📄 loadparm.c
字号:
{"strict sync", P_BOOL, P_LOCAL, LOCAL_VAR(bStrictSync), NULL, NULL}, {"case insensitive filesystem", P_BOOL, P_LOCAL, LOCAL_VAR(bCIFileSystem), NULL, NULL}, {"max print jobs", P_INTEGER, P_LOCAL, LOCAL_VAR(iMaxPrintJobs), NULL, NULL}, {"printable", P_BOOL, P_LOCAL, LOCAL_VAR(bPrint_ok), NULL, NULL}, {"print ok", P_BOOL, P_LOCAL, LOCAL_VAR(bPrint_ok), NULL, NULL}, {"printer name", P_STRING, P_LOCAL, LOCAL_VAR(szPrintername), NULL, NULL}, {"printer", P_STRING, P_LOCAL, LOCAL_VAR(szPrintername), NULL, NULL}, {"map system", P_BOOL, P_LOCAL, LOCAL_VAR(bMap_system), NULL, NULL}, {"map hidden", P_BOOL, P_LOCAL, LOCAL_VAR(bMap_hidden), NULL, NULL}, {"map archive", P_BOOL, P_LOCAL, LOCAL_VAR(bMap_archive), NULL, NULL}, {"preferred master", P_ENUM, P_GLOBAL, GLOBAL_VAR(bPreferredMaster), NULL, enum_bool_auto}, {"prefered master", P_ENUM, P_GLOBAL, GLOBAL_VAR(bPreferredMaster), NULL, enum_bool_auto}, {"local master", P_BOOL, P_GLOBAL, GLOBAL_VAR(bLocalMaster), NULL, NULL}, {"browseable", P_BOOL, P_LOCAL, LOCAL_VAR(bBrowseable), NULL, NULL}, {"browsable", P_BOOL, P_LOCAL, LOCAL_VAR(bBrowseable), NULL, NULL}, {"wins server", P_LIST, P_GLOBAL, GLOBAL_VAR(szWINSservers), NULL, NULL}, {"wins support", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWINSsupport), NULL, NULL}, {"dns proxy", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWINSdnsProxy), NULL, NULL}, {"wins hook", P_STRING, P_GLOBAL, GLOBAL_VAR(szWINSHook), NULL, NULL}, {"csc policy", P_ENUM, P_LOCAL, LOCAL_VAR(iCSCPolicy), NULL, enum_csc_policy}, {"strict locking", P_BOOL, P_LOCAL, LOCAL_VAR(bStrictLocking), NULL, NULL}, {"oplocks", P_BOOL, P_LOCAL, LOCAL_VAR(bOplocks), NULL, NULL}, {"share backend", P_STRING, P_GLOBAL, GLOBAL_VAR(szShareBackend), NULL, NULL}, {"preload", P_STRING, P_GLOBAL, GLOBAL_VAR(szAutoServices), NULL, NULL}, {"auto services", P_STRING, P_GLOBAL, GLOBAL_VAR(szAutoServices), NULL, NULL}, {"lock dir", P_STRING, P_GLOBAL, GLOBAL_VAR(szLockDir), NULL, NULL}, {"lock directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szLockDir), NULL, NULL}, {"modules dir", P_STRING, P_GLOBAL, GLOBAL_VAR(szModulesDir), NULL, NULL}, {"pid directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szPidDir), NULL, NULL}, {"js include", P_LIST, P_GLOBAL, GLOBAL_VAR(jsInclude), NULL, NULL}, {"setup directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szSetupDir), NULL, NULL}, {"socket address", P_STRING, P_GLOBAL, GLOBAL_VAR(szSocketAddress), NULL, NULL}, {"copy", P_STRING, P_LOCAL, LOCAL_VAR(szCopy), handle_copy, NULL}, {"include", P_STRING, P_LOCAL, LOCAL_VAR(szInclude), handle_include, NULL}, {"available", P_BOOL, P_LOCAL, LOCAL_VAR(bAvailable), NULL, NULL}, {"volume", P_STRING, P_LOCAL, LOCAL_VAR(volume), NULL, NULL }, {"fstype", P_STRING, P_LOCAL, LOCAL_VAR(fstype), NULL, NULL}, {"panic action", P_STRING, P_GLOBAL, GLOBAL_VAR(panic_action), NULL, NULL}, {"msdfs root", P_BOOL, P_LOCAL, LOCAL_VAR(bMSDfsRoot), NULL, NULL}, {"host msdfs", P_BOOL, P_GLOBAL, GLOBAL_VAR(bHostMSDfs), NULL, NULL}, {"winbind separator", P_STRING, P_GLOBAL, GLOBAL_VAR(szWinbindSeparator), NULL, NULL }, {"winbindd socket directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szWinbinddSocketDirectory), NULL, NULL }, {"winbind sealed pipes", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWinbindSealedPipes), NULL, NULL }, {"template shell", P_STRING, P_GLOBAL, GLOBAL_VAR(szTemplateShell), NULL, NULL }, {"template homedir", P_STRING, P_GLOBAL, GLOBAL_VAR(szTemplateHomedir), NULL, NULL }, {"idmap trusted only", P_BOOL, P_GLOBAL, GLOBAL_VAR(bIdmapTrustedOnly), NULL, NULL}, {"ntp signd socket directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szNTPSignDSocketDirectory), NULL, NULL }, {NULL, P_BOOL, P_NONE, 0, NULL, NULL}};/* local variables */struct loadparm_context { const char *szConfigFile; struct loadparm_global *globals; struct loadparm_service **services; struct loadparm_service *sDefault; int iNumServices; struct loadparm_service *currentService; bool bInGlobalSection; struct file_lists { struct file_lists *next; char *name; char *subfname; time_t modtime; } *file_lists; unsigned int flags[NUMPARAMETERS]; struct smb_iconv_convenience *iconv_convenience;};struct loadparm_service *lp_default_service(struct loadparm_context *lp_ctx){ return lp_ctx->sDefault;}/* return the parameter table*/struct parm_struct *lp_parm_table(void){ return parm_table;}/** * Convenience routine to grab string parameters into temporary memory * and run standard_sub_basic on them. * * The buffers can be written to by * callers without affecting the source string. */static const char *lp_string(const char *s){#if 0 /* until REWRITE done to make thread-safe */ size_t len = s ? strlen(s) : 0; char *ret;#endif /* The follow debug is useful for tracking down memory problems especially if you have an inner loop that is calling a lp_*() function that returns a string. Perhaps this debug should be present all the time? */#if 0 DEBUG(10, ("lp_string(%s)\n", s));#endif#if 0 /* until REWRITE done to make thread-safe */ if (!lp_talloc) lp_talloc = talloc_init("lp_talloc"); ret = talloc_array(lp_talloc, char, len + 100); /* leave room for substitution */ if (!ret) return NULL; if (!s) *ret = 0; else strlcpy(ret, s, len); if (trim_string(ret, "\"", "\"")) { if (strchr(ret,'"') != NULL) strlcpy(ret, s, len); } standard_sub_basic(ret,len+100); return (ret);#endif return s;}/* In this section all the functions that are used to access the parameters from the rest of the program are defined*/#define FN_GLOBAL_STRING(fn_name,var_name) \ const char *fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return NULL; return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : "";}#define FN_GLOBAL_CONST_STRING(fn_name,var_name) \ const char *fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return NULL; return lp_ctx->globals->var_name ? lp_ctx->globals->var_name : "";}#define FN_GLOBAL_LIST(fn_name,var_name) \ const char **fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return NULL; return lp_ctx->globals->var_name;}#define FN_GLOBAL_BOOL(fn_name,var_name) \ bool fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return false; return lp_ctx->globals->var_name;}#if 0 /* unused */#define FN_GLOBAL_CHAR(fn_name,ptr) \ char fn_name(void) {return(*(char *)(ptr));}#endif#define FN_GLOBAL_INTEGER(fn_name,var_name) \ int fn_name(struct loadparm_context *lp_ctx) {return lp_ctx->globals->var_name;}#define FN_LOCAL_STRING(fn_name,val) \ const char *fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return(lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val)));}#define FN_LOCAL_LIST(fn_name,val) \ const char **fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return(const char **)(service != NULL && service->val != NULL? service->val : sDefault->val);}#define FN_LOCAL_BOOL(fn_name,val) \ bool fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return((service != NULL)? service->val : sDefault->val);}#define FN_LOCAL_INTEGER(fn_name,val) \ int fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return((service != NULL)? service->val : sDefault->val);}_PUBLIC_ FN_GLOBAL_INTEGER(lp_server_role, server_role)_PUBLIC_ FN_GLOBAL_LIST(lp_smb_ports, smb_ports)_PUBLIC_ FN_GLOBAL_INTEGER(lp_nbt_port, nbt_port)_PUBLIC_ FN_GLOBAL_INTEGER(lp_dgram_port, dgram_port)_PUBLIC_ FN_GLOBAL_INTEGER(lp_cldap_port, cldap_port)_PUBLIC_ FN_GLOBAL_INTEGER(lp_krb5_port, krb5_port)_PUBLIC_ FN_GLOBAL_INTEGER(lp_kpasswd_port, kpasswd_port)_PUBLIC_ FN_GLOBAL_INTEGER(lp_web_port, web_port)_PUBLIC_ FN_GLOBAL_STRING(lp_swat_directory, swat_directory)_PUBLIC_ FN_GLOBAL_BOOL(lp_tls_enabled, tls_enabled)_PUBLIC_ FN_GLOBAL_STRING(lp_tls_keyfile, tls_keyfile)_PUBLIC_ FN_GLOBAL_STRING(lp_tls_certfile, tls_certfile)_PUBLIC_ FN_GLOBAL_STRING(lp_tls_cafile, tls_cafile)_PUBLIC_ FN_GLOBAL_STRING(lp_tls_crlfile, tls_crlfile)_PUBLIC_ FN_GLOBAL_STRING(lp_tls_dhpfile, tls_dhpfile)_PUBLIC_ FN_GLOBAL_STRING(lp_share_backend, szShareBackend)_PUBLIC_ FN_GLOBAL_STRING(lp_sam_url, szSAM_URL)_PUBLIC_ FN_GLOBAL_STRING(lp_idmap_url, szIDMAP_URL)_PUBLIC_ FN_GLOBAL_STRING(lp_secrets_url, szSECRETS_URL)_PUBLIC_ FN_GLOBAL_STRING(lp_spoolss_url, szSPOOLSS_URL)_PUBLIC_ FN_GLOBAL_STRING(lp_wins_config_url, szWINS_CONFIG_URL)_PUBLIC_ FN_GLOBAL_STRING(lp_wins_url, szWINS_URL)_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_winbind_separator, szWinbindSeparator)_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_winbindd_socket_directory, szWinbinddSocketDirectory)_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_template_shell, szTemplateShell)_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_template_homedir, szTemplateHomedir)_PUBLIC_ FN_GLOBAL_BOOL(lp_winbind_sealed_pipes, bWinbindSealedPipes)_PUBLIC_ FN_GLOBAL_BOOL(lp_idmap_trusted_only, bIdmapTrustedOnly)_PUBLIC_ FN_GLOBAL_STRING(lp_private_dir, szPrivateDir)_PUBLIC_ FN_GLOBAL_STRING(lp_serverstring, szServerString)_PUBLIC_ FN_GLOBAL_STRING(lp_lockdir, szLockDir)_PUBLIC_ FN_GLOBAL_STRING(lp_modulesdir, szModulesDir)_PUBLIC_ FN_GLOBAL_STRING(lp_setupdir, szSetupDir)_PUBLIC_ FN_GLOBAL_STRING(lp_ncalrpc_dir, ncalrpc_dir)_PUBLIC_ FN_GLOBAL_STRING(lp_dos_charset, dos_charset)_PUBLIC_ FN_GLOBAL_STRING(lp_unix_charset, unix_charset)_PUBLIC_ FN_GLOBAL_STRING(lp_display_charset, display_charset)_PUBLIC_ FN_GLOBAL_STRING(lp_piddir, szPidDir)_PUBLIC_ FN_GLOBAL_LIST(lp_dcerpc_endpoint_servers, dcerpc_ep_servers)_PUBLIC_ FN_GLOBAL_LIST(lp_server_services, server_services)_PUBLIC_ FN_GLOBAL_STRING(lp_ntptr_providor, ntptr_providor)_PUBLIC_ FN_GLOBAL_STRING(lp_auto_services, szAutoServices)_PUBLIC_ FN_GLOBAL_STRING(lp_passwd_chat, szPasswdChat)_PUBLIC_ FN_GLOBAL_LIST(lp_passwordserver, szPasswordServers)_PUBLIC_ FN_GLOBAL_LIST(lp_name_resolve_order, szNameResolveOrder)_PUBLIC_ FN_GLOBAL_STRING(lp_realm, szRealm)_PUBLIC_ FN_GLOBAL_STRING(lp_socket_options, socket_options)_PUBLIC_ FN_GLOBAL_STRING(lp_workgroup, szWorkgroup)_PUBLIC_ FN_GLOBAL_STRING(lp_netbios_name, szNetbiosName)_PUBLIC_ FN_GLOBAL_STRING(lp_netbios_scope, szNetbiosScope)_PUBLIC_ FN_GLOBAL_LIST(lp_wins_server_list, szWINSservers)_PUBLIC_ FN_GLOBAL_LIST(lp_interfaces, szInterfaces)_PUBLIC_ FN_GLOBAL_STRING(lp_socket_address, szSocketAddress)_PUBLIC_ FN_GLOBAL_LIST(lp_netbios_aliases, szNetbiosAliases)_PUBLIC_ FN_GLOBAL_BOOL(lp_disable_netbios, bDisableNetbios)_PUBLIC_ FN_GLOBAL_BOOL(lp_wins_support, bWINSsupport)_PUBLIC_ FN_GLOBAL_BOOL(lp_wins_dns_proxy, bWINSdnsProxy)_PUBLIC_ FN_GLOBAL_STRING(lp_wins_hook, szWINSHook)_PUBLIC_ FN_GLOBAL_BOOL(lp_local_master, bLocalMaster)_PUBLIC_ FN_GLOBAL_BOOL(lp_readraw, bReadRaw)_PUBLIC_ FN_GLOBAL_BOOL(lp_large_readwrite, bLargeReadwrite)_PUBLIC_ FN_GLOBAL_BOOL(lp_writeraw, bWriteRaw)_PUBLIC_ FN_GLOBAL_BOOL(lp_null_passwords, bNullPasswords)_PUBLIC_ FN_GLOBAL_BOOL(lp_obey_pam_restrictions, bObeyPamRestrictions)_PUBLIC_ FN_GLOBAL_BOOL(lp_encrypted_passwords, bEncryptPasswords)_PUBLIC_ FN_GLOBAL_BOOL(lp_time_server, bTimeServer)_PUBLIC_ FN_GLOBAL_BOOL(lp_bind_interfaces_only, bBindInterfacesOnly)_PUBLIC_ FN_GLOBAL_BOOL(lp_unicode, bUnicode)_PUBLIC_ FN_GLOBAL_BOOL(lp_nt_status_support, bNTStatusSupport)_PUBLIC_ FN_GLOBAL_BOOL(lp_lanman_auth, bLanmanAuth)_PUBLIC_ FN_GLOBAL_BOOL(lp_ntlm_auth, bNTLMAuth)_PUBLIC_ FN_GLOBAL_BOOL(lp_client_plaintext_auth, bClientPlaintextAuth)_PUBLIC_ FN_GLOBAL_BOOL(lp_client_lanman_auth, bClientLanManAuth)_PUBLIC_ FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, bClientNTLMv2Auth)_PUBLIC_ FN_GLOBAL_BOOL(lp_client_use_spnego_principal, client_use_spnego_principal)_PUBLIC_ FN_GLOBAL_BOOL(lp_host_msdfs, bHostMSDfs)_PUBLIC_ FN_GLOBAL_BOOL(lp_unix_extensions, bUnixExtensions)_PUBLIC_ FN_GLOBAL_BOOL(lp_use_spnego, bUseSpnego)_PUBLIC_ FN_GLOBAL_BOOL(lp_rpc_big_endian, bRpcBigEndian)_PUBLIC_ FN_GLOBAL_INTEGER(lp_max_wins_ttl, max_wins_ttl)_PUBLIC_ FN_GLOBAL_INTEGER(lp_min_wins_ttl, min_wins_ttl)_PUBLIC_ FN_GLOBAL_INTEGER(lp_maxmux, max_mux)_PUBLIC_ FN_GLOBAL_INTEGER(lp_max_xmit, max_xmit)_PUBLIC_ FN_GLOBAL_INTEGER(lp_passwordlevel, pwordlevel)_PUBLIC_ FN_GLOBAL_INTEGER(lp_srv_maxprotocol, srv_maxprotocol)_PUBLIC_ FN_GLOBAL_INTEGER(lp_srv_minprotocol, srv_minprotocol)_PUBLIC_ FN_GLOBAL_INTEGER(lp_cli_maxprotocol, cli_maxprotocol)_PUBLIC_ FN_GLOBAL_INTEGER(lp_cli_minprotocol, cli_minprotocol)_PUBLIC_ FN_GLOBAL_INTEGER(lp_security, security)_PUBLIC_ FN_GLOBAL_BOOL(lp_paranoid_server_security, paranoid_server_security)_PUBLIC_ FN_GLOBAL_INTEGER(lp_announce_as, announce_as)_PUBLIC_ FN_GLOBAL_LIST(lp_js_include, jsInclude)const char *lp_servicename(const struct loadparm_service *service){ return lp_string((const char *)service->szService);}_PUBLIC_ FN_LOCAL_STRING(lp_pathname, szPath)static FN_LOCAL_STRING(_lp_printername, szPrintername)_PUBLIC_ FN_LOCAL_LIST(lp_hostsallow, szHostsallow)_PUBLIC_ FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)_PUBLIC_ FN_LOCAL_STRING(lp_comment, comment)_PUBLIC_ FN_LOCAL_STRING(lp_fstype, fstype)static FN_LOCAL_STRING(lp_volume, volume)_PUBLIC_ FN_LOCAL_LIST(lp_ntvfs_handler, ntvfs_handler)_PUBLIC_ FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)_PUBLIC_ FN_LOCAL_BOOL(lp_browseable, bBrowseable)_PUBLIC_ FN_LOCAL_BOOL(lp_readonly, bRead_only)_PUBLIC_ FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)_PUBLIC_ FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)_PUBLIC_ FN_LOCAL_BOOL(lp_map_archive, bMap_archive)_PUBLIC_ FN_LOCAL_BOOL(lp_strict_locking, bStrictLocking)_PUBLIC_ FN_LOCAL_BOOL(lp_oplocks, bOplocks)_PUBLIC_ FN_LOCAL_BOOL(lp_strict_sync, bStrictSync)_PUBLIC_ FN_LOCAL_BOOL(lp_ci_filesystem, bCIFileSystem)_PUBLIC_ FN_LOCAL_BOOL(lp_map_system, bMap_system)_PUBLIC_ FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)_PUBLIC_ FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)_PUBLIC_ FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)_PUBLIC_ FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)_PUBLIC_ FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)_PUBLIC_ FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)_PUBLIC_ FN_GLOBAL_INTEGER(lp_server_signing, server_signing)_PUBLIC_ FN_GLOBAL_INTEGER(lp_client_signing, client_signing)_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_ntp_signd_socket_directory, szNTPSignDSocketDirectory)/* local prototypes */static int map_parameter(const char *pszParmName);static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx, const char *pszServiceName);static void copy_service(struct loadparm_service *pserviceDest, struct loadparm_service *pserviceSource, int *pcopymapDest);static bool service_ok(struct loadparm_service *service);static bool do_section(const char *pszSectionName, void *);static void init_copymap(struct loadparm_service *pservice);/* This is a helper function for parametrical options support. *//* It returns a pointer to parametrical option value if it exists or NULL otherwise *//* Actual parametrical functions are quite simple */const char *lp_get_parametric(struct loadparm_context *lp_ctx, struct loadparm_service *service, const char *type, const char *option){ char *vfskey; struct param_opt *data; if (lp_ctx == NULL) return NULL; data = (service == NULL ? lp_ctx->globals->param_opt : service->param_opt); asprintf(&vfskey, "%s:%s", type, option); strlower(vfskey); while (data) { if (strcmp(data->key, vfskey) == 0) { free(vfskey); return data->value; } data = data->next; } if (service != NULL) { /* Try to fetch the same option but from globals */ /* but only if we are not already working with globals */ for (data = lp_ctx->globals->param_opt; data; data = data->next) { if (strcmp(data->key, vfskey) == 0) { free(vfskey); return data->value; } } } free(vfskey); return NULL;}/** * convenience routine to return int parameters. */static int lp_int(const char *s){ if (!s) { DEBUG(0,("lp_int(%s): is called with NULL!\n",s)); return -1; } return strtol(s, NULL, 0);}/** * convenience routine to return unsigned long parameters. */static int lp_ulong(const char *s){ if (!s) { DEBUG(0,("lp_int(%s): is called with NULL!\n",s)); return -1; } return strtoul(s, NULL, 0);}/** * convenience routine to return unsigned long parameters. */static double lp_double(const char *s){ if (!s) { DEBUG(0,("lp_double(%s): is called with NULL!\n",s)); return -1; } return strtod(s, NULL);}/** * convenience routine to return boolean parameters. */static bool lp_bool(const char *s){ bool ret = false; if (!s) { DEBUG(0,("lp_bool(%s): is called with NULL!\n",s)); return false; } if (!set_boolean(s, &ret)) { DEBUG(0,("lp_bool(%s): value is not boolean!\n",s)); return false; } return ret;}/** * Return parametric option from a given service. Type is a part of option before ':' * Parametric option has following syntax: 'Type: option = value' * Returned value is allocated in 'lp_talloc' context */const char *lp_parm_string(struct loadparm_context *lp_ctx, struct loadparm_service *service, const char *type, const char *option)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -