s3-libsmb: Remove use of cli_errstr()
[kai/samba.git] / source4 / param / loadparm.c
index 531789e3e9ec6b3c8a47296c91ce9c3d144f1bc6..eafe8333eac844b0084eb44329410dcb95d4eb3a 100644 (file)
 #include "rpc_server/common/common.h"
 #include "lib/socket/socket.h"
 #include "auth/gensec/gensec.h"
+#include "s3_param.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;
+#define LOADPARM_EXTRA_GLOBALS \
+       struct parmlist_entry *param_opt;                               \
+       char *szRealm;                                                  \
+       char *tls_keyfile;                                              \
+       char *tls_certfile;                                             \
+       char *tls_cafile;                                               \
+       char *tls_crlfile;                                              \
+       char *tls_dhpfile;                                              \
+       char *loglevel;                                                 \
+       char *panic_action;                                             \
        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;
-       const 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;
 
+#define LOADPARM_EXTRA_LOCALS                          \
+       struct parmlist_entry *param_opt;               \
+       char *szService;                                \
+       char *szCopy;                                   \
+       char *szInclude;                                \
+       char *szPrintername;                            \
+       int bAvailable;                                 \
+       int iMaxPrintJobs;                              \
+       char *volume;                                   \
+       int *copymap;                                   \
        char dummy[3];          /* for alignment */
-};
 
+#include "param_global.h"
+#include "param_local.h"
 
 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
 
 
 /* prototypes for the special type handlers */
