lib/param: handle non-constant strings properly by passing in a memory context
[sfrench/samba-autobuild/.git] / lib / param / loadparm.c
index 580be29e2db64a0493d6d541d63326f84bf6c51f..b42855c0fe16890212b04a0abca3bbb386c49903 100644 (file)
 static bool do_parameter(const char *, const char *, void *);
 static bool defaults_saved = false;
 
-#define LOADPARM_EXTRA_GLOBALS \
-       struct parmlist_entry *param_opt;                               \
-       char *realm_original;                                           \
-       char *szConfigFile;                                             \
-       int iminreceivefile;                                            \
-       char *szPrintcapname;                                           \
-       int CupsEncrypt;                                                \
-       int  iPreferredMaster;                                          \
-       char *szLdapMachineSuffix;                                      \
-       char *szLdapUserSuffix;                                         \
-       char *szLdapIdmapSuffix;                                        \
-       char *szLdapGroupSuffix;                                        \
-       char *szUsershareTemplateShare;                                 \
-       char *szIdmapUID;                                               \
-       char *szIdmapGID;                                               \
-       char *szIdmapBackend;                                           \
-       int winbindMaxDomainConnections;                                \
-       int ismb2_max_credits;                                          \
-       char *tls_keyfile;                                              \
-       char *tls_certfile;                                             \
-       char *tls_cafile;                                               \
-       char *tls_crlfile;                                              \
-       char *tls_dhpfile;                                              \
-       char *loglevel;
-
 #include "lib/param/param_global.h"
 
 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
@@ -232,12 +207,13 @@ static struct loadparm_context *global_loadparm_context;
 #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) {\
+ _PUBLIC_ char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx, TALLOC_CTX *ctx) {\
         if (lp_ctx == NULL) return NULL;                               \
         if (lp_ctx->s3_fns) {                                          \
-                smb_panic( __location__ ": " #fn_name " not implemented because it is an allocated and substiuted string"); \
+                SMB_ASSERT(lp_ctx->s3_fns->fn_name);                   \
+                return lp_ctx->s3_fns->fn_name(ctx);                   \
         }                                                              \
-        return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \
+        return lp_ctx->globals->var_name ? talloc_strdup(ctx, lp_string(lp_ctx->globals->var_name)) : talloc_strdup(ctx, ""); \
 }
 
 #define FN_GLOBAL_CONST_STRING(fn_name,var_name)                               \
@@ -283,13 +259,17 @@ static struct loadparm_context *global_loadparm_context;
  * loadparm_service is shared and lpcfg_service() checks the ->s3_fns
  * hook */
 #define FN_LOCAL_STRING(fn_name,val) \
+ _PUBLIC_ char *lpcfg_ ## fn_name(struct loadparm_service *service, \
+                                       struct loadparm_service *sDefault, TALLOC_CTX *ctx) { \
+        return(talloc_strdup(ctx, lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val)))); \
+ }
+
+#define FN_LOCAL_CONST_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))); \
+        return((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val)); \
  }
 
