-#include "rpc_server/common/common.h"
-#include "lib/socket/socket.h"
-#include "auth/gensec/gensec.h"
-
-#define standard_sub_basic talloc_strdup
-
-static bool do_parameter(const char *, const char *, void *);
-static bool defaults_saved = false;
-
-/**
- * This structure describes global (ie., server-wide) parameters.
- */
-struct loadparm_global
-{
- enum server_role server_role;
- enum sid_generator sid_generator;
-
- const char **smb_ports;
- char *ncalrpc_dir;
- char *dos_charset;
- char *unix_charset;
- char *display_charset;
- char *szLockDir;
- char *szModulesDir;
- char *szPidDir;
- char *szSetupDir;
- char *szServerString;
- char *szAutoServices;
- char *szPasswdChat;
- char *szShareBackend;
- char *szSAM_URL;
- char *szIDMAP_URL;
- char *szSECRETS_URL;
- char *szSPOOLSS_URL;
- char *szWINS_CONFIG_URL;
- char *szWINS_URL;
- char *szPrivateDir;
- const char **szPasswordServers;
- char *szSocketOptions;
- char *szRealm;
- char *szRealm_upper;
- char *szRealm_lower;
- const char **szWINSservers;
- const char **szInterfaces;
- char *szSocketAddress;
- char *szAnnounceVersion; /* This is initialised in init_globals */
- char *szWorkgroup;
- char *szNetbiosName;
- const char **szNetbiosAliases;
- char *szNetbiosScope;
- char *szDomainOtherSIDs;
- const char **szNameResolveOrder;
- const char **dcerpc_ep_servers;
- const char **server_services;
- char *ntptr_providor;
- char *szWinbindSeparator;
- char *szWinbinddPrivilegedSocketDirectory;
- char *szWinbinddSocketDirectory;
- char *szTemplateShell;
- char *szTemplateHomedir;
- int bWinbindSealedPipes;
- int bIdmapTrustedOnly;
- int tls_enabled;
- char *tls_keyfile;
- char *tls_certfile;
- char *tls_cafile;
- char *tls_crlfile;
- char *tls_dhpfile;
- char *logfile;
- char *panic_action;
- int max_mux;
- int debuglevel;
- int max_xmit;
- int pwordlevel;
- int srv_maxprotocol;
- int srv_minprotocol;
- int cli_maxprotocol;
- int cli_minprotocol;
- int security;
- int paranoid_server_security;
- int max_wins_ttl;
- int min_wins_ttl;
- int announce_as; /* This is initialised in init_globals */
- int nbt_port;
- int dgram_port;
- int cldap_port;
- int krb5_port;
- int kpasswd_port;
- int web_port;
- char *socket_options;
- int bWINSsupport;
- int bWINSdnsProxy;
- char *szWINSHook;
- int bLocalMaster;
- int bPreferredMaster;
- int bEncryptPasswords;
- int bNullPasswords;
- int bObeyPamRestrictions;
- int bLargeReadwrite;
- int bReadRaw;
- int bWriteRaw;
- int bTimeServer;
- int bBindInterfacesOnly;
- int bNTSmbSupport;
- int bNTStatusSupport;
- int bLanmanAuth;
- int bNTLMAuth;
- int bUseSpnego;
- int server_signing;
- int client_signing;
- int bClientPlaintextAuth;
- int bClientLanManAuth;
- int bClientNTLMv2Auth;
- int client_use_spnego_principal;
- int bHostMSDfs;
- int bUnicode;
- int bUnixExtensions;
- int bDisableNetbios;
- int bRpcBigEndian;
- char *szNTPSignDSocketDirectory;
- const char **szRNDCCommand;
- const char **szDNSUpdateCommand;
- const char **szSPNUpdateCommand;
- char *szNSUpdateCommand;
- struct parmlist_entry *param_opt;
-};
-
-
-/**
- * This structure describes a single service.
- */
-struct loadparm_service
-{
- char *szService;
- char *szPath;
- char *szCopy;
- char *szInclude;
- char *szPrintername;
- char **szHostsallow;
- char **szHostsdeny;
- char *comment;
- char *volume;
- char *fstype;
- char **ntvfs_handler;
- int iMaxPrintJobs;
- int iMaxConnections;
- int iCSCPolicy;
- int bAvailable;
- int bBrowseable;
- int bRead_only;
- int bPrint_ok;
- int bMap_system;
- int bMap_hidden;
- int bMap_archive;
- int bStrictLocking;
- int bOplocks;
- int iCreate_mask;
- int iCreate_force_mode;
- int iDir_mask;
- int iDir_force_mode;
- int *copymap;
- int bMSDfsRoot;
- int bStrictSync;
- int bCIFileSystem;
- struct parmlist_entry *param_opt;
-
- char dummy[3]; /* for alignment */
-};
-
-
-#define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
-
-
-/* prototypes for the special type handlers */
-static bool handle_include(struct loadparm_context *lp_ctx,
- const char *pszParmValue, char **ptr);
-static bool handle_realm(struct loadparm_context *lp_ctx,
- const char *pszParmValue, char **ptr);
-static bool handle_copy(struct loadparm_context *lp_ctx,
- const char *pszParmValue, char **ptr);
-static bool handle_debuglevel(struct loadparm_context *lp_ctx,
- const char *pszParmValue, char **ptr);
-static bool handle_logfile(struct loadparm_context *lp_ctx,
- const char *pszParmValue, char **ptr);
-
-static const struct enum_list enum_protocol[] = {
- {PROTOCOL_SMB2, "SMB2"},
- {PROTOCOL_NT1, "NT1"},
- {PROTOCOL_LANMAN2, "LANMAN2"},
- {PROTOCOL_LANMAN1, "LANMAN1"},
- {PROTOCOL_CORE, "CORE"},
- {PROTOCOL_COREPLUS, "COREPLUS"},
- {PROTOCOL_COREPLUS, "CORE+"},
- {-1, NULL}
-};
-
-static const struct enum_list enum_security[] = {
- {SEC_SHARE, "SHARE"},
- {SEC_USER, "USER"},
- {-1, NULL}
-};
-
-static const struct enum_list enum_announce_as[] = {
- {ANNOUNCE_AS_NT_SERVER, "NT"},
- {ANNOUNCE_AS_NT_SERVER, "NT Server"},
- {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
- {ANNOUNCE_AS_WIN95, "win95"},
- {ANNOUNCE_AS_WFW, "WfW"},
- {-1, NULL}
-};
-
-static const struct enum_list enum_bool_auto[] = {
- {false, "No"},
- {false, "False"},
- {false, "0"},
- {true, "Yes"},
- {true, "True"},
- {true, "1"},
- {Auto, "Auto"},
- {-1, NULL}
-};
-
-/* Client-side offline caching policy types */
-enum csc_policy {
- CSC_POLICY_MANUAL=0,
- CSC_POLICY_DOCUMENTS=1,
- CSC_POLICY_PROGRAMS=2,
- CSC_POLICY_DISABLE=3
-};
-
-static const struct enum_list enum_csc_policy[] = {
- {CSC_POLICY_MANUAL, "manual"},
- {CSC_POLICY_DOCUMENTS, "documents"},
- {CSC_POLICY_PROGRAMS, "programs"},
- {CSC_POLICY_DISABLE, "disable"},
- {-1, NULL}
-};
-
-/* SMB signing types. */
-static const struct enum_list enum_smb_signing_vals[] = {
- {SMB_SIGNING_OFF, "No"},
- {SMB_SIGNING_OFF, "False"},
- {SMB_SIGNING_OFF, "0"},
- {SMB_SIGNING_OFF, "Off"},
- {SMB_SIGNING_OFF, "disabled"},
- {SMB_SIGNING_SUPPORTED, "Yes"},
- {SMB_SIGNING_SUPPORTED, "True"},
- {SMB_SIGNING_SUPPORTED, "1"},
- {SMB_SIGNING_SUPPORTED, "On"},
- {SMB_SIGNING_SUPPORTED, "enabled"},
- {SMB_SIGNING_REQUIRED, "required"},
- {SMB_SIGNING_REQUIRED, "mandatory"},
- {SMB_SIGNING_REQUIRED, "force"},
- {SMB_SIGNING_REQUIRED, "forced"},
- {SMB_SIGNING_REQUIRED, "enforced"},
- {SMB_SIGNING_AUTO, "auto"},
- {-1, NULL}
-};
-
-static const struct enum_list enum_server_role[] = {
- {ROLE_STANDALONE, "standalone"},
- {ROLE_DOMAIN_MEMBER, "member server"},
- {ROLE_DOMAIN_MEMBER, "member"},
- {ROLE_DOMAIN_CONTROLLER, "domain controller"},
- {ROLE_DOMAIN_CONTROLLER, "dc"},
- {-1, NULL}
-};
-
-static const struct enum_list enum_sid_generator[] = {
- {SID_GENERATOR_INTERNAL, "internal"},
- {SID_GENERATOR_BACKEND, "backend"},
- {-1, NULL}
-};
-
-#define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
-#define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
-
-static struct parm_struct parm_table[] = {
- {"server role", P_ENUM, P_GLOBAL, GLOBAL_VAR(server_role), NULL, enum_server_role},
- {"sid generator", P_ENUM, P_GLOBAL, GLOBAL_VAR(sid_generator), NULL, enum_sid_generator},
-
- {"dos charset", P_STRING, P_GLOBAL, GLOBAL_VAR(dos_charset), NULL, NULL},
- {"unix charset", P_STRING, P_GLOBAL, GLOBAL_VAR(unix_charset), NULL, NULL},
- {"ncalrpc dir", P_STRING, P_GLOBAL, GLOBAL_VAR(ncalrpc_dir), NULL, NULL},
- {"display charset", P_STRING, P_GLOBAL, GLOBAL_VAR(display_charset), NULL, NULL},
- {"comment", P_STRING, P_LOCAL, LOCAL_VAR(comment), NULL, NULL},
- {"path", P_STRING, P_LOCAL, LOCAL_VAR(szPath), NULL, NULL},
- {"directory", P_STRING, P_LOCAL, LOCAL_VAR(szPath), NULL, NULL},
- {"workgroup", P_USTRING, P_GLOBAL, GLOBAL_VAR(szWorkgroup), NULL, NULL},
- {"realm", P_STRING, P_GLOBAL, GLOBAL_VAR(szRealm), handle_realm, NULL},
- {"netbios name", P_USTRING, P_GLOBAL, GLOBAL_VAR(szNetbiosName), NULL, NULL},
- {"netbios aliases", P_LIST, P_GLOBAL, GLOBAL_VAR(szNetbiosAliases), NULL, NULL},
- {"netbios scope", P_USTRING, P_GLOBAL, GLOBAL_VAR(szNetbiosScope), NULL, NULL},
- {"server string", P_STRING, P_GLOBAL, GLOBAL_VAR(szServerString), NULL, NULL},
- {"interfaces", P_LIST, P_GLOBAL, GLOBAL_VAR(szInterfaces), NULL, NULL},
- {"bind interfaces only", P_BOOL, P_GLOBAL, GLOBAL_VAR(bBindInterfacesOnly), NULL, NULL},
- {"ntvfs handler", P_LIST, P_LOCAL, LOCAL_VAR(ntvfs_handler), NULL, NULL},
- {"ntptr providor", P_STRING, P_GLOBAL, GLOBAL_VAR(ntptr_providor), NULL, NULL},
- {"dcerpc endpoint servers", P_LIST, P_GLOBAL, GLOBAL_VAR(dcerpc_ep_servers), NULL, NULL},
- {"server services", P_LIST, P_GLOBAL, GLOBAL_VAR(server_services), NULL, NULL},
-
- {"security", P_ENUM, P_GLOBAL, GLOBAL_VAR(security), NULL, enum_security},
- {"encrypt passwords", P_BOOL, P_GLOBAL, GLOBAL_VAR(bEncryptPasswords), NULL, NULL},
- {"null passwords", P_BOOL, P_GLOBAL, GLOBAL_VAR(bNullPasswords), NULL, NULL},
- {"obey pam restrictions", P_BOOL, P_GLOBAL, GLOBAL_VAR(bObeyPamRestrictions), NULL, NULL},
- {"password server", P_LIST, P_GLOBAL, GLOBAL_VAR(szPasswordServers), NULL, NULL},
- {"sam database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSAM_URL), NULL, NULL},
- {"idmap database", P_STRING, P_GLOBAL, GLOBAL_VAR(szIDMAP_URL), NULL, NULL},
- {"secrets database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSECRETS_URL), NULL, NULL},
- {"spoolss database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSPOOLSS_URL), NULL, NULL},
- {"wins config database", P_STRING, P_GLOBAL, GLOBAL_VAR(szWINS_CONFIG_URL), NULL, NULL},
- {"wins database", P_STRING, P_GLOBAL, GLOBAL_VAR(szWINS_URL), NULL, NULL},
- {"private dir", P_STRING, P_GLOBAL, GLOBAL_VAR(szPrivateDir), NULL, NULL},
- {"passwd chat", P_STRING, P_GLOBAL, GLOBAL_VAR(szPasswdChat), NULL, NULL},
- {"password level", P_INTEGER, P_GLOBAL, GLOBAL_VAR(pwordlevel), NULL, NULL},
- {"lanman auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bLanmanAuth), NULL, NULL},
- {"ntlm auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bNTLMAuth), NULL, NULL},
- {"client NTLMv2 auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientNTLMv2Auth), NULL, NULL},
- {"client lanman auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientLanManAuth), NULL, NULL},
- {"client plaintext auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientPlaintextAuth), NULL, NULL},
- {"client use spnego principal", P_BOOL, P_GLOBAL, GLOBAL_VAR(client_use_spnego_principal), NULL, NULL},
-
- {"read only", P_BOOL, P_LOCAL, LOCAL_VAR(bRead_only), NULL, NULL},
-
- {"create mask", P_OCTAL, P_LOCAL, LOCAL_VAR(iCreate_mask), NULL, NULL},
- {"force create mode", P_OCTAL, P_LOCAL, LOCAL_VAR(iCreate_force_mode), NULL, NULL},
- {"directory mask", P_OCTAL, P_LOCAL, LOCAL_VAR(iDir_mask), NULL, NULL},
- {"force directory mode", P_OCTAL, P_LOCAL, LOCAL_VAR(iDir_force_mode), NULL, NULL},
-
- {"hosts allow", P_LIST, P_LOCAL, LOCAL_VAR(szHostsallow), NULL, NULL},
- {"hosts deny", P_LIST, P_LOCAL, LOCAL_VAR(szHostsdeny), NULL, NULL},
-
- {"log level", P_INTEGER, P_GLOBAL, GLOBAL_VAR(debuglevel), handle_debuglevel, NULL},
- {"debuglevel", P_INTEGER, P_GLOBAL, GLOBAL_VAR(debuglevel), handle_debuglevel, NULL},
- {"log file", P_STRING, P_GLOBAL, GLOBAL_VAR(logfile), handle_logfile, NULL},
-
- {"smb ports", P_LIST, P_GLOBAL, GLOBAL_VAR(smb_ports), NULL, NULL},
- {"nbt port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(nbt_port), NULL, NULL},
- {"dgram port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(dgram_port), NULL, NULL},
- {"cldap port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(cldap_port), NULL, NULL},
- {"krb5 port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(krb5_port), NULL, NULL},
- {"kpasswd port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(kpasswd_port), NULL, NULL},
- {"web port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(web_port), NULL, NULL},
- {"tls enabled", P_BOOL, P_GLOBAL, GLOBAL_VAR(tls_enabled), NULL, NULL},
- {"tls keyfile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_keyfile), NULL, NULL},
- {"tls certfile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_certfile), NULL, NULL},
- {"tls cafile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_cafile), NULL, NULL},
- {"tls crlfile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_crlfile), NULL, NULL},
- {"tls dh params file", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_dhpfile), NULL, NULL},
- {"large readwrite", P_BOOL, P_GLOBAL, GLOBAL_VAR(bLargeReadwrite), NULL, NULL},
- {"server max protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(srv_maxprotocol), NULL, enum_protocol},
- {"server min protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(srv_minprotocol), NULL, enum_protocol},
- {"client max protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(cli_maxprotocol), NULL, enum_protocol},
- {"client min protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(cli_minprotocol), NULL, enum_protocol},
- {"unicode", P_BOOL, P_GLOBAL, GLOBAL_VAR(bUnicode), NULL, NULL},
- {"read raw", P_BOOL, P_GLOBAL, GLOBAL_VAR(bReadRaw), NULL, NULL},
- {"write raw", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWriteRaw), NULL, NULL},
- {"disable netbios", P_BOOL, P_GLOBAL, GLOBAL_VAR(bDisableNetbios), NULL, NULL},
-
- {"nt status support", P_BOOL, P_GLOBAL, GLOBAL_VAR(bNTStatusSupport), NULL, NULL},
-
- {"announce version", P_STRING, P_GLOBAL, GLOBAL_VAR(szAnnounceVersion), NULL, NULL},
- {"announce as", P_ENUM, P_GLOBAL, GLOBAL_VAR(announce_as), NULL, enum_announce_as},
- {"max mux", P_INTEGER, P_GLOBAL, GLOBAL_VAR(max_mux), NULL, NULL},
- {"max xmit", P_BYTES, P_GLOBAL, GLOBAL_VAR(max_xmit), NULL, NULL},
-
- {"name resolve order", P_LIST, P_GLOBAL, GLOBAL_VAR(szNameResolveOrder), NULL, NULL},
- {"max wins ttl", P_INTEGER, P_GLOBAL, GLOBAL_VAR(max_wins_ttl), NULL, NULL},
- {"min wins ttl", P_INTEGER, P_GLOBAL, GLOBAL_VAR(min_wins_ttl), NULL, NULL},
- {"time server", P_BOOL, P_GLOBAL, GLOBAL_VAR(bTimeServer), NULL, NULL},
- {"unix extensions", P_BOOL, P_GLOBAL, GLOBAL_VAR(bUnixExtensions), NULL, NULL},
- {"use spnego", P_BOOL, P_GLOBAL, GLOBAL_VAR(bUseSpnego), NULL, NULL},
- {"server signing", P_ENUM, P_GLOBAL, GLOBAL_VAR(server_signing), NULL, enum_smb_signing_vals},
- {"client signing", P_ENUM, P_GLOBAL, GLOBAL_VAR(client_signing), NULL, enum_smb_signing_vals},
- {"rpc big endian", P_BOOL, P_GLOBAL, GLOBAL_VAR(bRpcBigEndian), NULL, NULL},
-
- {"max connections", P_INTEGER, P_LOCAL, LOCAL_VAR(iMaxConnections), NULL, NULL},
- {"paranoid server security", P_BOOL, P_GLOBAL, GLOBAL_VAR(paranoid_server_security), NULL, NULL},
- {"socket options", P_STRING, P_GLOBAL, GLOBAL_VAR(socket_options), NULL, NULL},
-
- {"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},
- {"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 },
- {"winbindd privileged socket directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szWinbinddPrivilegedSocketDirectory), 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 },
- {"rndc command", P_LIST, P_GLOBAL, GLOBAL_VAR(szRNDCCommand), NULL, NULL },
- {"dns update command", P_LIST, P_GLOBAL, GLOBAL_VAR(szDNSUpdateCommand), NULL, NULL },
- {"spn update command", P_LIST, P_GLOBAL, GLOBAL_VAR(szSPNUpdateCommand), NULL, NULL },
- {"nsupdate command", P_STRING, P_GLOBAL, GLOBAL_VAR(szNSUpdateCommand), 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_INTEGER(lp_sid_generator, sid_generator)
-_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_BOOL(lp_tls_enabled, tls_enabled)
-_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_winbindd_privileged_socket_directory, szWinbinddPrivilegedSocketDirectory)
-_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_rndc_command, szRNDCCommand)
-_PUBLIC_ FN_GLOBAL_LIST(lp_dns_update_command, szDNSUpdateCommand)
-_PUBLIC_ FN_GLOBAL_LIST(lp_spn_update_command, szSPNUpdateCommand)
-_PUBLIC_ FN_GLOBAL_STRING(lp_nsupdate_command, szNSUpdateCommand)
-_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_upper)
-_PUBLIC_ FN_GLOBAL_STRING(lp_dnsdomain, szRealm_lower)
-_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)
-
-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 parmlist_entry *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)
-{
- const char *value = lp_get_parametric(lp_ctx, service, type, option);