-static bool handle_include(struct loadparm_context *lp_ctx,
+static bool handle_include(struct loadparm_context *lp_ctx, int unused,
                           const char *pszParmValue, char **ptr);
-static bool handle_realm(struct loadparm_context *lp_ctx,
+static bool handle_realm(struct loadparm_context *lp_ctx, int unused,
                         const char *pszParmValue, char **ptr);
-static bool handle_copy(struct loadparm_context *lp_ctx,
+static bool handle_copy(struct loadparm_context *lp_ctx, int unused,
                        const char *pszParmValue, char **ptr);
-static bool handle_debuglevel(struct loadparm_context *lp_ctx,
+static bool handle_debuglevel(struct loadparm_context *lp_ctx, int unused,
                              const char *pszParmValue, char **ptr);
-static bool handle_logfile(struct loadparm_context *lp_ctx,
+static bool handle_logfile(struct loadparm_context *lp_ctx, int unused,
                           const char *pszParmValue, char **ptr);
 
 static const struct enum_list enum_protocol[] = {
@@ -264,15 +131,7 @@ static const struct enum_list enum_protocol[] = {
 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"},
+       {SEC_ADS, "ADS"},
        {-1, NULL}
 };
 
@@ -333,184 +192,1092 @@ static const struct enum_list enum_server_role[] = {
        {-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_CMDLIST, P_GLOBAL, GLOBAL_VAR(szRNDCCommand), NULL, NULL },
-       {"dns update command", P_CMDLIST, P_GLOBAL, GLOBAL_VAR(szDNSUpdateCommand), NULL, NULL },
-       {"spn update command", P_CMDLIST, P_GLOBAL, GLOBAL_VAR(szSPNUpdateCommand), NULL, NULL },
-       {"nsupdate command", P_CMDLIST, P_GLOBAL, GLOBAL_VAR(szNSUpdateCommand), NULL, NULL },
-
-       {NULL, P_BOOL, P_NONE, 0, NULL, NULL}
+       {
+               .label          = "server role",
+               .type           = P_ENUM,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(server_role),
+               .special        = NULL,
+               .enum_list      = enum_server_role
+       },
+       {
+               .label          = "dos charset",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(dos_charset),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "unix charset",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(unix_charset),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "ncalrpc dir",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(ncalrpc_dir),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "comment",
+               .type           = P_STRING,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(comment),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "path",
+               .type           = P_STRING,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(szPath),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "directory",
+               .type           = P_STRING,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(szPath),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "workgroup",
+               .type           = P_USTRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szWorkgroup),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "realm",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szRealm),
+               .special        = handle_realm,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "netbios name",
+               .type           = P_USTRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szNetbiosName),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "netbios aliases",
+               .type           = P_LIST,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szNetbiosAliases),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "netbios scope",
+               .type           = P_USTRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szNetbiosScope),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "server string",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szServerString),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "interfaces",
+               .type           = P_LIST,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szInterfaces),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "bind interfaces only",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bBindInterfacesOnly),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "ntvfs handler",
+               .type           = P_LIST,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(ntvfs_handler),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "ntptr providor",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(ntptr_providor),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "dcerpc endpoint servers",
+               .type           = P_LIST,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(dcerpc_ep_servers),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "server services",
+               .type           = P_LIST,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(server_services),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "security",
+               .type           = P_ENUM,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(security),
+               .special        = NULL,
+               .enum_list      = enum_security
+       },
+       {
+               .label          = "encrypt passwords",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bEncryptPasswords),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "null passwords",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bNullPasswords),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "obey pam restrictions",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bObeyPamRestrictions),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "password server",
+               .type           = P_LIST,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szPasswordServers),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "spoolss database",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szSPOOLSS_URL),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "wins config database",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szWINS_CONFIG_URL),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "wins database",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szWINS_URL),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "private dir",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szPrivateDir),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "passwd chat",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szPasswdChat),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "password level",
+               .type           = P_INTEGER,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(pwordlevel),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "lanman auth",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bLanmanAuth),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "ntlm auth",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bNTLMAuth),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "client NTLMv2 auth",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bClientNTLMv2Auth),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "client lanman auth",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bClientLanManAuth),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "client plaintext auth",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bClientPlaintextAuth),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "client use spnego principal",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(client_use_spnego_principal),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "read only",
+               .type           = P_BOOL,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(bRead_only),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "create mask",
+               .type           = P_OCTAL,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(iCreate_mask),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "force create mode",
+               .type           = P_OCTAL,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(iCreate_force_mode),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "directory mask",
+               .type           = P_OCTAL,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(iDir_mask),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "force directory mode",
+               .type           = P_OCTAL,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(iDir_force_mode),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "hosts allow",
+               .type           = P_LIST,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(szHostsallow),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "hosts deny",
+               .type           = P_LIST,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(szHostsdeny),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "log level",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(loglevel),
+               .special        = handle_debuglevel,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "debuglevel",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(loglevel),
+               .special        = handle_debuglevel,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "log file",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(logfile),
+               .special        = handle_logfile,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "smb ports",
+               .type           = P_LIST,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(smb_ports),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "nbt port",
+               .type           = P_INTEGER,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(nbt_port),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "dgram port",
+               .type           = P_INTEGER,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(dgram_port),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "cldap port",
+               .type           = P_INTEGER,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(cldap_port),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "krb5 port",
+               .type           = P_INTEGER,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(krb5_port),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "kpasswd port",
+               .type           = P_INTEGER,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(kpasswd_port),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "web port",
+               .type           = P_INTEGER,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(web_port),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "tls enabled",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(tls_enabled),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "tls keyfile",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(tls_keyfile),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "tls certfile",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(tls_certfile),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "tls cafile",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(tls_cafile),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "tls crlfile",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(tls_crlfile),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "tls dh params file",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(tls_dhpfile),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "large readwrite",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bLargeReadwrite),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "server max protocol",
+               .type           = P_ENUM,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(srv_maxprotocol),
+               .special        = NULL,
+               .enum_list      = enum_protocol
+       },
+       {
+               .label          = "server min protocol",
+               .type           = P_ENUM,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(srv_minprotocol),
+               .special        = NULL,
+               .enum_list      = enum_protocol
+       },
+       {
+               .label          = "client max protocol",
+               .type           = P_ENUM,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(cli_maxprotocol),
+               .special        = NULL,
+               .enum_list      = enum_protocol
+       },
+       {
+               .label          = "client min protocol",
+               .type           = P_ENUM,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(cli_minprotocol),
+               .special        = NULL,
+               .enum_list      = enum_protocol
+       },
+       {
+               .label          = "unicode",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bUnicode),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "read raw",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bReadRaw),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "write raw",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bWriteRaw),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "disable netbios",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bDisableNetbios),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "nt status support",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bNTStatusSupport),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "max mux",
+               .type           = P_INTEGER,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(max_mux),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "max xmit",
+               .type           = P_BYTES,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(max_xmit),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "name resolve order",
+               .type           = P_LIST,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szNameResolveOrder),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "max wins ttl",
+               .type           = P_INTEGER,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(max_wins_ttl),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "min wins ttl",
+               .type           = P_INTEGER,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(min_wins_ttl),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "time server",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bTimeServer),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "unix extensions",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bUnixExtensions),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "use spnego",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bUseSpnego),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "server signing",
+               .type           = P_ENUM,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(server_signing),
+               .special        = NULL,
+               .enum_list      = enum_smb_signing_vals
+       },
+       {
+               .label          = "client signing",
+               .type           = P_ENUM,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(client_signing),
+               .special        = NULL,
+               .enum_list      = enum_smb_signing_vals
+       },
+       {
+               .label          = "rpc big endian",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bRpcBigEndian),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "max connections",
+               .type           = P_INTEGER,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(iMaxConnections),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "paranoid server security",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(paranoid_server_security),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "socket options",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(socket_options),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "strict sync",
+               .type           = P_BOOL,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(bStrictSync),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "case insensitive filesystem",
+               .type           = P_BOOL,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(bCIFileSystem),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "max print jobs",
+               .type           = P_INTEGER,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(iMaxPrintJobs),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "printable",
+               .type           = P_BOOL,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(bPrint_ok),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "print ok",
+               .type           = P_BOOL,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(bPrint_ok),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "printer name",
+               .type           = P_STRING,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(szPrintername),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "printer",
+               .type           = P_STRING,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(szPrintername),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "map system",
+               .type           = P_BOOL,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(bMap_system),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "map hidden",
+               .type           = P_BOOL,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(bMap_hidden),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "map archive",
+               .type           = P_BOOL,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(bMap_archive),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "preferred master",
+               .type           = P_ENUM,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bPreferredMaster),
+               .special        = NULL,
+               .enum_list      = enum_bool_auto
+       },
+       {
+               .label          = "prefered master",
+               .type           = P_ENUM,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bPreferredMaster),
+               .special        = NULL,
+               .enum_list      = enum_bool_auto
+       },
+       {
+               .label          = "local master",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bLocalMaster),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "browseable",
+               .type           = P_BOOL,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(bBrowseable),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "browsable",
+               .type           = P_BOOL,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(bBrowseable),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "wins server",
+               .type           = P_LIST,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szWINSservers),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "wins support",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bWINSsupport),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "dns proxy",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bWINSdnsProxy),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "wins hook",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szWINSHook),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "csc policy",
+               .type           = P_ENUM,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(iCSCPolicy),
+               .special        = NULL,
+               .enum_list      = enum_csc_policy
+       },
+
+       {
+               .label          = "strict locking",
+               .type           = P_BOOL,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(bStrictLocking),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "oplocks",
+               .type           = P_BOOL,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(bOplocks),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "share backend",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szShareBackend),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "preload",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szAutoServices),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "auto services",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szAutoServices),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "lock dir",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szLockDir),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "lock directory",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szLockDir),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "pid directory",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szPidDir),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "socket address",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szSocketAddress),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "copy",
+               .type           = P_STRING,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(szCopy),
+               .special        = handle_copy,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "include",
+               .type           = P_STRING,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(szInclude),
+               .special        = handle_include,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "available",
+               .type           = P_BOOL,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(bAvailable),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "volume",
+               .type           = P_STRING,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(volume),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "fstype",
+               .type           = P_STRING,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(fstype),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "panic action",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(panic_action),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "msdfs root",
+               .type           = P_BOOL,
+               .p_class        = P_LOCAL,
+               .offset         = LOCAL_VAR(bMSDfsRoot),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "host msdfs",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bHostMSDfs),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "winbind separator",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szWinbindSeparator),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "winbindd socket directory",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szWinbinddSocketDirectory),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "winbindd privileged socket directory",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szWinbinddPrivilegedSocketDirectory),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "winbind sealed pipes",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bWinbindSealedPipes),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "template shell",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szTemplateShell),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "template homedir",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szTemplateHomedir),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "idmap trusted only",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bIdmapTrustedOnly),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {
+               .label          = "ntp signd socket directory",
+               .type           = P_STRING,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szNTPSignDSocketDirectory),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "rndc command",
+               .type           = P_CMDLIST,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szRNDCCommand),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "dns update command",
+               .type           = P_CMDLIST,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szDNSUpdateCommand),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "spn update command",
+               .type           = P_CMDLIST,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szSPNUpdateCommand),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+       {
+               .label          = "nsupdate command",
+               .type           = P_CMDLIST,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(szNSUpdateCommand),
+               .special        = NULL,
+               .enum_list      = NULL
+       },
+
+       {NULL,  P_BOOL,  P_NONE,  0,  NULL,  NULL,  0}
 };
 
 
