static void onefs_load_faketimestamp_config(struct connection_struct *conn, struct onefs_vfs_share_config *cfg) { const char **parm; int snum = SNUM(conn); parm = lp_parm_string_list(snum, PARM_ONEFS_TYPE, PARM_ATIME_NOW, PARM_ATIME_NOW_DEFAULT); if (parm) { cfg->init_flags |= ONEFS_VFS_CONFIG_FAKETIMESTAMPS; set_namearray(&cfg->atime_now_list,*parm); } parm = lp_parm_string_list(snum, PARM_ONEFS_TYPE, PARM_CTIME_NOW, PARM_CTIME_NOW_DEFAULT); if (parm) { cfg->init_flags |= ONEFS_VFS_CONFIG_FAKETIMESTAMPS; set_namearray(&cfg->ctime_now_list,*parm); } parm = lp_parm_string_list(snum, PARM_ONEFS_TYPE, PARM_MTIME_NOW, PARM_MTIME_NOW_DEFAULT); if (parm) { cfg->init_flags |= ONEFS_VFS_CONFIG_FAKETIMESTAMPS; set_namearray(&cfg->mtime_now_list,*parm); } parm = lp_parm_string_list(snum, PARM_ONEFS_TYPE, PARM_ATIME_STATIC, PARM_ATIME_STATIC_DEFAULT); if (parm) { cfg->init_flags |= ONEFS_VFS_CONFIG_FAKETIMESTAMPS; set_namearray(&cfg->atime_static_list,*parm); } parm = lp_parm_string_list(snum, PARM_ONEFS_TYPE, PARM_MTIME_STATIC, PARM_MTIME_STATIC_DEFAULT); if (parm) { cfg->init_flags |= ONEFS_VFS_CONFIG_FAKETIMESTAMPS; set_namearray(&cfg->mtime_static_list,*parm); } cfg->atime_slop = lp_parm_int(snum, PARM_ONEFS_TYPE, PARM_ATIME_SLOP, PARM_ATIME_SLOP_DEFAULT); cfg->ctime_slop = lp_parm_int(snum, PARM_ONEFS_TYPE, PARM_CTIME_SLOP, PARM_CTIME_SLOP_DEFAULT); cfg->mtime_slop = lp_parm_int(snum, PARM_ONEFS_TYPE, PARM_MTIME_SLOP, PARM_MTIME_SLOP_DEFAULT); }
static void perfcount_test_dump_counters(void) { int i; struct perfcount_test_counter *head; count_mod = lp_parm_int(0, PARM_PC_TEST_TYPE, PARM_DUMPON_COUNT, PARM_DUMPON_COUNT_DEFAULT); if (count_mod == 0) { return; } if ((count++ % count_mod) != 0) return; DEBUG(0,("##### Dumping Performance Counters #####\n")); for (i=0; i < MAX_OP; i++) { struct perfcount_test_counter *next; for (head = g_list[i]; head != NULL; head = next) { next = head->next; perfcount_test_dump_counter(head, 0); SAFE_FREE(head); } g_list[i] = NULL; } }
static void remove_child_pid(struct smbd_parent_context *parent, pid_t pid, bool unclean_shutdown) { struct smbd_child_pid *child; struct server_id child_id; int ret; child_id = pid_to_procid(pid); ret = messaging_cleanup(parent->msg_ctx, pid); if ((ret != 0) && (ret != ENOENT)) { DEBUG(10, ("%s: messaging_cleanup returned %s\n", __func__, strerror(ret))); } smbprofile_cleanup(pid); for (child = parent->children; child != NULL; child = child->next) { if (child->pid == pid) { struct smbd_child_pid *tmp = child; DLIST_REMOVE(parent->children, child); TALLOC_FREE(tmp); parent->num_children -= 1; break; } } if (child == NULL) { /* not all forked child processes are added to the children list */ DEBUG(2, ("Could not find child %d -- ignoring\n", (int)pid)); return; } if (unclean_shutdown) { /* a child terminated uncleanly so tickle all processes to see if they can grab any of the pending locks */ DEBUG(3,(__location__ " Unclean shutdown of pid %u\n", (unsigned int)pid)); if (parent->cleanup_te == NULL) { /* call the cleanup timer, but not too often */ int cleanup_time = lp_parm_int(-1, "smbd", "cleanuptime", 20); parent->cleanup_te = tevent_add_timer(parent->ev_ctx, parent, timeval_current_ofs(cleanup_time, 0), cleanup_timeout_fn, parent); DEBUG(1,("Scheduled cleanup of brl and lock database after unclean shutdown\n")); } } if (!serverid_deregister(child_id)) { DEBUG(1, ("Could not remove pid %d from serverid.tdb\n", (int)pid)); } }
/* This hardcoded value should go into a ldb database! */ _PUBLIC_ enum srvsvc_PlatformId dcesrv_common_get_platform_id(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx) { enum srvsvc_PlatformId id; id = lp_parm_int(-1, "server_info", "platform_id", PLATFORM_ID_NT); return id; }
/* called when a wins name register has completed */ static void nbtd_wins_register_handler(struct composite_context *c) { NTSTATUS status; struct nbt_name_register_wins io; struct nbtd_iface_name *iname = talloc_get_type(c->async.private_data, struct nbtd_iface_name); TALLOC_CTX *tmp_ctx = talloc_new(iname); status = nbt_name_register_wins_recv(c, tmp_ctx, &io); if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { /* none of the WINS servers responded - try again periodically */ int wins_retry_time = lp_parm_int(iname->iface->nbtsrv->task->lp_ctx, NULL, "nbtd", "wins_retry", 300); event_add_timed(iname->iface->nbtsrv->task->event_ctx, iname, timeval_current_ofs(wins_retry_time, 0), nbtd_wins_register_retry, iname); talloc_free(tmp_ctx); return; } if (!NT_STATUS_IS_OK(status)) { DEBUG(1,("Name register failure with WINS for %s - %s\n", nbt_name_string(tmp_ctx, &iname->name), nt_errstr(status))); talloc_free(tmp_ctx); return; } if (io.out.rcode != 0) { DEBUG(1,("WINS server %s rejected name register of %s - %s\n", io.out.wins_server, nbt_name_string(tmp_ctx, &iname->name), nt_errstr(nbt_rcode_to_ntstatus(io.out.rcode)))); iname->nb_flags |= NBT_NM_CONFLICT; talloc_free(tmp_ctx); return; } /* success - start a periodic name refresh */ iname->nb_flags |= NBT_NM_ACTIVE; if (iname->wins_server) { /* * talloc_free() would generate a warning, * so steal it into the tmp context */ talloc_steal(tmp_ctx, iname->wins_server); } iname->wins_server = talloc_steal(iname, io.out.wins_server); iname->registration_time = timeval_current(); nbtd_wins_start_refresh_timer(iname); DEBUG(3,("Registered %s with WINS server %s\n", nbt_name_string(tmp_ctx, &iname->name), iname->wins_server)); talloc_free(tmp_ctx); }
static int prealloc_connect( struct vfs_handle_struct * handle, const char * service, const char * user) { module_debug = lp_parm_int(SNUM(handle->conn), MODULE, "msglevel", 100); return SMB_VFS_NEXT_CONNECT(handle, service, user); }
static int recycle_maxsize(vfs_handle_struct *handle) { int maxsize; maxsize = lp_parm_int(SNUM(handle->conn), "recycle", "maxsize", -1); DEBUG(10, ("recycle: maxsize = %d\n", maxsize)); return maxsize; }
static struct tdb_wrap_private *tdb_wrap_private_open(TALLOC_CTX *mem_ctx, const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode) { struct tdb_wrap_private *result; result = talloc(mem_ctx, struct tdb_wrap_private); if (result == NULL) { return NULL; } result->name = talloc_strdup(result, name); if (result->name == NULL) { goto fail; } #if _SAMBA_BUILD_ == 3 /* This #if _SAMBA_BUILD == 3 is very unfortunate, as it means * that in the top level build, these options are not * available for these databases. However, having two * different tdb_wrap lists is a worse fate, so this will do * for now */ if (!lp_use_mmap()) { tdb_flags |= TDB_NOMMAP; } if ((hash_size == 0) && (name != NULL)) { const char *base; base = strrchr_m(name, '/'); if (base != NULL) { base += 1; } else { base = name; } hash_size = lp_parm_int(-1, "tdb_hashsize", base, 0); } #endif result->tdb = tdb_open_compat(name, hash_size, tdb_flags, open_flags, mode, tdb_wrap_log, NULL); if (result->tdb == NULL) { goto fail; } talloc_set_destructor(result, tdb_wrap_private_destructor); DLIST_ADD(tdb_list, result); return result; fail: TALLOC_FREE(result); return NULL; }
static NTSTATUS vfs_worm_create_file(vfs_handle_struct *handle, struct smb_request *req, uint16_t root_dir_fid, struct smb_filename *smb_fname, uint32_t access_mask, uint32_t share_access, uint32_t create_disposition, uint32_t create_options, uint32_t file_attributes, uint32_t oplock_request, uint64_t allocation_size, uint32_t private_flags, struct security_descriptor *sd, struct ea_list *ea_list, files_struct **result, int *pinfo) { bool readonly = false; const uint32_t write_access_flags = FILE_WRITE_DATA | FILE_APPEND_DATA | FILE_WRITE_ATTRIBUTES | DELETE_ACCESS | WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS; NTSTATUS status; if (VALID_STAT(smb_fname->st)) { double age; age = timespec_elapsed(&smb_fname->st.st_ex_ctime); if (age > lp_parm_int(SNUM(handle->conn), "worm", "grace_period", 3600)) { readonly = true; } } if (readonly && (access_mask & write_access_flags)) { return NT_STATUS_ACCESS_DENIED; } status = SMB_VFS_NEXT_CREATE_FILE( handle, req, root_dir_fid, smb_fname, access_mask, share_access, create_disposition, create_options, file_attributes, oplock_request, allocation_size, private_flags, sd, ea_list, result, pinfo); if (!NT_STATUS_IS_OK(status)) { return status; } /* * Access via MAXIMUM_ALLOWED_ACCESS? */ if (readonly && ((*result)->access_mask & write_access_flags)) { close_file(req, *result, NORMAL_CLOSE); return NT_STATUS_ACCESS_DENIED; } return NT_STATUS_OK; }
/* start a timer to refresh this name */ static void nbtd_wins_start_refresh_timer(struct nbtd_iface_name *iname) { uint32_t refresh_time; uint32_t max_refresh_time = lp_parm_int(iname->iface->nbtsrv->task->lp_ctx, NULL, "nbtd", "max_refresh_time", 7200); refresh_time = MIN(max_refresh_time, iname->ttl/2); event_add_timed(iname->iface->nbtsrv->task->event_ctx, iname, timeval_add(&iname->registration_time, refresh_time, 0), nbtd_wins_refresh, iname); }
/* startup the WINS server, if configured */ NTSTATUS nbtd_winsserver_init(struct nbtd_server *nbtsrv) { uint32_t tmp; const char *owner; if (!lp_wins_support(nbtsrv->task->lp_ctx)) { nbtsrv->winssrv = NULL; return NT_STATUS_OK; } nbtsrv->winssrv = talloc_zero(nbtsrv, struct wins_server); NT_STATUS_HAVE_NO_MEMORY(nbtsrv->winssrv); nbtsrv->winssrv->config.max_renew_interval = lp_max_wins_ttl(nbtsrv->task->lp_ctx); nbtsrv->winssrv->config.min_renew_interval = lp_min_wins_ttl(nbtsrv->task->lp_ctx); tmp = lp_parm_int(nbtsrv->task->lp_ctx, NULL, "wreplsrv", "tombstone_interval", 6*24*60*60); nbtsrv->winssrv->config.tombstone_interval = tmp; tmp = lp_parm_int(nbtsrv->task->lp_ctx, NULL, "wreplsrv"," tombstone_timeout", 1*24*60*60); nbtsrv->winssrv->config.tombstone_timeout = tmp; owner = lp_parm_string(nbtsrv->task->lp_ctx, NULL, "winsdb", "local_owner"); if (owner == NULL) { struct interface *ifaces; load_interfaces(nbtsrv->task, lp_interfaces(nbtsrv->task->lp_ctx), &ifaces); owner = iface_n_ip(ifaces, 0); } nbtsrv->winssrv->wins_db = winsdb_connect(nbtsrv->winssrv, nbtsrv->task->event_ctx, nbtsrv->task->lp_ctx, owner, WINSDB_HANDLE_CALLER_NBTD); if (!nbtsrv->winssrv->wins_db) { return NT_STATUS_INTERNAL_DB_ERROR; } irpc_add_name(nbtsrv->task->msg_ctx, "wins_server"); return NT_STATUS_OK; }
void pfh_daemon_config(const char *daemon_name, struct pf_daemon_config *cfg, struct pf_daemon_config *default_cfg) { int min, max, rate, allow, life; min = lp_parm_int(GLOBAL_SECTION_SNUM, daemon_name, "prefork_min_children", default_cfg->min_children); max = lp_parm_int(GLOBAL_SECTION_SNUM, daemon_name, "prefork_max_children", default_cfg->max_children); rate = lp_parm_int(GLOBAL_SECTION_SNUM, daemon_name, "prefork_spawn_rate", default_cfg->spawn_rate); allow = lp_parm_int(GLOBAL_SECTION_SNUM, daemon_name, "prefork_max_allowed_clients", default_cfg->max_allowed_clients); life = lp_parm_int(GLOBAL_SECTION_SNUM, daemon_name, "prefork_child_min_life", default_cfg->child_min_life); if (max > cfg->max_children && cfg->max_children != 0) { cfg->prefork_status |= PFH_NEW_MAX; } cfg->min_children = min; cfg->max_children = max; cfg->spawn_rate = rate; cfg->max_allowed_clients = allow; cfg->child_min_life = life; }
static int prealloc_connect( struct vfs_handle_struct * handle, const char * service, const char * user) { int ret = SMB_VFS_NEXT_CONNECT(handle, service, user); if (ret < 0) { return ret; } module_debug = lp_parm_int(SNUM(handle->conn), MODULE, "debug", 100); return 0; }
static void remove_child_pid(struct tevent_context *ev_ctx, pid_t pid, bool unclean_shutdown) { struct child_pid *child; static struct timed_event *cleanup_te; struct server_id child_id; if (unclean_shutdown) { /* a child terminated uncleanly so tickle all processes to see if they can grab any of the pending locks */ DEBUG(3,(__location__ " Unclean shutdown of pid %u\n", (unsigned int)pid)); if (!cleanup_te) { /* call the cleanup timer, but not too often */ int cleanup_time = lp_parm_int(-1, "smbd", "cleanuptime", 20); cleanup_te = event_add_timed(ev_ctx, NULL, timeval_current_ofs(cleanup_time, 0), cleanup_timeout_fn, &cleanup_te); DEBUG(1,("Scheduled cleanup of brl and lock database after unclean shutdown\n")); } } child_id = procid_self(); /* Just initialize pid and potentially vnn */ child_id.pid = pid; if (!serverid_deregister(child_id)) { DEBUG(1, ("Could not remove pid %d from serverid.tdb\n", (int)pid)); } for (child = children; child != NULL; child = child->next) { if (child->pid == pid) { struct child_pid *tmp = child; DLIST_REMOVE(children, child); SAFE_FREE(tmp); num_children -= 1; return; } } /* not all forked child processes are added to the children list */ DEBUG(1, ("Could not find child %d -- ignoring\n", (int)pid)); }
static int crossrename_connect( struct vfs_handle_struct * handle, const char * service, const char * user) { int ret = SMB_VFS_NEXT_CONNECT(handle, service, user); if (ret < 0) { return ret; } module_sizelimit = (off_t) lp_parm_int(SNUM(handle->conn), MODULE, "sizelimit", 20); /* convert from MiB to byte: */ module_sizelimit *= 1048576; return 0; }
void trigger_write_time_update(struct files_struct *fsp) { int delay; if (fsp->posix_open) { /* Don't use delayed writes on POSIX files. */ return; } if (fsp->write_time_forced) { /* No point - "sticky" write times * in effect. */ return; } /* We need to remember someone did a write * and update to current time on close. */ fsp->update_write_time_on_close = true; if (fsp->update_write_time_triggered) { /* * We only update the write time after 2 seconds * on the first normal write. After that * no other writes affect this until close. */ return; } fsp->update_write_time_triggered = true; delay = lp_parm_int(SNUM(fsp->conn), "smbd", "writetimeupdatedelay", WRITE_TIME_UPDATE_USEC_DELAY); DEBUG(5, ("Update write time %d usec later on %s\n", delay, fsp_str_dbg(fsp))); /* trigger the update 2 seconds later */ fsp->update_write_time_event = event_add_timed(smbd_event_context(), NULL, timeval_current_ofs(0, delay), update_write_time_handler, fsp); }
/* open winsdb */ static NTSTATUS wreplsrv_open_winsdb(struct wreplsrv_service *service, struct loadparm_context *lp_ctx) { const char *owner = lp_parm_string(lp_ctx, NULL, "winsdb", "local_owner"); if (owner == NULL) { struct interface *ifaces; load_interfaces(service, lp_interfaces(lp_ctx), &ifaces); owner = iface_n_ip(ifaces, 0); } service->wins_db = winsdb_connect(service, service->task->event_ctx, lp_ctx, owner, WINSDB_HANDLE_CALLER_WREPL); if (!service->wins_db) { return NT_STATUS_INTERNAL_DB_ERROR; } service->config.ldb = wins_config_db_connect(service, service->task->event_ctx, lp_ctx); if (!service->config.ldb) { return NT_STATUS_INTERNAL_DB_ERROR; } /* the default renew interval is 6 days */ service->config.renew_interval = lp_parm_int(lp_ctx, NULL,"wreplsrv","renew_interval", 6*24*60*60); /* the default tombstone (extinction) interval is 6 days */ service->config.tombstone_interval= lp_parm_int(lp_ctx, NULL,"wreplsrv","tombstone_interval", 6*24*60*60); /* the default tombstone (extinction) timeout is 1 day */ service->config.tombstone_timeout = lp_parm_int(lp_ctx, NULL,"wreplsrv","tombstone_timeout", 1*24*60*60); /* the default tombstone extra timeout is 3 days */ service->config.tombstone_extra_timeout = lp_parm_int(lp_ctx, NULL,"wreplsrv","tombstone_extra_timeout", 3*24*60*60); /* the default verify interval is 24 days */ service->config.verify_interval = lp_parm_int(lp_ctx, NULL,"wreplsrv","verify_interval", 24*24*60*60); /* the default scavenging interval is 'renew_interval/2' */ service->config.scavenging_interval=lp_parm_int(lp_ctx, NULL,"wreplsrv","scavenging_interval", service->config.renew_interval/2); /* the maximun interval to the next periodic processing event */ service->config.periodic_interval = lp_parm_int(lp_ctx, NULL,"wreplsrv","periodic_interval", 15); return NT_STATUS_OK; }
static void fss_seq_tout_set(TALLOC_CTX *mem_ctx, uint32_t timeout_s, struct fss_sc_set *sc_set, struct tevent_timer **tmr_out) { struct tevent_timer *tmr; struct GUID *sc_set_id = NULL; uint32_t tout; /* allow changes to timeout for testing/debugging purposes */ tout = lp_parm_int(GLOBAL_SECTION_SNUM, "fss", "sequence timeout", timeout_s); if (tout == 0) { DEBUG(2, ("FSRVP message sequence timeout disabled\n")); *tmr_out = NULL; return; } if (sc_set) { /* don't use talloc_memdup(), need explicit type for callback */ sc_set_id = talloc(mem_ctx, struct GUID); if (sc_set_id == NULL) { smb_panic("no memory"); } memcpy(sc_set_id, &sc_set->id, sizeof(*sc_set_id)); } tmr = tevent_add_timer(server_event_context(), mem_ctx, timeval_current_ofs(tout, 0), fss_seq_tout_handler, sc_set_id); if (tmr == NULL) { talloc_free(sc_set_id); smb_panic("no memory"); } *tmr_out = tmr; }
static int cprime_connect( struct vfs_handle_struct * handle, const char * service, const char * user) { module_debug = lp_parm_int(SNUM(handle->conn), MODULE, "debug", 100); if (g_readbuf) { /* Only allocate g_readbuf once. If the config changes and * another client multiplexes onto this smbd, we don't want * to risk memory corruption. */ return SMB_VFS_NEXT_CONNECT(handle, service, user); } g_readsz = conv_str_size(lp_parm_const_string(SNUM(handle->conn), MODULE, "rsize", NULL)); if (g_readsz < READAHEAD_MIN) { DEBUG(module_debug, ("%s: %ld bytes of readahead " "requested, using minimum of %u\n", MODULE, (long)g_readsz, READAHEAD_MIN)); g_readsz = READAHEAD_MIN; } else if (g_readsz > READAHEAD_MAX) { DEBUG(module_debug, ("%s: %ld bytes of readahead " "requested, using maximum of %u\n", MODULE, (long)g_readsz, READAHEAD_MAX)); g_readsz = READAHEAD_MAX; } if ((g_readbuf = SMB_MALLOC(g_readsz)) == NULL) { /* Turn off readahead if we can't get a buffer. */ g_readsz = 0; } return SMB_VFS_NEXT_CONNECT(handle, service, user); }
static int nfs4acl_connect(struct vfs_handle_struct *handle, const char *service, const char *user) { struct nfs4acl_config *config = NULL; const struct enum_list *default_acl_style_list = NULL; const char *default_xattr_name = NULL; int enumval; unsigned nfs_version; int ret; default_acl_style_list = get_default_acl_style_list(); config = talloc_zero(handle->conn, struct nfs4acl_config); if (config == NULL) { DBG_ERR("talloc_zero() failed\n"); return -1; } ret = SMB_VFS_NEXT_CONNECT(handle, service, user); if (ret < 0) { TALLOC_FREE(config); return ret; } ret = smbacl4_get_vfs_params(handle->conn, &config->nfs4_params); if (ret < 0) { TALLOC_FREE(config); return ret; } enumval = lp_parm_enum(SNUM(handle->conn), "nfs4acl_xattr", "encoding", nfs4acl_encoding, NFS4ACL_ENCODING_NDR); if (enumval == -1) { DBG_ERR("Invalid \"nfs4acl_xattr:encoding\" parameter\n"); return -1; } config->encoding = (enum nfs4acl_encoding)enumval; switch (config->encoding) { case NFS4ACL_ENCODING_XDR: default_xattr_name = NFS4ACL_XDR_XATTR_NAME; break; case NFS4ACL_ENCODING_NDR: default: default_xattr_name = NFS4ACL_NDR_XATTR_NAME; break; } nfs_version = (unsigned)lp_parm_int(SNUM(handle->conn), "nfs4acl_xattr", "version", 41); switch (nfs_version) { case 40: config->nfs_version = ACL4_XATTR_VERSION_40; break; case 41: config->nfs_version = ACL4_XATTR_VERSION_41; break; default: config->nfs_version = ACL4_XATTR_VERSION_DEFAULT; break; } config->default_acl_style = lp_parm_enum(SNUM(handle->conn), "nfs4acl_xattr", "default acl style", default_acl_style_list, DEFAULT_ACL_EVERYONE); config->xattr_name = lp_parm_talloc_string(config, SNUM(handle->conn), "nfs4acl_xattr", "xattr_name", default_xattr_name); SMB_VFS_HANDLE_SET_DATA(handle, config, NULL, struct nfs4acl_config, return -1); /* * Ensure we have the parameters correct if we're using this module. */ DBG_NOTICE("Setting 'inherit acls = true', " "'dos filemode = true', " "'force unknown acl user = true', " "'create mask = 0666', " "'directory mask = 0777' and " "'store dos attributes = yes' " "for service [%s]\n", service); lp_do_parameter(SNUM(handle->conn), "inherit acls", "true"); lp_do_parameter(SNUM(handle->conn), "dos filemode", "true"); lp_do_parameter(SNUM(handle->conn), "force unknown acl user", "true"); lp_do_parameter(SNUM(handle->conn), "create mask", "0666"); lp_do_parameter(SNUM(handle->conn), "directory mask", "0777"); lp_do_parameter(SNUM(handle->conn), "store dos attributes", "yes"); return 0; }
/* This hardcoded value should go into a ldb database! */ _PUBLIC_ uint32_t dcesrv_common_get_version_build(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx) { return lp_parm_int(-1, "server_info", "version_build", 3790); }
static int aio_get_num_threads(struct vfs_handle_struct *handle) { return lp_parm_int(SNUM(handle->conn), "aio_pthread", "aio num threads", 100); }
static bool recalc_brl_timeout(struct smbd_server_connection *sconn) { struct blocking_lock_record *blr; struct timeval next_timeout; int max_brl_timeout = lp_parm_int(-1, "brl", "recalctime", 5); TALLOC_FREE(sconn->smb1.locks.brl_timeout); next_timeout = timeval_zero(); for (blr = sconn->smb1.locks.blocking_lock_queue; blr; blr = blr->next) { if (timeval_is_zero(&blr->expire_time)) { /* * If we're blocked on pid 0xFFFFFFFFFFFFFFFFLL this is * a POSIX lock, so calculate a timeout of * 10 seconds into the future. */ if (blr->blocking_smblctx == 0xFFFFFFFFFFFFFFFFLL) { struct timeval psx_to = timeval_current_ofs(10, 0); next_timeout = timeval_brl_min(&next_timeout, &psx_to); } continue; } next_timeout = timeval_brl_min(&next_timeout, &blr->expire_time); } if (timeval_is_zero(&next_timeout)) { DEBUG(10, ("Next timeout = Infinite.\n")); return True; } /* to account for unclean shutdowns by clients we need a maximum timeout that we use for checking pending locks. If we have any pending locks at all, then check if the pending lock can continue at least every brl:recalctime seconds (default 5 seconds). This saves us needing to do a message_send_all() in the SIGCHLD handler in the parent daemon. That message_send_all() caused O(n^2) work to be done when IP failovers happened in clustered Samba, which could make the entire system unusable for many minutes. */ if (max_brl_timeout > 0) { struct timeval min_to = timeval_current_ofs(max_brl_timeout, 0); next_timeout = timeval_min(&next_timeout, &min_to); } if (DEBUGLVL(10)) { struct timeval cur, from_now; cur = timeval_current(); from_now = timeval_until(&cur, &next_timeout); DEBUG(10, ("Next timeout = %d.%d seconds from now.\n", (int)from_now.tv_sec, (int)from_now.tv_usec)); } sconn->smb1.locks.brl_timeout = tevent_add_timer(sconn->ev_ctx, NULL, next_timeout, brl_timeout_fn, sconn); if (sconn->smb1.locks.brl_timeout == NULL) { return False; } return True; }
/* startup the dsdb replicator service task */ static void dreplsrv_task_init(struct task_server *task) { WERROR status; struct dreplsrv_service *service; uint32_t periodic_startup_interval; switch (lp_server_role(task->lp_ctx)) { case ROLE_STANDALONE: task_server_terminate(task, "dreplsrv: no DSDB replication required in standalone configuration"); return; case ROLE_DOMAIN_MEMBER: task_server_terminate(task, "dreplsrv: no DSDB replication required in domain member configuration"); return; case ROLE_DOMAIN_CONTROLLER: /* Yes, we want DSDB replication */ break; } task_server_set_title(task, "task[dreplsrv]"); service = talloc_zero(task, struct dreplsrv_service); if (!service) { task_server_terminate(task, "dreplsrv_task_init: out of memory"); return; } service->task = task; service->startup_time = timeval_current(); task->private_data = service; status = dreplsrv_init_creds(service); if (!W_ERROR_IS_OK(status)) { task_server_terminate(task, talloc_asprintf(task, "dreplsrv: Failed to obtain server credentials: %s\n", win_errstr(status))); return; } status = dreplsrv_connect_samdb(service, task->lp_ctx); if (!W_ERROR_IS_OK(status)) { task_server_terminate(task, talloc_asprintf(task, "dreplsrv: Failed to connect to local samdb: %s\n", win_errstr(status))); return; } status = dreplsrv_load_partitions(service); if (!W_ERROR_IS_OK(status)) { task_server_terminate(task, talloc_asprintf(task, "dreplsrv: Failed to load partitions: %s\n", win_errstr(status))); return; } periodic_startup_interval = lp_parm_int(task->lp_ctx, NULL, "dreplsrv", "periodic_startup_interval", 15); /* in seconds */ service->periodic.interval = lp_parm_int(task->lp_ctx, NULL, "dreplsrv", "periodic_interval", 300); /* in seconds */ status = dreplsrv_periodic_schedule(service, periodic_startup_interval); if (!W_ERROR_IS_OK(status)) { task_server_terminate(task, talloc_asprintf(task, "dreplsrv: Failed to periodic schedule: %s\n", win_errstr(status))); return; } irpc_add_name(task->msg_ctx, "dreplsrv"); }
int torture_setting_int(struct torture_context *test, const char *name, int default_value) { return lp_parm_int(test->lp_ctx, NULL, "torture", name, default_value); }
/* * Test for maximum ea size - more than one ea name is checked. * * Additional parameters can be passed, to allow further testing: * * default * maxeasize 65536 limit the max. size for a single EA name * maxeanames 101 limit of the number of tested names * maxeastart 1 this EA size is used to test for the 1st EA (atm) * maxeadebug 0 if set True, further debug output is done - in addition * the testfile is not deleted for further inspection! * * Set some/all of these options on the cmdline with: * --option torture:maxeasize=1024 --option torture:maxeadebug=1 ... * */ static BOOL test_max_eas(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { NTSTATUS status; union smb_open io; const char *fname = BASEDIR "\\ea_max.txt"; int fnum = -1; BOOL ret = True; BOOL err = False; int i, j, k, last, total; DATA_BLOB eablob; char *eaname = NULL; int maxeasize; int maxeanames; int maxeastart; printf("TESTING SETFILEINFO MAX. EA_SET\n"); maxeasize = lp_parm_int(-1, "torture", "maxeasize", 65536); maxeanames = lp_parm_int(-1, "torture", "maxeanames", 101); maxeastart = lp_parm_int(-1, "torture", "maxeastart", 1); maxeadebug = lp_parm_int(-1, "torture", "maxeadebug", 0); /* Do some sanity check on possibly passed parms */ if (maxeasize <= 0) { printf("Invalid parameter 'maxeasize=%d'",maxeasize); err = True; } if (maxeanames <= 0) { printf("Invalid parameter 'maxeanames=%d'",maxeanames); err = True; } if (maxeastart <= 0) { printf("Invalid parameter 'maxeastart=%d'",maxeastart); err = True; } if (maxeadebug < 0) { printf("Invalid parameter 'maxeadebug=%d'",maxeadebug); err = True; } if (err) { printf("\n\n"); goto done; } if (maxeastart > maxeasize) { maxeastart = maxeasize; printf ("'maxeastart' outside range - corrected to %d\n", maxeastart); } printf("MAXEA parms: maxeasize=%d maxeanames=%d maxeastart=%d" " maxeadebug=%d\n", maxeasize, maxeanames, maxeastart, maxeadebug); io.generic.level = RAW_OPEN_NTCREATEX; io.ntcreatex.in.root_fid = 0; io.ntcreatex.in.flags = 0; io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; io.ntcreatex.in.create_options = 0; io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; io.ntcreatex.in.alloc_size = 0; io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); fnum = io.ntcreatex.out.file.fnum; eablob = data_blob_talloc(mem_ctx, NULL, maxeasize); if (eablob.data == NULL) { goto done; } /* * Fill in some EA data - the offset could be easily checked * during a hexdump. */ for (i = 0, k = 0; i < eablob.length / 4; i++, k+=4) { eablob.data[k] = k & 0xff; eablob.data[k+1] = (k >> 8) & 0xff; eablob.data[k+2] = (k >> 16) & 0xff; eablob.data[k+3] = (k >> 24) & 0xff; } i = eablob.length % 4; if (i-- > 0) { eablob.data[k] = k & 0xff; if (i-- > 0) { eablob.data[k+1] = (k >> 8) & 0xff; if (i-- > 0) { eablob.data[k+2] = (k >> 16) & 0xff; }