-#define FN_LOCAL_CONST_STRING(fn_name,val) FN_LOCAL_STRING(fn_name, val)
-
 #define FN_LOCAL_LIST(fn_name,val) \
  _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_service *service, \
                                         struct loadparm_service *sDefault) {\
@@ -320,14 +300,11 @@ static struct loadparm_context *global_loadparm_context;
 
 #include "lib/param/param_functions.c"
 
-/* These functions remain only in lib/param for now */
-FN_GLOBAL_BOOL(readraw, bReadRaw)
-FN_GLOBAL_BOOL(writeraw, bWriteRaw)
-FN_GLOBAL_CONST_STRING(cachedir, szCacheDir)
-FN_GLOBAL_CONST_STRING(statedir, szStateDir)
+/* These functions cannot be auto-generated */
+FN_LOCAL_BOOL(autoloaded, autoloaded)
+FN_GLOBAL_CONST_STRING(dnsdomain, dnsdomain)
 
 /* local prototypes */
-static int map_parameter(const char *pszParmName);
 static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
                                        const char *pszServiceName);
 static void copy_service(struct loadparm_service *pserviceDest,
@@ -744,11 +721,11 @@ bool lpcfg_add_home(struct loadparm_context *lp_ctx,
        if (service == NULL)
                return false;
 
-       if (!(*(default_service->pathname))
-           || strequal(default_service->pathname, lp_ctx->sDefault->pathname)) {
-               service->pathname = talloc_strdup(service, pszHomedir);
+       if (!(*(default_service->path))
+           || strequal(default_service->path, lp_ctx->sDefault->path)) {
+               service->path = talloc_strdup(service, pszHomedir);
        } else {
-               service->pathname = string_sub_talloc(service, lpcfg_pathname(default_service, lp_ctx->sDefault), "%H", pszHomedir);
+               service->path = string_sub_talloc(service, lpcfg_path(default_service, lp_ctx->sDefault, service), "%H", pszHomedir);
        }
 
        if (!(*(service->comment))) {
@@ -758,7 +735,7 @@ bool lpcfg_add_home(struct loadparm_context *lp_ctx,
        service->browseable = default_service->browseable;
 
        DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n",
-                 pszHomename, user, service->pathname));
+                 pszHomename, user, service->path));
 
        return true;
 }