@@ -520,7 +1287,7 @@ struct loadparm_context {
        struct loadparm_global *globals;
        struct loadparm_service **services;
        struct loadparm_service *sDefault;
-       struct smb_iconv_convenience *iconv_convenience;
+       struct smb_iconv_handle *iconv_handle;
        int iNumServices;
        struct loadparm_service *currentService;
        bool bInGlobalSection;
@@ -533,6 +1300,9 @@ struct loadparm_context {
        unsigned int flags[NUMPARAMETERS];
        bool loaded;
        bool refuse_free;
+       bool global; /* Is this the global context, which may set
+                     * global variables such as debug level etc? */
+       const struct loadparm_s3_context *s3_fns;
 };
 
 
@@ -614,35 +1384,80 @@ static struct loadparm_context *global_loadparm_context;
 #define lpcfg_default_service global_loadparm_context->sDefault
 #define lpcfg_global_service(i) global_loadparm_context->services[i]
 
-#define FN_GLOBAL_STRING(fn_name,var_name) \
- _PUBLIC_ const char *lpcfg_ ## 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_STRING(fn_name,var_name)                             \
+ _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
+       if (lp_ctx == NULL) return NULL;                                \
+       if (lp_ctx->s3_fns) {                                           \
+               SMB_ASSERT(lp_ctx->s3_fns->fn_name);                    \
+               return lp_ctx->s3_fns->fn_name();                       \
+       }                                                               \
+       return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \
+}
 
 #define FN_GLOBAL_CONST_STRING(fn_name,var_name) \
- _PUBLIC_ const char *lpcfg_ ## 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) \
- _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return NULL; return lp_ctx->globals->var_name;}
+ _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\
+        if (lp_ctx == NULL) return NULL;                               \
+        if (lp_ctx->s3_fns) {                                          \
+                SMB_ASSERT(lp_ctx->s3_fns->fn_name);                   \
+                return lp_ctx->s3_fns->fn_name();                      \
+        }                                                              \
+        return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \
+ }
+
+#define FN_GLOBAL_LIST(fn_name,var_name)                               \
+ _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
+        if (lp_ctx == NULL) return NULL;                               \
+        if (lp_ctx->s3_fns) {                                          \
+                SMB_ASSERT(lp_ctx->s3_fns->fn_name);                   \
+                return lp_ctx->s3_fns->fn_name();                      \
+        }                                                              \
+        return lp_ctx->globals->var_name;                              \
+ }
 
 #define FN_GLOBAL_BOOL(fn_name,var_name) \
- _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return false; return lp_ctx->globals->var_name;}
+ _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\
+        if (lp_ctx == NULL) return false;                              \
+        if (lp_ctx->s3_fns) {                                          \
+                SMB_ASSERT(lp_ctx->s3_fns->fn_name);                   \
+                return lp_ctx->s3_fns->fn_name();                      \
+        }                                                              \
+        return lp_ctx->globals->var_name;                              \
+}
 
 #define FN_GLOBAL_INTEGER(fn_name,var_name) \
- _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {return lp_ctx->globals->var_name;}
+ _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
+        if (lp_ctx->s3_fns) {                                          \
+                SMB_ASSERT(lp_ctx->s3_fns->fn_name);                   \
+                return lp_ctx->s3_fns->fn_name();                      \
+        }                                                              \
+        return lp_ctx->globals->var_name;                              \
+ }
 
 #define FN_LOCAL_STRING(fn_name,val) \
- _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return(lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val)));}
+ _PUBLIC_ const char *lpcfg_ ## 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) \
- _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return(const char **)(service != NULL && service->val != NULL? service->val : sDefault->val);}
+ _PUBLIC_ const char **lpcfg_ ## 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) \
- _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return((service != NULL)? service->val : sDefault->val);}
+ _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_service *service, \
+                                struct loadparm_service *sDefault) {   \
+        return((service != NULL)? service->val : sDefault->val); \
+ }
 
 #define FN_LOCAL_INTEGER(fn_name,val) \
- _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return((service != NULL)? service->val : sDefault->val);}
+ _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_service *service, \
+                               struct loadparm_service *sDefault) {    \
+        return((service != NULL)? service->val : sDefault->val); \
+ }
 
 FN_GLOBAL_INTEGER(server_role, server_role)
-FN_GLOBAL_INTEGER(sid_generator, sid_generator)
 FN_GLOBAL_LIST(smb_ports, smb_ports)
 FN_GLOBAL_INTEGER(nbt_port, nbt_port)
 FN_GLOBAL_INTEGER(dgram_port, dgram_port)
@@ -651,10 +1466,8 @@ FN_GLOBAL_INTEGER(krb5_port, krb5_port)
 FN_GLOBAL_INTEGER(kpasswd_port, kpasswd_port)
 FN_GLOBAL_INTEGER(web_port, web_port)
 FN_GLOBAL_BOOL(tls_enabled, tls_enabled)
+FN_GLOBAL_STRING(logfile, logfile)
 FN_GLOBAL_STRING(share_backend, szShareBackend)
-FN_GLOBAL_STRING(sam_url, szSAM_URL)
-FN_GLOBAL_STRING(idmap_url, szIDMAP_URL)
-FN_GLOBAL_STRING(secrets_url, szSECRETS_URL)
 FN_GLOBAL_STRING(spoolss_url, szSPOOLSS_URL)
 FN_GLOBAL_STRING(wins_config_url, szWINS_CONFIG_URL)
 FN_GLOBAL_STRING(wins_url, szWINS_URL)
@@ -668,12 +1481,9 @@ FN_GLOBAL_BOOL(idmap_trusted_only, bIdmapTrustedOnly)
 FN_GLOBAL_STRING(private_dir, szPrivateDir)
 FN_GLOBAL_STRING(serverstring, szServerString)
 FN_GLOBAL_STRING(lockdir, szLockDir)
-FN_GLOBAL_STRING(modulesdir, szModulesDir)
-FN_GLOBAL_STRING(setupdir, szSetupDir)
 FN_GLOBAL_STRING(ncalrpc_dir, ncalrpc_dir)
 FN_GLOBAL_STRING(dos_charset, dos_charset)
 FN_GLOBAL_STRING(unix_charset, unix_charset)
-FN_GLOBAL_STRING(display_charset, display_charset)
 FN_GLOBAL_STRING(piddir, szPidDir)
 FN_GLOBAL_LIST(rndc_command, szRNDCCommand)
 FN_GLOBAL_LIST(dns_update_command, szDNSUpdateCommand)
@@ -697,7 +1507,7 @@ FN_GLOBAL_LIST(interfaces, szInterfaces)
 FN_GLOBAL_STRING(socket_address, szSocketAddress)
 FN_GLOBAL_LIST(netbios_aliases, szNetbiosAliases)
 FN_GLOBAL_BOOL(disable_netbios, bDisableNetbios)
-FN_GLOBAL_BOOL(wins_support, bWINSsupport)
+FN_GLOBAL_BOOL(we_are_a_wins_server, bWINSsupport)
 FN_GLOBAL_BOOL(wins_dns_proxy, bWINSdnsProxy)
 FN_GLOBAL_STRING(wins_hook, szWINSHook)
 FN_GLOBAL_BOOL(local_master, bLocalMaster)
@@ -732,7 +1542,6 @@ FN_GLOBAL_INTEGER(cli_maxprotocol, cli_maxprotocol)
 FN_GLOBAL_INTEGER(cli_minprotocol, cli_minprotocol)
 FN_GLOBAL_INTEGER(security, security)
 FN_GLOBAL_BOOL(paranoid_server_security, paranoid_server_security)
-FN_GLOBAL_INTEGER(announce_as, announce_as)
 
 FN_LOCAL_STRING(pathname, szPath)
 FN_LOCAL_LIST(hostsallow, szHostsallow)
@@ -780,21 +1589,28 @@ const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
                              struct loadparm_service *service,
                              const char *type, const char *option)
 {
+       char *vfskey_tmp = NULL;
        char *vfskey = NULL;
        struct parmlist_entry *data;
 
        if (lp_ctx == NULL)
                return NULL;
 
+       if (lp_ctx->s3_fns) {
+               SMB_ASSERT(service == NULL);
+               return lp_ctx->s3_fns->get_parametric(type, option);
+       }
+
        data = (service == NULL ? lp_ctx->globals->param_opt : service->param_opt);
 
-       asprintf(&vfskey, "%s:%s", type, option);
-       if (vfskey == NULL) return NULL;
-       strlower(vfskey);
+       vfskey_tmp = talloc_asprintf(NULL, "%s:%s", type, option);
+       if (vfskey_tmp == NULL) return NULL;
+       vfskey = strlower_talloc(NULL, vfskey_tmp);
+       talloc_free(vfskey_tmp);
 
        while (data) {
                if (strcmp(data->key, vfskey) == 0) {
-                       free(vfskey);
+                       talloc_free(vfskey);
                        return data->value;
                }
                data = data->next;
@@ -806,13 +1622,13 @@ const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
                for (data = lp_ctx->globals->param_opt; data;
                     data = data->next) {
                        if (strcmp(data->key, vfskey) == 0) {
-                               free(vfskey);
+                               talloc_free(vfskey);
                                return data->value;
                        }
                }
        }
 
-       free(vfskey);
+       talloc_free(vfskey);
 
        return NULL;
 }