@@ -784,13 +761,13 @@ bool lpcfg_add_printer(struct loadparm_context *lp_ctx,
        /* entry (if/when the 'available' keyword is implemented!).    */
 
        /* the printer name is set to the service name. */
-       lpcfg_string_set(service, &service->szPrintername, pszPrintername);
+       lpcfg_string_set(service, &service->_printername, pszPrintername);
        lpcfg_string_set(service, &service->comment, comment);
        service->browseable = default_service->browseable;
        /* Printers cannot be read_only. */
-       service->readonly = false;
+       service->read_only = false;
        /* Printer services must be printable. */
-       service->print_ok = true;
+       service->printable = true;
 
        DEBUG(3, ("adding printer service %s\n", pszPrintername));
 
@@ -802,13 +779,10 @@ bool lpcfg_add_printer(struct loadparm_context *lp_ctx,
  * Returns False if the parameter string is not recognised, else TRUE.
  */
 
-static int map_parameter(const char *pszParmName)
+int lpcfg_map_parameter(const char *pszParmName)
 {
        int iIndex;
 
-       if (*pszParmName == '-')
-               return -1;
-
        for (iIndex = 0; parm_table[iIndex].label; iIndex++)
                if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
                        return iIndex;
@@ -834,7 +808,7 @@ struct parm_struct *lpcfg_parm_struct(struct loadparm_context *lp_ctx, const cha
                return lp_ctx->s3_fns->get_parm_struct(name);
        }
 
-       parmnum = map_parameter(name);
+       parmnum = lpcfg_map_parameter(name);
        if (parmnum == -1) return NULL;
        return &parm_table[parmnum];
 }
@@ -875,7 +849,7 @@ bool lpcfg_parm_is_cmdline(struct loadparm_context *lp_ctx, const char *name)
                return false;
        }
 
-       parmnum = map_parameter(name);
+       parmnum = lpcfg_map_parameter(name);
        if (parmnum == -1) return false;
 
        return lp_ctx->flags[parmnum] & FLAG_CMDLINE;
@@ -927,6 +901,7 @@ static void copy_service(struct loadparm_service *pserviceDest,
 
                        switch (parm_table[i].type) {
                                case P_BOOL:
+                               case P_BOOLREV:
                                        *(bool *)dest_ptr = *(bool *)src_ptr;
                                        break;
 
@@ -937,6 +912,10 @@ static void copy_service(struct loadparm_service *pserviceDest,
                                        *(int *)dest_ptr = *(int *)src_ptr;
                                        break;
 
+                               case P_CHAR:
+                                       *(char *)dest_ptr = *(char *)src_ptr;
+                                       break;
+
                                case P_STRING:
                                        lpcfg_string_set(pserviceDest,
                                                   (char **)dest_ptr,
@@ -1010,10 +989,10 @@ static bool lpcfg_service_ok(struct loadparm_service *service)
        /* The [printers] entry MUST be printable. I'm all for flexibility, but */
        /* I can't see why you'd want a non-printable printer service...        */
        if (strwicmp(service->szService, PRINTERS_NAME) == 0) {
-               if (!service->print_ok) {
+               if (!service->printable) {
                        DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
                               service->szService));
-                       service->print_ok = true;
+                       service->printable = true;
                }
                /* [printers] service must also be non-browsable. */
                if (service->browseable)
@@ -1429,7 +1408,7 @@ mark_non_default:
 bool lpcfg_do_global_parameter(struct loadparm_context *lp_ctx,
                               const char *pszParmName, const char *pszParmValue)
 {
-       int parmnum = map_parameter(pszParmName);
+       int parmnum = lpcfg_map_parameter(pszParmName);
        void *parm_ptr;
 
        if (parmnum < 0) {
@@ -1458,7 +1437,7 @@ bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
 {
        void *parm_ptr;
        int i;
-       int parmnum = map_parameter(pszParmName);
+       int parmnum = lpcfg_map_parameter(pszParmName);
 
        if (parmnum < 0) {
                if (strchr(pszParmName, ':')) {
@@ -1548,7 +1527,7 @@ bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
                return lp_ctx->s3_fns->set_cmdline(pszParmName, pszParmValue);
        }
 
-       parmnum = map_parameter(pszParmName);
+       parmnum = lpcfg_map_parameter(pszParmName);
 
        while (isspace((unsigned char)*pszParmValue)) pszParmValue++;
 
@@ -1574,10 +1553,17 @@ bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
        lp_ctx->flags[parmnum] |= FLAG_CMDLINE;
 
        /* we have to also set FLAG_CMDLINE on aliases */
-       for (i=parmnum-1;i>=0 && parm_table[i].offset == parm_table[parmnum].offset;i--) {
+       for (i=parmnum-1;
+            i>=0 && parm_table[i].p_class == parm_table[parmnum].p_class &&
+            parm_table[i].offset == parm_table[parmnum].offset;
+            i--) {
                lp_ctx->flags[i] |= FLAG_CMDLINE;
        }
-       for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset;i++) {
+       for (i=parmnum+1;
+            i<NUMPARAMETERS &&
+            parm_table[i].p_class == parm_table[parmnum].p_class &&
+            parm_table[i].offset == parm_table[parmnum].offset;
+            i++) {
                lp_ctx->flags[i] |= FLAG_CMDLINE;
        }
 
@@ -1617,7 +1603,7 @@ bool lpcfg_set_option(struct loadparm_context *lp_ctx, const char *option)
  * Print a parameter of the specified type.
  */
 
-static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
+void lpcfg_print_parameter(struct parm_struct *p, void *ptr, FILE * f)
 {
        /* For the seperation of lists values that we print below */
        const char *list_sep = ", ";
@@ -1656,7 +1642,7 @@ static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
                        if (val == -1) {
                                fprintf(f, "-1");
                        } else {
-                               fprintf(f, "0%o", val);
+                               fprintf(f, "0%03o", val);
                        }
                        break;
                }
@@ -1697,7 +1683,7 @@ static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
  * Check if two parameters are equal.
  */
 
-static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
+ bool lpcfg_equal_parameter(parm_type type, void *ptr1, void *ptr2)
 {
        switch (type) {
                case P_BOOL:
@@ -1789,8 +1775,6 @@ static bool do_section(const char *pszSectionName, void *userdata)
 static bool is_default(struct loadparm_service *sDefault, int i)
 {
        void *def_ptr = ((char *)sDefault) + parm_table[i].offset;
-       if (!defaults_saved)
-               return false;
        switch (parm_table[i].type) {
                case P_CMDLIST:
                case P_LIST:
@@ -1835,7 +1819,7 @@ static void dump_globals(struct loadparm_context *lp_ctx, FILE *f,
                        if (!show_defaults && (lp_ctx->flags[i] & FLAG_DEFAULT))
                                continue;
                        fprintf(f, "\t%s = ", parm_table[i].label);
-                       print_parameter(&parm_table[i], lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[i]), f);
+                       lpcfg_print_parameter(&parm_table[i], lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[i]), f);
                        fprintf(f, "\n");
        }
        if (lp_ctx->globals->param_opt != NULL) {
@@ -1878,16 +1862,16 @@ static void dump_a_service(struct loadparm_service * pService, struct loadparm_s
                                        }
                                }
                        } else {
-                               if (equal_parameter(parm_table[i].type,
-                                                   ((char *)pService) +
-                                                   parm_table[i].offset,
-                                                   ((char *)sDefault) +
-                                                   parm_table[i].offset))
+                               if (lpcfg_equal_parameter(parm_table[i].type,
+                                                         ((char *)pService) +
+                                                         parm_table[i].offset,
+                                                         ((char *)sDefault) +
+                                                         parm_table[i].offset))
                                        continue;
                        }
 
                        fprintf(f, "\t%s = ", parm_table[i].label);
-                       print_parameter(&parm_table[i],
+                       lpcfg_print_parameter(&parm_table[i],
                                        ((char *)pService) + parm_table[i].offset, f);
                        fprintf(f, "\n");
                }
@@ -1917,63 +1901,11 @@ bool lpcfg_dump_a_parameter(struct loadparm_context *lp_ctx,
 
        ptr = lpcfg_parm_ptr(lp_ctx, service,parm);
 
-       print_parameter(parm, ptr, f);
+       lpcfg_print_parameter(parm, ptr, f);
        fprintf(f, "\n");
        return true;
 }
 
-/**
- * Return info about the next parameter in a service.
- * snum==-1 gives the globals.
- * Return NULL when out of parameters.
- */
-
-
-struct parm_struct *lpcfg_next_parameter(struct loadparm_context *lp_ctx, int snum, int *i,
-                                        int allparameters)
-{
-       if (snum == -1) {
-               /* do the globals */
-               for (; parm_table[*i].label; (*i)++) {
-                       if ((*parm_table[*i].label == '-'))
-                               continue;
-
-                       if ((*i) > 0
-                           && (parm_table[*i].offset ==
-                               parm_table[(*i) - 1].offset)
-                           && (parm_table[*i].p_class ==
-                               parm_table[(*i) - 1].p_class))
-                               continue;
-
-                       return &parm_table[(*i)++];
-               }
-       } else {
-               struct loadparm_service *pService = lp_ctx->services[snum];
-
-               for (; parm_table[*i].label; (*i)++) {
-                       if (parm_table[*i].p_class == P_LOCAL &&
-                           (*parm_table[*i].label != '-') &&
-                           ((*i) == 0 ||
-                            (parm_table[*i].offset !=
-                             parm_table[(*i) - 1].offset)))
-                       {
-                               if (allparameters ||
-                                   !equal_parameter(parm_table[*i].type,
-                                                    ((char *)pService) +
-                                                    parm_table[*i].offset,
-                                                    ((char *)lp_ctx->sDefault) +
-                                                    parm_table[*i].offset))
-                               {
-                                       return &parm_table[(*i)++];
-                               }
-                       }
-               }
-       }
-
-       return NULL;
-}
-
-
 /**
  * Auto-load some home services.
  */
@@ -2054,14 +1986,14 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
        lp_ctx->sDefault->iMaxPrintJobs = 1000;
        lp_ctx->sDefault->bAvailable = true;
        lp_ctx->sDefault->browseable = true;
-       lp_ctx->sDefault->readonly = true;
+       lp_ctx->sDefault->read_only = true;
        lp_ctx->sDefault->map_archive = true;
        lp_ctx->sDefault->strict_locking = true;
        lp_ctx->sDefault->oplocks = true;
        lp_ctx->sDefault->create_mask = 0744;
        lp_ctx->sDefault->force_create_mode = 0000;
-       lp_ctx->sDefault->dir_mask = 0755;
-       lp_ctx->sDefault->force_dir_mode = 0000;
+       lp_ctx->sDefault->directory_mask = 0755;
+       lp_ctx->sDefault->force_directory_mode = 0000;
 
        DEBUG(3, ("Initialising global parameters\n"));
 
@@ -2109,12 +2041,12 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
        myname = get_myname(lp_ctx);
        lpcfg_do_global_parameter(lp_ctx, "netbios name", myname);
        talloc_free(myname);
-       lpcfg_do_global_parameter(lp_ctx, "name resolve order", "wins host bcast");
+       lpcfg_do_global_parameter(lp_ctx, "name resolve order", "lmhosts wins host bcast");
 
        lpcfg_do_global_parameter(lp_ctx, "fstype", "NTFS");
 
        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, "max connections", "0");
 
        lpcfg_do_global_parameter(lp_ctx, "dcerpc endpoint servers", "epmapper wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi dssetup unixinfo browser eventlog6 backupkey dnsserver");
        lpcfg_do_global_parameter(lp_ctx, "server services", "s3fs rpc nbt wrepl ldap cldap kdc drepl winbind ntp_signd kcc dnsupdate dns");
@@ -2146,19 +2078,19 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
        lpcfg_do_global_parameter(lp_ctx, "cache directory", dyn_CACHEDIR);
        lpcfg_do_global_parameter(lp_ctx, "ncalrpc dir", dyn_NCALRPCDIR);
 
-       lpcfg_do_global_parameter(lp_ctx, "nbt client socket address", "");
+       lpcfg_do_global_parameter(lp_ctx, "nbt client socket address", "0.0.0.0");
        lpcfg_do_global_parameter_var(lp_ctx, "server string",
                                   "Samba %s", SAMBA_VERSION_STRING);
 
        lpcfg_do_global_parameter(lp_ctx, "password server", "*");
 
        lpcfg_do_global_parameter(lp_ctx, "max mux", "50");
-       lpcfg_do_global_parameter(lp_ctx, "max xmit", "12288");
+       lpcfg_do_global_parameter(lp_ctx, "max xmit", "16644");
        lpcfg_do_global_parameter(lp_ctx, "host msdfs", "true");
 
        lpcfg_do_global_parameter(lp_ctx, "LargeReadwrite", "True");
-       lpcfg_do_global_parameter(lp_ctx, "server min protocol", "CORE");
-       lpcfg_do_global_parameter(lp_ctx, "server max protocol", "NT1");
+       lpcfg_do_global_parameter(lp_ctx, "server min protocol", "LANMAN1");
+       lpcfg_do_global_parameter(lp_ctx, "server max protocol", "SMB3");
        lpcfg_do_global_parameter(lp_ctx, "client min protocol", "CORE");
        lpcfg_do_global_parameter(lp_ctx, "client max protocol", "NT1");
        lpcfg_do_global_parameter(lp_ctx, "security", "AUTO");
@@ -2216,7 +2148,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
        lpcfg_do_global_parameter(lp_ctx, "nt status support", "True");
 
        lpcfg_do_global_parameter(lp_ctx, "max wins ttl", "518400"); /* 6 days */
-       lpcfg_do_global_parameter(lp_ctx, "min wins ttl", "10");
+       lpcfg_do_global_parameter(lp_ctx, "min wins ttl", "21600");
 
        lpcfg_do_global_parameter(lp_ctx, "tls enabled", "True");
        lpcfg_do_global_parameter(lp_ctx, "tls keyfile", "tls/key.pem");
@@ -2230,6 +2162,202 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
         lpcfg_do_global_parameter(lp_ctx, "allow dns updates", "secure only");
         lpcfg_do_global_parameter(lp_ctx, "dns forwarder", "");
 
+       lpcfg_do_global_parameter(lp_ctx, "algorithmic rid base", "1000");
+
+       lpcfg_do_global_parameter(lp_ctx, "enhanced browsing", "True");
+
+       lpcfg_do_global_parameter(lp_ctx, "winbind nss info", "template");
+
+       lpcfg_do_global_parameter(lp_ctx, "server schannel", "Auto");
+
+       lpcfg_do_global_parameter(lp_ctx, "short preserve case", "True");
+
+       lpcfg_do_global_parameter(lp_ctx, "max open files", "16384");
+
+       lpcfg_do_global_parameter(lp_ctx, "cups connection timeout", "30");
+
+       lpcfg_do_global_parameter(lp_ctx, "locking", "True");
+
+       lpcfg_do_global_parameter(lp_ctx, "block size", "1024");
+
+       lpcfg_do_global_parameter(lp_ctx, "client use spnego", "True");
+
+       lpcfg_do_global_parameter(lp_ctx, "change notify", "True");
+
+       lpcfg_do_global_parameter(lp_ctx, "name cache timeout", "660");
+
+       lpcfg_do_global_parameter(lp_ctx, "defer sharing violations", "True");
+
+       lpcfg_do_global_parameter(lp_ctx, "ldap replication sleep", "1000");
+
+       lpcfg_do_global_parameter(lp_ctx, "idmap backend", "tdb");
+
+       lpcfg_do_global_parameter(lp_ctx, "enable privileges", "True");
+
+       lpcfg_do_global_parameter_var(lp_ctx, "smb2 max write", "%u", DEFAULT_SMB2_MAX_WRITE);
+
+       lpcfg_do_global_parameter(lp_ctx, "passdb backend", "tdbsam");
+
+       lpcfg_do_global_parameter(lp_ctx, "getwd cache", "True");
+
+       lpcfg_do_global_parameter(lp_ctx, "winbind nested groups", "True");
+
+       lpcfg_do_global_parameter(lp_ctx, "mangled names", "True");
+
+       lpcfg_do_global_parameter_var(lp_ctx, "smb2 max credits", "%u", DEFAULT_SMB2_MAX_CREDITS);
+
+       lpcfg_do_global_parameter(lp_ctx, "ldap ssl", "start tls");
+
+       lpcfg_do_global_parameter(lp_ctx, "ldap deref", "auto");
+
+       lpcfg_do_global_parameter(lp_ctx, "lm interval", "60");
+
+       lpcfg_do_global_parameter(lp_ctx, "mangling method", "hash2");
+
+       lpcfg_do_global_parameter(lp_ctx, "hide dot files", "True");
+
+       lpcfg_do_global_parameter(lp_ctx, "browse list", "True");
+
+       lpcfg_do_global_parameter(lp_ctx, "passwd chat timeout", "2");
+
+       lpcfg_do_global_parameter(lp_ctx, "guest account", GUEST_ACCOUNT);
+
+       lpcfg_do_global_parameter(lp_ctx, "client schannel", "auto");
+
+       lpcfg_do_global_parameter(lp_ctx, "smb encrypt", "default");
+
+       lpcfg_do_global_parameter(lp_ctx, "max log size", "5000");
+
+       lpcfg_do_global_parameter(lp_ctx, "idmap negative cache time", "120");
+
+       lpcfg_do_global_parameter(lp_ctx, "ldap follow referral", "auto");
+
+       lpcfg_do_global_parameter(lp_ctx, "multicast dns register", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "winbind reconnect delay", "30");
+
+       lpcfg_do_global_parameter(lp_ctx, "nt acl support", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "acl check permissions", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "keepalive", "300");
+
+       lpcfg_do_global_parameter(lp_ctx, "winbind cache time", "300");
+
+       lpcfg_do_global_parameter(lp_ctx, "level2 oplocks", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "show add printer wizard", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "allocation roundup size", "1048576");
+
+       lpcfg_do_global_parameter(lp_ctx, "ldap page size", "1024");
+
+       lpcfg_do_global_parameter(lp_ctx, "kernel share modes", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "strict locking", "Auto");
+
+       lpcfg_do_global_parameter(lp_ctx, "map readonly", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "allow trusted domains", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "default devmode", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "os level", "20");
+
+       lpcfg_do_global_parameter(lp_ctx, "dos filetimes", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "mangling char", "~");
+
+       lpcfg_do_global_parameter(lp_ctx, "printcap cache time", "750");
+
+       lpcfg_do_global_parameter(lp_ctx, "create krb5 conf", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "winbind max clients", "200");
+
+       lpcfg_do_global_parameter(lp_ctx, "acl map full control", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "nt pipe support", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "ldap debug threshold", "10");
+
+       lpcfg_do_global_parameter(lp_ctx, "follow symlinks", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "machine password timeout", "604800");
+
+       lpcfg_do_global_parameter(lp_ctx, "ldap connection timeout", "2");
+
+       lpcfg_do_global_parameter(lp_ctx, "winbind expand groups", "1");
+
+       lpcfg_do_global_parameter(lp_ctx, "stat cache", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "lpq cache time", "30");
+
+       lpcfg_do_global_parameter_var(lp_ctx, "smb2 max trans", "%u", DEFAULT_SMB2_MAX_TRANSACT);
+
+       lpcfg_do_global_parameter_var(lp_ctx, "smb2 max read", "%u", DEFAULT_SMB2_MAX_READ);
+
+       lpcfg_do_global_parameter(lp_ctx, "durable handles", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "max stat cache size", "256");
+
+       lpcfg_do_global_parameter(lp_ctx, "ldap passwd sync", "no");
+
+       lpcfg_do_global_parameter(lp_ctx, "kernel change notify", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "max ttl", "259200");
+
+       lpcfg_do_global_parameter(lp_ctx, "blocking locks", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "oplock contention limit", "2");
+
+       lpcfg_do_global_parameter(lp_ctx, "load printers", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "idmap cache time", "604800");
+
+       lpcfg_do_global_parameter(lp_ctx, "preserve case", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "lm announce", "auto");
+
+       lpcfg_do_global_parameter(lp_ctx, "afs token lifetime", "604800");
+
+       lpcfg_do_global_parameter(lp_ctx, "enable core files", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "winbind max domain connections", "1");
+
+       lpcfg_do_global_parameter(lp_ctx, "case sensitive", "auto");
+
+       lpcfg_do_global_parameter(lp_ctx, "ldap timeout", "15");
+
+       lpcfg_do_global_parameter(lp_ctx, "mangle prefix", "1");
+
+       lpcfg_do_global_parameter(lp_ctx, "posix locking", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "lock spin time", "200");
+
+       lpcfg_do_global_parameter(lp_ctx, "directory name cache size", "100");
+
+       lpcfg_do_global_parameter(lp_ctx, "nmbd bind explicit broadcast", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "init logon delay", "100");
+
+       lpcfg_do_global_parameter(lp_ctx, "usershare owner only", "yes");
+
+       lpcfg_do_global_parameter(lp_ctx, "-valid", "yes");
+
+       lpcfg_do_global_parameter_var(lp_ctx, "usershare path", "%s/usershares", get_dyn_STATEDIR());
+
+#ifdef DEVELOPER
+       lpcfg_do_global_parameter_var(lp_ctx, "panic action", "/bin/sleep 999999999");
+#endif
+
+       lpcfg_do_global_parameter(lp_ctx, "smb passwd file", get_dyn_SMB_PASSWD_FILE());
+
+       lpcfg_do_global_parameter(lp_ctx, "logon home", "\\\\%N\\%U");
+
+       lpcfg_do_global_parameter(lp_ctx, "logon path", "\\\\%N\\%U\\profile");
+
+       lpcfg_do_global_parameter(lp_ctx, "printjob username", "%U");
+
        for (i = 0; parm_table[i].label; i++) {
                if (!(lp_ctx->flags[i] & FLAG_CMDLINE)) {
                        lp_ctx->flags[i] |= FLAG_DEFAULT;
@@ -2298,13 +2426,21 @@ 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));
+       TALLOC_CTX *tmp_ctx;
+
+       tmp_ctx = talloc_new(lp_ctx);
+       if (tmp_ctx == NULL) {
+               return false;
+       }
+
+       lpcfg_add_auto_services(lp_ctx, lpcfg_auto_services(lp_ctx, tmp_ctx));
 
        if (!lp_ctx->globals->wins_server_list && lp_ctx->globals->we_are_a_wins_server) {
                lpcfg_do_global_parameter(lp_ctx, "wins server", "127.0.0.1");
        }
 
        if (!lp_ctx->global) {
+               TALLOC_FREE(tmp_ctx);
                return true;
        }
 
@@ -2333,6 +2469,7 @@ static bool lpcfg_update(struct loadparm_context *lp_ctx)
                unsetenv("SOCKET_TESTNONBLOCK");
        }
 
+       TALLOC_FREE(tmp_ctx);
        return true;
 }
 
@@ -2515,13 +2652,13 @@ const char *lpcfg_volume_label(struct loadparm_service *service, struct loadparm
 }
 
 /**
- * If we are PDC then prefer us as DMB
+ * Return the correct printer name.
  */
 const char *lpcfg_printername(struct loadparm_service *service, struct loadparm_service *sDefault)
 {
        const char *ret;
-       ret = lp_string((const char *)((service != NULL && service->szPrintername != NULL) ?
-                                      service->szPrintername : sDefault->szPrintername));
+       ret = lp_string((const char *)((service != NULL && service->_printername != NULL) ?
+                                      service->_printername : sDefault->_printername));
        if (ret == NULL || (ret != NULL && *ret == '\0'))
                ret = lpcfg_servicename(service);
 
@@ -2565,27 +2702,27 @@ _PUBLIC_ void reload_charcnv(struct loadparm_context *lp_ctx)
 
 _PUBLIC_ char *lpcfg_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
 {
-       return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_keyfile);
+       return lpcfg_private_path(mem_ctx, lp_ctx, lpcfg__tls_keyfile(lp_ctx));
 }
 
 _PUBLIC_ char *lpcfg_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
 {
-       return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_certfile);
+       return lpcfg_private_path(mem_ctx, lp_ctx, lpcfg__tls_certfile(lp_ctx));
 }
 
 _PUBLIC_ char *lpcfg_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
 {
-       return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_cafile);
+       return lpcfg_private_path(mem_ctx, lp_ctx, lpcfg__tls_cafile(lp_ctx));
 }
 
 _PUBLIC_ char *lpcfg_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
 {
-       return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_crlfile);
+       return lpcfg_private_path(mem_ctx, lp_ctx, lpcfg__tls_crlfile(lp_ctx));
 }
 
 _PUBLIC_ char *lpcfg_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
 {
-       return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_dhpfile);
+       return lpcfg_private_path(mem_ctx, lp_ctx, lpcfg__tls_dhpfile(lp_ctx));
 }
 
 struct gensec_settings *lpcfg_gensec_settings(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)