@@ -950,7 +1766,7 @@ int lpcfg_parm_bytes(struct loadparm_context *lp_ctx,
 
        const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
 
-       if (value && conv_str_size(value, &bval)) {
+       if (value && conv_str_size_error(value, &bval)) {
                if (bval <= INT_MAX) {
                        return (int)bval;
                }
@@ -1032,7 +1848,27 @@ static bool string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
 
        *dest = talloc_strdup(mem_ctx, src);
        if ((*dest) == NULL) {
-               DEBUG(0,("Out of memory in string_init\n"));
+               DEBUG(0,("Out of memory in string_set\n"));
+               return false;
+       }
+
+       return true;
+}
+
+/**
+ * Set a string value, deallocating any existing space, and allocing the space
+ * for the string
+ */
+static bool string_set_upper(TALLOC_CTX *mem_ctx, char **dest, const char *src)
+{
+       talloc_free(*dest);
+
+       if (src == NULL)
+               src = "";
+
+       *dest = strupper_talloc(mem_ctx, src);
+       if ((*dest) == NULL) {
+               DEBUG(0,("Out of memory in string_set_upper\n"));
                return false;
        }
 
@@ -1152,9 +1988,9 @@ bool lpcfg_add_home(struct loadparm_context *lp_ctx,
  * Add a new printer service, with defaults coming from service iFrom.
  */
 
-bool lp_add_printer(struct loadparm_context *lp_ctx,
-                   const char *pszPrintername,
-                   struct loadparm_service *default_service)
+bool lpcfg_add_printer(struct loadparm_context *lp_ctx,
+                      const char *pszPrintername,
+                      struct loadparm_service *default_service)
 {
        const char *comment = "From Printcap";
        struct loadparm_service *service;
@@ -1225,9 +2061,9 @@ void *lpcfg_parm_ptr(struct loadparm_context *lp_ctx,
                  struct loadparm_service *service, struct parm_struct *parm)
 {
        if (service == NULL) {
-               if (parm->pclass == P_LOCAL)
+               if (parm->p_class == P_LOCAL)
                        return ((char *)lp_ctx->sDefault)+parm->offset;
-               else if (parm->pclass == P_GLOBAL)
+               else if (parm->p_class == P_GLOBAL)
                        return ((char *)lp_ctx->globals)+parm->offset;
                else return NULL;
        } else {
@@ -1268,7 +2104,7 @@ static void copy_service(struct loadparm_service *pserviceDest,
        bool not_added;
 
        for (i = 0; parm_table[i].label; i++)
-               if (parm_table[i].offset != -1 && parm_table[i].pclass == P_LOCAL &&
+               if (parm_table[i].offset != -1 && parm_table[i].p_class == P_LOCAL &&
                    (bcopyall || pcopymapDest[i])) {
                        void *src_ptr =
                                ((char *)pserviceSource) + parm_table[i].offset;
@@ -1293,10 +2129,9 @@ static void copy_service(struct loadparm_service *pserviceDest,
                                        break;
 
                                case P_USTRING:
-                                       string_set(pserviceDest,
-                                                  (char **)dest_ptr,
-                                                  *(char **)src_ptr);
-                                       strupper(*(char **)dest_ptr);
+                                       string_set_upper(pserviceDest,
+                                                        (char **)dest_ptr,
+                                                        *(char **)src_ptr);
                                        break;
                                case P_LIST:
                                        *(const char ***)dest_ptr = (const char **)str_list_copy(pserviceDest, 
@@ -1423,7 +2258,7 @@ static void add_to_file_list(struct loadparm_context *lp_ctx,
 /*******************************************************************
  Check if a config file has changed date.
 ********************************************************************/
-bool lp_file_list_changed(struct loadparm_context *lp_ctx)
+bool lpcfg_file_list_changed(struct loadparm_context *lp_ctx)
 {
        struct file_lists *f;
        DEBUG(6, ("lp_file_list_changed()\n"));
@@ -1455,7 +2290,7 @@ bool lp_file_list_changed(struct loadparm_context *lp_ctx)
  Handle the "realm" parameter
 ***************************************************************************/
 
-static bool handle_realm(struct loadparm_context *lp_ctx,
+static bool handle_realm(struct loadparm_context *lp_ctx, int unused,
                         const char *pszParmValue, char **ptr)
 {
        string_set(lp_ctx, ptr, pszParmValue);
@@ -1473,7 +2308,7 @@ static bool handle_realm(struct loadparm_context *lp_ctx,
  Handle the include operation.
 ***************************************************************************/
 
-static bool handle_include(struct loadparm_context *lp_ctx,
+static bool handle_include(struct loadparm_context *lp_ctx, int unused,
                           const char *pszParmValue, char **ptr)
 {
        char *fname = standard_sub_basic(lp_ctx, pszParmValue);
@@ -1494,7 +2329,7 @@ static bool handle_include(struct loadparm_context *lp_ctx,
  Handle the interpretation of the copy parameter.
 ***************************************************************************/
 
-static bool handle_copy(struct loadparm_context *lp_ctx,
+static bool handle_copy(struct loadparm_context *lp_ctx, int unused,
                        const char *pszParmValue, char **ptr)
 {
        bool bRetval;
@@ -1524,26 +2359,24 @@ static bool handle_copy(struct loadparm_context *lp_ctx,
        return bRetval;
 }
 
-static bool handle_debuglevel(struct loadparm_context *lp_ctx,
+static bool handle_debuglevel(struct loadparm_context *lp_ctx, int unused,
                        const char *pszParmValue, char **ptr)
 {
-       DEBUGLEVEL = atoi(pszParmValue);
-
-       /* also set in the loadparm table, so querying debug level
-          works */
-       *(int *)ptr = DEBUGLEVEL;
 
+       string_set(lp_ctx, ptr, pszParmValue);
+       if (lp_ctx->global) {
+               return debug_parse_levels(pszParmValue);
+       }
        return true;
 }
 
-static bool handle_logfile(struct loadparm_context *lp_ctx,
+static bool handle_logfile(struct loadparm_context *lp_ctx, int unused,
                        const char *pszParmValue, char **ptr)
 {
-       if (logfile != NULL) {
-               free(discard_const_p(char, logfile));
+       debug_set_logfile(pszParmValue);
+       if (lp_ctx->global) {
+               string_set(lp_ctx, ptr, pszParmValue);
        }
-       logfile = strdup(pszParmValue);
-       string_set(lp_ctx, ptr, pszParmValue);
        return true;
 }
 
@@ -1582,11 +2415,9 @@ static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
                pszParmName++;
        }
 
-       name = strdup(pszParmName);
+       name = strlower_talloc(lp_ctx, pszParmName);
        if (!name) return false;
 
-       strlower(name);
-
        if (service == NULL) {
                data = lp_ctx->globals->param_opt;
                mem_ctx = lp_ctx->globals;
@@ -1602,13 +2433,14 @@ static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
                if (strcmp(paramo->key, name) == 0) {
                        if ((paramo->priority & FLAG_CMDLINE) &&
                            !(flags & FLAG_CMDLINE)) {
+                               talloc_free(name);
                                return true;
                        }
 
                        talloc_free(paramo->value);
                        paramo->value = talloc_strdup(paramo, pszParmValue);
                        paramo->priority = flags;
-                       free(name);
+                       talloc_free(name);
                        return true;
                }
        }
@@ -1625,7 +2457,7 @@ static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
                DLIST_ADD(service->param_opt, paramo);
        }
 
-       free(name);
+       talloc_free(name);
 
        return true;
 }
@@ -1638,7 +2470,7 @@ static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
        /* if it is a special case then go ahead */
        if (parm_table[parmnum].special) {
                bool ret;
-               ret = parm_table[parmnum].special(lp_ctx, pszParmValue,
+               ret = parm_table[parmnum].special(lp_ctx, -1, pszParmValue,
                                                  (char **)parm_ptr);
                if (!ret) {
                        return false;
@@ -1659,6 +2491,16 @@ static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
                        }
                        break;
 
+               case P_BOOLREV: {
+                       bool b;
+                       if (!set_boolean(pszParmValue, &b)) {
+                               DEBUG(0,("lp_do_parameter(%s): value is not boolean!\n", pszParmValue));
+                               return false;
+                       }
+                       *(int *)parm_ptr = !b;
+                       }
+                       break;
+
                case P_INTEGER:
                        *(int *)parm_ptr = atoi(pszParmValue);
                        break;
@@ -1670,7 +2512,7 @@ static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
                case P_BYTES:
                {
                        uint64_t val;
-                       if (conv_str_size(pszParmValue, &val)) {
+                       if (conv_str_size_error(pszParmValue, &val)) {
                                if (val <= INT_MAX) {
                                        *(int *)parm_ptr = (int)val;
                                        break;
@@ -1691,17 +2533,23 @@ static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
                        char **new_list = str_list_make(mem_ctx,
                                                        pszParmValue, NULL);
                        for (i=0; new_list[i]; i++) {
-                               if (new_list[i][0] == '+' && new_list[i][1]) {
+                               if (new_list[i][0] == '+' && new_list[i][1] &&
+                                   (!str_list_check(*(const char ***)parm_ptr,
+                                                    &new_list[i][1]))) {
                                        *(const char ***)parm_ptr = str_list_add(*(const char ***)parm_ptr,
                                                                                 &new_list[i][1]);
                                } else if (new_list[i][0] == '-' && new_list[i][1]) {
+#if 0 /* This is commented out because we sometimes parse the list
+       * twice, and so we can't assert on this */
                                        if (!str_list_check(*(const char ***)parm_ptr,
                                                            &new_list[i][1])) {
-                                               DEBUG(0, ("Unsupported value for: %s = %s, %s is not in the original list\n",
-                                                         pszParmName, pszParmValue, new_list[i]));
+                                               DEBUG(0, ("Unsupported value for: %s = %s, %s is not in the original list [%s]\n",
+                                                         pszParmName, pszParmValue, new_list[i],
+                                                         str_list_join_shell(mem_ctx, *(const char ***)parm_ptr, ' ')));
                                                return false;
 
                                        }
+#endif
                                        str_list_remove(*(const char ***)parm_ptr,
                                                        &new_list[i][1]);
                                } else {
@@ -1721,8 +2569,7 @@ static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
                        break;
 
                case P_USTRING:
-                       string_set(mem_ctx, (char **)parm_ptr, pszParmValue);
-                       strupper(*(char **)parm_ptr);
+                       string_set_upper(mem_ctx, (char **)parm_ptr, pszParmValue);
                        break;
 
                case P_ENUM:
@@ -1807,7 +2654,7 @@ bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
                return true;
        }
 
-       if (parm_table[parmnum].pclass == P_GLOBAL) {
+       if (parm_table[parmnum].p_class == P_GLOBAL) {
                DEBUG(0,
                      ("Global parameter %s found in service section!\n",
                       pszParmName));
@@ -1822,7 +2669,7 @@ bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
         * entries with the same data pointer */
        for (i = 0; parm_table[i].label; i++)
                if (parm_table[i].offset == parm_table[parmnum].offset &&
-                   parm_table[i].pclass == parm_table[parmnum].pclass)
+                   parm_table[i].p_class == parm_table[parmnum].p_class)
                        service->copymap[i] = false;
 
        return set_variable(service, parmnum, parm_ptr, pszParmName,
@@ -1964,6 +2811,10 @@ static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
                        fprintf(f, "%s", BOOLSTR((bool)*(int *)ptr));
                        break;
 
+               case P_BOOLREV:
+                       fprintf(f, "%s", BOOLSTR(!(bool)*(int *)ptr));
+                       break;
+
                case P_INTEGER:
                case P_BYTES:
                        fprintf(f, "%d", *(int *)ptr);
@@ -2007,6 +2858,7 @@ static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
 {
        switch (type) {
                case P_BOOL:
+               case P_BOOLREV:
                        return (*((int *)ptr1) == *((int *)ptr2));
 
                case P_INTEGER:
@@ -2055,7 +2907,7 @@ static bool do_section(const char *pszSectionName, void *userdata)
 
        /* check for multiple global sections */
        if (lp_ctx->bInGlobalSection) {
-               DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
+               DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName));
                return true;
        }
 
@@ -2069,7 +2921,7 @@ static bool do_section(const char *pszSectionName, void *userdata)
        if (bRetval) {
                /* We put this here to avoid an odd message order if messages are */
                /* issued by the post-processing of a previous section. */
-               DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
+               DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName));
 
                if ((lp_ctx->currentService = lpcfg_add_service(lp_ctx, lp_ctx->sDefault,
                                                                   pszSectionName))
@@ -2102,6 +2954,7 @@ static bool is_default(struct loadparm_service *sDefault, int i)
                        return strequal(parm_table[i].def.svalue,
                                        *(char **)def_ptr);
                case P_BOOL:
+               case P_BOOLREV:
                        return parm_table[i].def.bvalue ==
                                *(int *)def_ptr;
                case P_INTEGER:
@@ -2127,7 +2980,7 @@ static void dump_globals(struct loadparm_context *lp_ctx, FILE *f,
        fprintf(f, "# Global parameters\n[global]\n");
 
        for (i = 0; parm_table[i].label; i++)
-               if (parm_table[i].pclass == P_GLOBAL &&
+               if (parm_table[i].p_class == P_GLOBAL &&
                    parm_table[i].offset != -1 &&
                    (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) {
                        if (!show_defaults && (lp_ctx->flags[i] & FLAG_DEFAULT))
@@ -2162,7 +3015,7 @@ static void dump_a_service(struct loadparm_service * pService, struct loadparm_s
                fprintf(f, "\n[%s]\n", pService->szService);
 
        for (i = 0; parm_table[i].label; i++) {
-               if (parm_table[i].pclass == P_LOCAL &&
+               if (parm_table[i].p_class == P_LOCAL &&
                    parm_table[i].offset != -1 &&
                    (*parm_table[i].label != '-') &&
                    (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
@@ -2245,7 +3098,7 @@ struct parm_struct *lpcfg_next_parameter(struct loadparm_context *lp_ctx, int sn
                struct loadparm_service *pService = lp_ctx->services[snum];
 
                for (; parm_table[*i].label; (*i)++) {
-                       if (parm_table[*i].pclass == P_LOCAL &&
+                       if (parm_table[*i].p_class == P_LOCAL &&
                            parm_table[*i].offset != -1 &&
                            (*parm_table[*i].label != '-') &&
                            ((*i) == 0 ||
@@ -2283,7 +3136,7 @@ static void lpcfg_add_auto_services(struct loadparm_context *lp_ctx,
  * Unload unused services.
  */
 
-void lp_killunused(struct loadparm_context *lp_ctx,
+void lpcfg_killunused(struct loadparm_context *lp_ctx,
                   struct smbsrv_connection *smb,
                   bool (*snumused) (struct smbsrv_connection *, int))
 {
@@ -2300,7 +3153,7 @@ void lp_killunused(struct loadparm_context *lp_ctx,
 }
 
 
-static int lp_destructor(struct loadparm_context *lp_ctx)
+static int lpcfg_destructor(struct loadparm_context *lp_ctx)
 {
        struct parmlist_entry *data;
 
@@ -2335,12 +3188,13 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
        char *myname;
        struct loadparm_context *lp_ctx;
        struct parmlist_entry *parm;
+       char *logfile;
 
        lp_ctx = talloc_zero(mem_ctx, struct loadparm_context);
        if (lp_ctx == NULL)
                return NULL;
 
-       talloc_set_destructor(lp_ctx, lp_destructor);
+       talloc_set_destructor(lp_ctx, lpcfg_destructor);
        lp_ctx->bInGlobalSection = true;
        lp_ctx->globals = talloc_zero(lp_ctx, struct loadparm_global);
        lp_ctx->sDefault = talloc_zero(lp_ctx, struct loadparm_service);
@@ -2365,7 +3219,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
                    parm_table[i].offset != -1 &&
                    !(lp_ctx->flags[i] & FLAG_CMDLINE)) {
                        char **r;
-                       if (parm_table[i].pclass == P_LOCAL) {
+                       if (parm_table[i].p_class == P_LOCAL) {
                                r = (char **)(((char *)lp_ctx->sDefault) + parm_table[i].offset);
                        } else {
                                r = (char **)(((char *)lp_ctx->globals) + parm_table[i].offset);
@@ -2374,6 +3228,14 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
                }
        }
 
+       logfile = talloc_asprintf(lp_ctx, "%s/log.samba", dyn_LOGFILEBASE);
+       lpcfg_do_global_parameter(lp_ctx, "log file", logfile);
+       talloc_free(logfile);
+
+       lpcfg_do_global_parameter(lp_ctx, "log level", "0");
+
+       lpcfg_do_global_parameter(lp_ctx, "share backend", "classic");
+
        lpcfg_do_global_parameter(lp_ctx, "share backend", "classic");
 
        lpcfg_do_global_parameter(lp_ctx, "server role", "standalone");
@@ -2394,18 +3256,12 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
        lpcfg_do_global_parameter(lp_ctx, "ntvfs handler", "unixuid default");
        lpcfg_do_global_parameter(lp_ctx, "max connections", "-1");
 
-       lpcfg_do_global_parameter(lp_ctx, "dcerpc endpoint servers", "epmapper srvsvc wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi winreg dssetup unixinfo browser eventlog6");
-       lpcfg_do_global_parameter(lp_ctx, "server services", "smb rpc nbt wrepl ldap cldap kdc drepl winbind ntp_signd kcc dnsupdate");
+       lpcfg_do_global_parameter(lp_ctx, "dcerpc endpoint servers", "epmapper srvsvc wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi winreg dssetup unixinfo browser eventlog6 backupkey");
+       lpcfg_do_global_parameter(lp_ctx, "server services", "smb rpc nbt wrepl ldap cldap kdc drepl winbind ntp_signd kcc dnsupdate web");
        lpcfg_do_global_parameter(lp_ctx, "ntptr providor", "simple_ldb");
        /* the winbind method for domain controllers is for both RODC
           auth forwarding and for trusted domains */
-       lpcfg_do_global_parameter(lp_ctx, "auth methods:domain controller", "anonymous sam_ignoredomain winbind");
-       lpcfg_do_global_parameter(lp_ctx, "auth methods:member server", "anonymous sam winbind");
-       lpcfg_do_global_parameter(lp_ctx, "auth methods:standalone", "anonymous sam_ignoredomain");
        lpcfg_do_global_parameter(lp_ctx, "private dir", dyn_PRIVATE_DIR);
-       lpcfg_do_global_parameter(lp_ctx, "sam database", "sam.ldb");
-       lpcfg_do_global_parameter(lp_ctx, "idmap database", "idmap.ldb");
-       lpcfg_do_global_parameter(lp_ctx, "secrets database", "secrets.ldb");
        lpcfg_do_global_parameter(lp_ctx, "spoolss database", "spoolss.ldb");
        lpcfg_do_global_parameter(lp_ctx, "wins config database", "wins_config.ldb");
        lpcfg_do_global_parameter(lp_ctx, "wins database", "wins.ldb");
@@ -2429,17 +3285,12 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
 
        lpcfg_do_global_parameter(lp_ctx, "pid directory", dyn_PIDDIR);
        lpcfg_do_global_parameter(lp_ctx, "lock dir", dyn_LOCKDIR);
-       lpcfg_do_global_parameter(lp_ctx, "modules dir", dyn_MODULESDIR);
        lpcfg_do_global_parameter(lp_ctx, "ncalrpc dir", dyn_NCALRPCDIR);
 
-       lpcfg_do_global_parameter(lp_ctx, "socket address", "0.0.0.0");
+       lpcfg_do_global_parameter(lp_ctx, "socket address", "");
        lpcfg_do_global_parameter_var(lp_ctx, "server string",
                                   "Samba %s", SAMBA_VERSION_STRING);
 
-       lpcfg_do_global_parameter_var(lp_ctx, "announce version", "%d.%d",
-                        DEFAULT_MAJOR_VERSION,
-                        DEFAULT_MINOR_VERSION);
-
        lpcfg_do_global_parameter(lp_ctx, "password server", "*");
 
        lpcfg_do_global_parameter(lp_ctx, "max mux", "50");
@@ -2457,7 +3308,6 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
        lpcfg_do_global_parameter(lp_ctx, "WriteRaw", "True");
        lpcfg_do_global_parameter(lp_ctx, "NullPasswords", "False");
        lpcfg_do_global_parameter(lp_ctx, "ObeyPamRestrictions", "False");
-       lpcfg_do_global_parameter(lp_ctx, "announce as", "NT SERVER");
 
        lpcfg_do_global_parameter(lp_ctx, "TimeServer", "False");
        lpcfg_do_global_parameter(lp_ctx, "BindInterfacesOnly", "False");
@@ -2506,9 +3356,6 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
        lpcfg_do_global_parameter(lp_ctx, "tls keyfile", "tls/key.pem");
        lpcfg_do_global_parameter(lp_ctx, "tls certfile", "tls/cert.pem");
        lpcfg_do_global_parameter(lp_ctx, "tls cafile", "tls/ca.pem");
-       lpcfg_do_global_parameter_var(lp_ctx, "setup directory", "%s",
-                                     dyn_SETUPDIR);
-
        lpcfg_do_global_parameter(lp_ctx, "prefork children:smb", "4");
 
        lpcfg_do_global_parameter(lp_ctx, "ntp signd socket directory", dyn_NTP_SIGND_SOCKET_DIR);
@@ -2540,6 +3387,10 @@ struct loadparm_context *loadparm_init_global(bool load_default)
        if (global_loadparm_context == NULL) {
                global_loadparm_context = loadparm_init(NULL);
        }
+       if (global_loadparm_context == NULL) {
+               return NULL;
+       }
+       global_loadparm_context->global = true;
        if (load_default && !global_loadparm_context->loaded) {
                lpcfg_load_default(global_loadparm_context);
        }
@@ -2547,6 +3398,20 @@ struct loadparm_context *loadparm_init_global(bool load_default)
        return global_loadparm_context;
 }
 
+/**
+ * Initialise the global parameter structure.
+ */
+struct loadparm_context *loadparm_init_s3(TALLOC_CTX *mem_ctx, 
+                                         const struct loadparm_s3_context *s3_fns)
+{
+       struct loadparm_context *loadparm_context = loadparm_init(mem_ctx);
+       if (!loadparm_context) {
+               return NULL;
+       }
+       loadparm_context->s3_fns = s3_fns;
+       return loadparm_context;
+}
+
 const char *lpcfg_configfile(struct loadparm_context *lp_ctx)
 {
        return lp_ctx->szConfigFile;
@@ -2566,17 +3431,26 @@ const char *lp_default_path(void)
  */
 static bool lpcfg_update(struct loadparm_context *lp_ctx)
 {
+       struct debug_settings settings;
        lpcfg_add_auto_services(lp_ctx, lpcfg_auto_services(lp_ctx));
 
        if (!lp_ctx->globals->szWINSservers && lp_ctx->globals->bWINSsupport) {
                lpcfg_do_global_parameter(lp_ctx, "wins server", "127.0.0.1");
        }
 
+       if (!lp_ctx->global) {
+               return true;
+       }
+
        panic_action = lp_ctx->globals->panic_action;
 
        reload_charcnv(lp_ctx);
 
-       /* FIXME: ntstatus_check_dos_mapping = lpcfg_nt_status_support(lp_ctx); */
+       ZERO_STRUCT(settings);
+       /* Add any more debug-related smb.conf parameters created in
+        * future here */
+       settings.timestamp_logs = true;
+       debug_set_settings(&settings);
 
        /* FIXME: This is a bit of a hack, but we can't use a global, since 
         * not everything that uses lp also uses the socket library */
@@ -2586,12 +3460,6 @@ static bool lpcfg_update(struct loadparm_context *lp_ctx)
                unsetenv("SOCKET_TESTNONBLOCK");
        }
 
-       /* FIXME: Check locale in environment for this: */
-       if (strcmp(lpcfg_display_charset(lp_ctx), lpcfg_unix_charset(lp_ctx)) != 0)
-               d_set_iconv(smb_iconv_open(lpcfg_display_charset(lp_ctx), lpcfg_unix_charset(lp_ctx)));
-       else
-               d_set_iconv((smb_iconv_t)-1);
-
        return true;
 }
 
@@ -2742,7 +3610,7 @@ const char *lpcfg_servicename(const struct loadparm_service *service)
 /**
  * A useful volume label function.
  */
-const char *volume_label(struct loadparm_service *service, struct loadparm_service *sDefault)
+const char *lpcfg_volume_label(struct loadparm_service *service, struct loadparm_service *sDefault)
 {
        const char *ret;
        ret = lp_string((const char *)((service != NULL && service->volume != NULL) ?
@@ -2779,26 +3647,26 @@ int lpcfg_maxprintjobs(struct loadparm_service *service, struct loadparm_service
        return maxjobs;
 }
 
-struct smb_iconv_convenience *lpcfg_iconv_convenience(struct loadparm_context *lp_ctx)
+struct smb_iconv_handle *lpcfg_iconv_handle(struct loadparm_context *lp_ctx)
 {
        if (lp_ctx == NULL) {
-               static struct smb_iconv_convenience *fallback_ic = NULL;
-               if (fallback_ic == NULL)
-                       fallback_ic = smb_iconv_convenience_reinit(talloc_autofree_context(),
-                                                                  "CP850", "UTF8", true, NULL);
-               return fallback_ic;
+               return get_iconv_handle();
        }
-       return lp_ctx->iconv_convenience;
+       return lp_ctx->iconv_handle;
 }
 
 _PUBLIC_ void reload_charcnv(struct loadparm_context *lp_ctx)
 {
-       struct smb_iconv_convenience *old_ic = lp_ctx->iconv_convenience;
+       struct smb_iconv_handle *old_ic = lp_ctx->iconv_handle;
+       if (!lp_ctx->global) {
+               return;
+       }
+
        if (old_ic == NULL) {
-               old_ic = global_iconv_convenience;
+               old_ic = global_iconv_handle;
        }
-       lp_ctx->iconv_convenience = smb_iconv_convenience_reinit_lp(lp_ctx, lp_ctx, old_ic);
-       global_iconv_convenience = lp_ctx->iconv_convenience;
+       lp_ctx->iconv_handle = smb_iconv_handle_reinit_lp(lp_ctx, lp_ctx, old_ic);
+       global_iconv_handle = lp_ctx->iconv_handle;
 }
 
 void lpcfg_smbcli_options(struct loadparm_context *lp_ctx,
@@ -2826,27 +3694,27 @@ void lpcfg_smbcli_session_options(struct loadparm_context *lp_ctx,
 
 _PUBLIC_ char *lpcfg_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
 {
-       return private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_keyfile);
+       return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_keyfile);
 }
 
 _PUBLIC_ char *lpcfg_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
 {
-       return private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_certfile);
+       return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_certfile);
 }
 
 _PUBLIC_ char *lpcfg_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
 {
-       return private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_cafile);
+       return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_cafile);
 }
 
 _PUBLIC_ char *lpcfg_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
 {
-       return private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_crlfile);
+       return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_crlfile);
 }
 
 _PUBLIC_ char *lpcfg_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
 {
-       return private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_dhpfile);
+       return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_dhpfile);
 }
 
 _PUBLIC_ struct dcerpc_server_info *lpcfg_dcerpc_server_info(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)