[GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch.
[samba.git] / source / param / loadparm.c
index acb54f25dfc529363df12b23ed05ca34055f36f8..8b15073ed0083f0087a55797537b54934ebd716a 100644 (file)
@@ -12,7 +12,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -21,8 +21,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 /*
@@ -72,6 +71,17 @@ extern userdom_struct current_user_info;
 #define HOMES_NAME "homes"
 #endif
 
+/* the special value for the include parameter
+ * to be interpreted not as a file name but to
+ * trigger loading of the global smb.conf options
+ * from registry. */
+#ifndef INCLUDE_REGISTRY_NAME
+#define INCLUDE_REGISTRY_NAME "registry"
+#endif
+
+static int regdb_last_seqnum = 0;
+static BOOL include_registry_globals = False;
+
 /* some helpful bits */
 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid)
 #define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid)
@@ -79,7 +89,6 @@ extern userdom_struct current_user_info;
 #define USERSHARE_VALID 1
 #define USERSHARE_PENDING_DELETE 2
 
-int keepalive = DEFAULT_KEEPALIVE;
 BOOL use_getwd_cache = True;
 
 extern int extra_time_offset;
@@ -178,9 +187,14 @@ typedef struct {
        BOOL bWinbindUseDefaultDomain;
        BOOL bWinbindTrustedDomainsOnly;
        BOOL bWinbindNestedGroups;
+       int  winbind_expand_groups;     
        BOOL bWinbindRefreshTickets;
        BOOL bWinbindOfflineLogon;
-       char **szIdmapBackend;
+       BOOL bWinbindNormalizeNames;
+       BOOL bWinbindRpcOnly;
+       char **szIdmapDomains;
+       char **szIdmapBackend; /* deprecated */
+       char *szIdmapAllocBackend;
        char *szAddShareCommand;
        char *szChangeShareCommand;
        char *szDeleteShareCommand;
@@ -226,7 +240,6 @@ typedef struct {
        int winbind_cache_time;
        int winbind_max_idle_children;
        char **szWinbindNssInfo;
-       int iLockSpinCount;
        int iLockSpinTime;
        char *szLdapMachineSuffix;
        char *szLdapUserSuffix;
@@ -238,6 +251,9 @@ typedef struct {
        int iAclCompat;
        char *szCupsServer;
        char *szIPrintServer;
+       char *ctdbdSocket;
+       char **szClusterAddresses;
+       BOOL clustering;
        int ldap_passwd_sync; 
        int ldap_replication_sleep;
        int ldap_timeout; /* This is initialised in init_globals */
@@ -262,7 +278,6 @@ typedef struct {
        BOOL bLargeReadwrite;
        BOOL bReadRaw;
        BOOL bWriteRaw;
-       BOOL bReadbmpx;
        BOOL bSyslogOnly;
        BOOL bBrowseList;
        BOOL bNISHomeMap;
@@ -287,30 +302,35 @@ typedef struct {
        BOOL bClientNTLMv2Auth;
        BOOL bClientPlaintextAuth;
        BOOL bClientUseSpnego;
+       BOOL bDebugPrefixTimestamp;
        BOOL bDebugHiresTimestamp;
        BOOL bDebugPid;
        BOOL bDebugUid;
+       BOOL bDebugClass;
        BOOL bEnableCoreFiles;
        BOOL bHostMSDfs;
        BOOL bUseMmap;
        BOOL bHostnameLookups;
        BOOL bUnixExtensions;
        BOOL bDisableNetbios;
-       BOOL bKernelChangeNotify;
-       BOOL bFamChangeNotify;
        BOOL bUseKerberosKeytab;
        BOOL bDeferSharingViolations;
        BOOL bEnablePrivileges;
        BOOL bASUSupport;
        BOOL bUsershareOwnerOnly;
        BOOL bUsershareAllowGuests;
+       BOOL bRegistryShares;
        int restrict_anonymous;
        int name_cache_timeout;
        int client_signing;
        int server_signing;
+       int client_ldap_sasl_wrapping;
        int iUsershareMaxShares;
+       int iIdmapCacheTime;
+       int iIdmapNegativeCacheTime;
 
        BOOL bResetOnZeroVC;
+       int iKeepalive;
        param_opt_struct *param_opt;
 } global;
 
@@ -345,12 +365,12 @@ typedef struct {
        char *szQueuepausecommand;
        char *szQueueresumecommand;
        char *szPrintername;
+       char *szPrintjobUsername;
        char *szDontdescend;
        char **szHostsallow;
        char **szHostsdeny;
        char *szMagicScript;
        char *szMagicOutput;
-       char *szMangledMap;
        char *szVetoFiles;
        char *szHideFiles;
        char *szVetoOplockFiles;
@@ -446,11 +466,13 @@ typedef struct {
        BOOL bAclCheckPermissions;
        BOOL bAclMapFullControl;
        BOOL bAclGroupControl;
+       BOOL bChangeNotify;
+       BOOL bKernelChangeNotify;
        int iallocation_roundup_size;
        int iAioReadSize;
        int iAioWriteSize;
        int iMap_readonly;
-       int ichange_notify_timeout;
+       int iDirectoryNameCacheSize;
        param_opt_struct *param_opt;
 
        char dummy[3];          /* for alignment */
@@ -484,12 +506,12 @@ static service sDefault = {
        NULL,                   /* szQueuepausecommand */
        NULL,                   /* szQueueresumecommand */
        NULL,                   /* szPrintername */
+       NULL,                   /* szPrintjobUsername */
        NULL,                   /* szDontdescend */
        NULL,                   /* szHostsallow */
        NULL,                   /* szHostsdeny */
        NULL,                   /* szMagicScript */
        NULL,                   /* szMagicOutput */
-       NULL,                   /* szMangledMap */
        NULL,                   /* szVetoFiles */
        NULL,                   /* szHideFiles */
        NULL,                   /* szVetoOplockFiles */
@@ -571,7 +593,7 @@ static service sDefault = {
        False,                  /* bInheritPerms */
        False,                  /* bInheritACLS */
        False,                  /* bInheritOwner */
-       True,                   /* bMSDfsRoot */
+       False,                  /* bMSDfsRoot */
        False,                  /* bUseClientDriver */
        True,                   /* bDefaultDevmode */
        False,                  /* bForcePrintername */
@@ -585,12 +607,17 @@ static service sDefault = {
        True,                   /* bAclCheckPermissions */
        True,                   /* bAclMapFullControl */
        False,                  /* bAclGroupControl */
+       True,                   /* bChangeNotify */
+       True,                   /* bKernelChangeNotify */
        SMB_ROUNDUP_ALLOCATION_SIZE,            /* iallocation_roundup_size */
        0,                      /* iAioReadSize */
        0,                      /* iAioWriteSize */
        MAP_READONLY_YES,       /* iMap_readonly */
-       60,                     /* ichange_notify_timeout = 1 minute default. */
-       
+#ifdef BROKEN_DIRECTORY_HANDLING
+       0,                      /* iDirectoryNameCacheSize */
+#else
+       100,                    /* iDirectoryNameCacheSize */
+#endif
        NULL,                   /* Parametric options */
 
        ""                      /* dummy */
@@ -667,6 +694,13 @@ static const struct enum_list enum_printing[] = {
        {-1, NULL}
 };
 
+static const struct enum_list enum_ldap_sasl_wrapping[] = {
+       {0, "plain"},
+       {ADS_AUTH_SASL_SIGN, "sign"},
+       {ADS_AUTH_SASL_SEAL, "seal"},
+       {-1, NULL}
+};
+
 static const struct enum_list enum_ldap_ssl[] = {
        {LDAP_SSL_OFF, "no"},
        {LDAP_SSL_OFF, "No"},
@@ -946,9 +980,11 @@ static struct parm_struct parm_table[] = {
        {"max log size", P_INTEGER, P_GLOBAL, &Globals.max_log_size, NULL, NULL, FLAG_ADVANCED}, 
        {"debug timestamp", P_BOOL, P_GLOBAL, &Globals.bTimestampLogs, NULL, NULL, FLAG_ADVANCED}, 
        {"timestamp logs", P_BOOL, P_GLOBAL, &Globals.bTimestampLogs, NULL, NULL, FLAG_ADVANCED}, 
+       {"debug prefix timestamp", P_BOOL, P_GLOBAL, &Globals.bDebugPrefixTimestamp, NULL, NULL, FLAG_ADVANCED}, 
        {"debug hires timestamp", P_BOOL, P_GLOBAL, &Globals.bDebugHiresTimestamp, NULL, NULL, FLAG_ADVANCED}, 
        {"debug pid", P_BOOL, P_GLOBAL, &Globals.bDebugPid, NULL, NULL, FLAG_ADVANCED}, 
        {"debug uid", P_BOOL, P_GLOBAL, &Globals.bDebugUid, NULL, NULL, FLAG_ADVANCED}, 
+       {"debug class", P_BOOL, P_GLOBAL, &Globals.bDebugClass, NULL, NULL, FLAG_ADVANCED},
        {"enable core files", P_BOOL, P_GLOBAL, &Globals.bEnableCoreFiles, NULL, NULL, FLAG_ADVANCED},
 
        {N_("Protocol Options"), P_SEP, P_SEPARATOR}, 
@@ -962,7 +998,6 @@ static struct parm_struct parm_table[] = {
        {"max protocol", P_ENUM, P_GLOBAL, &Globals.maxprotocol, NULL, enum_protocol, FLAG_ADVANCED}, 
        {"protocol", P_ENUM, P_GLOBAL, &Globals.maxprotocol, NULL, enum_protocol, FLAG_ADVANCED}, 
        {"min protocol", P_ENUM, P_GLOBAL, &Globals.minprotocol, NULL, enum_protocol, FLAG_ADVANCED}, 
-       {"read bmpx", P_BOOL, P_GLOBAL, &Globals.bReadbmpx, NULL, NULL, FLAG_ADVANCED}, 
        {"read raw", P_BOOL, P_GLOBAL, &Globals.bReadRaw, NULL, NULL, FLAG_ADVANCED}, 
        {"write raw", P_BOOL, P_GLOBAL, &Globals.bWriteRaw, NULL, NULL, FLAG_ADVANCED}, 
        {"disable netbios", P_BOOL, P_GLOBAL, &Globals.bDisableNetbios, NULL, NULL, FLAG_ADVANCED}, 
@@ -993,19 +1028,19 @@ static struct parm_struct parm_table[] = {
        {"client signing", P_ENUM, P_GLOBAL, &Globals.client_signing, NULL, enum_smb_signing_vals, FLAG_ADVANCED}, 
        {"server signing", P_ENUM, P_GLOBAL, &Globals.server_signing, NULL, enum_smb_signing_vals, FLAG_ADVANCED}, 
        {"client use spnego", P_BOOL, P_GLOBAL, &Globals.bClientUseSpnego, NULL, NULL, FLAG_ADVANCED}, 
-
+       {"client ldap sasl wrapping", P_ENUM, P_GLOBAL, &Globals.client_ldap_sasl_wrapping, NULL, enum_ldap_sasl_wrapping, FLAG_ADVANCED},
        {"enable asu support", P_BOOL, P_GLOBAL, &Globals.bASUSupport, NULL, NULL, FLAG_ADVANCED}, 
        {"svcctl list", P_LIST, P_GLOBAL, &Globals.szServicesList, NULL, NULL, FLAG_ADVANCED},
 
        {N_("Tuning Options"), P_SEP, P_SEPARATOR}, 
 
        {"block size", P_INTEGER, P_LOCAL, &sDefault.iBlock_size, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, 
-       {"change notify timeout", P_INTEGER, P_LOCAL, &sDefault.ichange_notify_timeout, NULL, NULL, FLAG_ADVANCED}, 
        {"deadtime", P_INTEGER, P_GLOBAL, &Globals.deadtime, NULL, NULL, FLAG_ADVANCED}, 
        {"getwd cache", P_BOOL, P_GLOBAL, &use_getwd_cache, NULL, NULL, FLAG_ADVANCED}, 
-       {"keepalive", P_INTEGER, P_GLOBAL, &keepalive, NULL, NULL, FLAG_ADVANCED}, 
-       {"kernel change notify", P_BOOL, P_GLOBAL, &Globals.bKernelChangeNotify, NULL, NULL, FLAG_ADVANCED}, 
-       {"fam change notify", P_BOOL, P_GLOBAL, &Globals.bFamChangeNotify, NULL, NULL, FLAG_ADVANCED},
+       {"keepalive", P_INTEGER, P_GLOBAL, &Globals.iKeepalive, NULL, NULL, FLAG_ADVANCED},
+       {"change notify", P_BOOL, P_LOCAL, &sDefault.bChangeNotify, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE },
+       {"directory name cache size", P_INTEGER, P_LOCAL, &sDefault.iDirectoryNameCacheSize, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE },
+       {"kernel change notify", P_BOOL, P_LOCAL, &sDefault.bKernelChangeNotify, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE },
 
        {"lpq cache time", P_INTEGER, P_GLOBAL, &Globals.lpqcachetime, NULL, NULL, FLAG_ADVANCED}, 
        {"max smbd processes", P_INTEGER, P_GLOBAL, &Globals.iMaxSmbdProcesses, NULL, NULL, FLAG_ADVANCED}, 
@@ -1014,7 +1049,6 @@ static struct parm_struct parm_table[] = {
        {"max disk size", P_INTEGER, P_GLOBAL, &Globals.maxdisksize, NULL, NULL, FLAG_ADVANCED}, 
        {"max open files", P_INTEGER, P_GLOBAL, &Globals.max_open_files, NULL, NULL, FLAG_ADVANCED}, 
        {"min print space", P_INTEGER, P_LOCAL, &sDefault.iMinPrintSpace, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT}, 
-       {"open files database hash size", P_INTEGER, P_GLOBAL, &Globals.open_files_db_hash_size, NULL, NULL, FLAG_ADVANCED}, 
 
        {"socket options", P_GSTRING, P_GLOBAL, user_socket_options, NULL, NULL, FLAG_ADVANCED}, 
        {"strict allocate", P_BOOL, P_LOCAL, &sDefault.bStrictAllocate, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE}, 
@@ -1026,6 +1060,9 @@ static struct parm_struct parm_table[] = {
        {"write cache size", P_INTEGER, P_LOCAL, &sDefault.iWriteCacheSize, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_DEPRECATED}, 
 
        {"name cache timeout", P_INTEGER, P_GLOBAL, &Globals.name_cache_timeout, NULL, NULL, FLAG_ADVANCED}, 
+       {"ctdbd socket", P_STRING, P_GLOBAL, &Globals.ctdbdSocket, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL}, 
+       {"cluster addresses", P_LIST, P_GLOBAL, &Globals.szClusterAddresses, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL}, 
+       {"clustering", P_BOOL, P_GLOBAL, &Globals.clustering, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL}, 
 
        {N_("Printing Options"), P_SEP, P_SEPARATOR}, 
 
@@ -1063,6 +1100,7 @@ static struct parm_struct parm_table[] = {
        {"use client driver", P_BOOL, P_LOCAL, &sDefault.bUseClientDriver, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT}, 
        {"default devmode", P_BOOL, P_LOCAL, &sDefault.bDefaultDevmode, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT}, 
        {"force printername", P_BOOL, P_LOCAL, &sDefault.bForcePrintername, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT}, 
+       {"printjob username", P_STRING, P_LOCAL, &sDefault.szPrintjobUsername, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
 
        {N_("Filename Handling"), P_SEP, P_SEPARATOR}, 
        {"mangling method", P_STRING, P_GLOBAL, &Globals.szManglingMethod, NULL, NULL, FLAG_ADVANCED}, 
@@ -1087,7 +1125,6 @@ static struct parm_struct parm_table[] = {
        {"map system", P_BOOL, P_LOCAL, &sDefault.bMap_system, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, 
        {"map readonly", P_ENUM, P_LOCAL, &sDefault.iMap_readonly, NULL, enum_map_readonly, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, 
        {"mangled names", P_BOOL, P_LOCAL, &sDefault.bMangledNames, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, 
-       {"mangled map", P_STRING, P_LOCAL, &sDefault.szMangledMap, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED }, 
        {"max stat cache size", P_INTEGER, P_GLOBAL, &Globals.iMaxStatCacheSize, NULL, NULL, FLAG_ADVANCED}, 
        {"stat cache", P_BOOL, P_GLOBAL, &Globals.bStatCache, NULL, NULL, FLAG_ADVANCED}, 
        {"store dos attributes", P_BOOL, P_LOCAL, &sDefault.bStoreDosAttributes, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, 
@@ -1149,7 +1186,6 @@ static struct parm_struct parm_table[] = {
        {"fake oplocks", P_BOOL, P_LOCAL, &sDefault.bFakeOplocks, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE}, 
        {"kernel oplocks", P_BOOL, P_GLOBAL, &Globals.bKernelOplocks, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL}, 
        {"locking", P_BOOL, P_LOCAL, &sDefault.bLocking, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, 
-       {"lock spin count", P_INTEGER, P_GLOBAL, &Globals.iLockSpinCount, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL}, 
        {"lock spin time", P_INTEGER, P_GLOBAL, &Globals.iLockSpinTime, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL}, 
 
        {"oplocks", P_BOOL, P_LOCAL, &sDefault.bOpLocks, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, 
@@ -1225,6 +1261,7 @@ static struct parm_struct parm_table[] = {
        {"root preexec close", P_BOOL, P_LOCAL, &sDefault.bRootpreexecClose, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE}, 
        {"root postexec", P_STRING, P_LOCAL, &sDefault.szRootPostExec, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT}, 
        {"available", P_BOOL, P_LOCAL, &sDefault.bAvailable, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT}, 
+       {"registry shares", P_BOOL, P_GLOBAL, &Globals.bRegistryShares, NULL, NULL, FLAG_ADVANCED},
        {"usershare allow guests", P_BOOL, P_GLOBAL, &Globals.bUsershareAllowGuests, NULL, NULL, FLAG_ADVANCED},
        {"usershare max shares", P_INTEGER, P_GLOBAL, &Globals.iUsershareMaxShares, NULL, NULL, FLAG_ADVANCED},
        {"usershare owner only", P_BOOL, P_GLOBAL, &Globals.bUsershareOwnerOnly, NULL, NULL, FLAG_ADVANCED}, 
@@ -1261,11 +1298,15 @@ static struct parm_struct parm_table[] = {
        {N_("Winbind options"), P_SEP, P_SEPARATOR}, 
 
        {"passdb expand explicit", P_BOOL, P_GLOBAL, &Globals.bPassdbExpandExplicit, NULL, NULL, FLAG_ADVANCED},
-       {"idmap backend", P_LIST, P_GLOBAL, &Globals.szIdmapBackend, NULL, NULL, FLAG_ADVANCED}, 
-       {"idmap uid", P_STRING, P_GLOBAL, &Globals.szIdmapUID, handle_idmap_uid, NULL, FLAG_ADVANCED}, 
-       {"winbind uid", P_STRING, P_GLOBAL, &Globals.szIdmapUID, handle_idmap_uid, NULL, FLAG_HIDE}, 
-       {"idmap gid", P_STRING, P_GLOBAL, &Globals.szIdmapGID, handle_idmap_gid, NULL, FLAG_ADVANCED}, 
-       {"winbind gid", P_STRING, P_GLOBAL, &Globals.szIdmapGID, handle_idmap_gid, NULL, FLAG_HIDE}, 
+       {"idmap domains", P_LIST, P_GLOBAL, &Globals.szIdmapDomains, NULL, NULL, FLAG_ADVANCED}, 
+       {"idmap backend", P_LIST, P_GLOBAL, &Globals.szIdmapBackend, NULL, NULL, FLAG_ADVANCED }, 
+       {"idmap alloc backend", P_STRING, P_GLOBAL, &Globals.szIdmapAllocBackend, NULL, NULL, FLAG_ADVANCED}, 
+       {"idmap cache time", P_INTEGER, P_GLOBAL, &Globals.iIdmapCacheTime, NULL, NULL, FLAG_ADVANCED}, 
+       {"idmap negative cache time", P_INTEGER, P_GLOBAL, &Globals.iIdmapNegativeCacheTime, NULL, NULL, FLAG_ADVANCED}, 
+       {"idmap uid", P_STRING, P_GLOBAL, &Globals.szIdmapUID, handle_idmap_uid, NULL, FLAG_ADVANCED }, 
+       {"winbind uid", P_STRING, P_GLOBAL, &Globals.szIdmapUID, handle_idmap_uid, NULL, FLAG_HIDE }, 
+       {"idmap gid", P_STRING, P_GLOBAL, &Globals.szIdmapGID, handle_idmap_gid, NULL, FLAG_ADVANCED }, 
+       {"winbind gid", P_STRING, P_GLOBAL, &Globals.szIdmapGID, handle_idmap_gid, NULL, FLAG_HIDE }, 
        {"template homedir", P_STRING, P_GLOBAL, &Globals.szTemplateHomedir, NULL, NULL, FLAG_ADVANCED}, 
        {"template shell", P_STRING, P_GLOBAL, &Globals.szTemplateShell, NULL, NULL, FLAG_ADVANCED}, 
        {"winbind separator", P_STRING, P_GLOBAL, &Globals.szWinbindSeparator, NULL, NULL, FLAG_ADVANCED}, 
@@ -1275,9 +1316,12 @@ static struct parm_struct parm_table[] = {
        {"winbind use default domain", P_BOOL, P_GLOBAL, &Globals.bWinbindUseDefaultDomain, NULL, NULL, FLAG_ADVANCED}, 
        {"winbind trusted domains only", P_BOOL, P_GLOBAL, &Globals.bWinbindTrustedDomainsOnly, NULL, NULL, FLAG_ADVANCED}, 
        {"winbind nested groups", P_BOOL, P_GLOBAL, &Globals.bWinbindNestedGroups, NULL, NULL, FLAG_ADVANCED}, 
+       {"winbind expand groups", P_INTEGER, P_GLOBAL, &Globals.winbind_expand_groups, NULL, NULL, FLAG_ADVANCED}, 
        {"winbind nss info", P_LIST, P_GLOBAL, &Globals.szWinbindNssInfo, NULL, NULL, FLAG_ADVANCED}, 
        {"winbind refresh tickets", P_BOOL, P_GLOBAL, &Globals.bWinbindRefreshTickets, NULL, NULL, FLAG_ADVANCED}, 
        {"winbind offline logon", P_BOOL, P_GLOBAL, &Globals.bWinbindOfflineLogon, NULL, NULL, FLAG_ADVANCED},
+       {"winbind normalize names", P_BOOL, P_GLOBAL, &Globals.bWinbindNormalizeNames, NULL, NULL, FLAG_ADVANCED},
+       {"winbind rpc only", P_BOOL, P_GLOBAL, &Globals.bWinbindRpcOnly, NULL, NULL, FLAG_ADVANCED},
 
        {NULL,  P_BOOL,  P_NONE,  NULL,  NULL,  NULL,  0}
 };
@@ -1401,6 +1445,7 @@ static void init_globals(BOOL first_time_only)
                                string_set((char **)parm_table[i].ptr, "");
 
                string_set(&sDefault.fstype, FSTYPE_STRING);
+               string_set(&sDefault.szPrintjobUsername, "%U");
 
                init_printer_values(&sDefault);
 
@@ -1497,23 +1542,22 @@ static void init_globals(BOOL first_time_only)
        Globals.serverSchannel = Auto;
        Globals.bReadRaw = True;
        Globals.bWriteRaw = True;
-       Globals.bReadbmpx = False;
        Globals.bNullPasswords = False;
        Globals.bObeyPamRestrictions = False;
        Globals.syslog = 1;
        Globals.bSyslogOnly = False;
        Globals.bTimestampLogs = True;
        string_set(&Globals.szLogLevel, "0");
+       Globals.bDebugPrefixTimestamp = False;
        Globals.bDebugHiresTimestamp = False;
        Globals.bDebugPid = False;
        Globals.bDebugUid = False;
+       Globals.bDebugClass = False;
        Globals.bEnableCoreFiles = True;
        Globals.max_ttl = 60 * 60 * 24 * 3;     /* 3 days default. */
        Globals.max_wins_ttl = 60 * 60 * 24 * 6;        /* 6 days default. */
        Globals.min_wins_ttl = 60 * 60 * 6;     /* 6 hours default. */
        Globals.machine_password_timeout = 60 * 60 * 24 * 7;    /* 7 days default. */
-       Globals.bKernelChangeNotify = True;     /* On if we have it. */
-       Globals.bFamChangeNotify = True;        /* On if we have it. */
        Globals.lm_announce = 2;        /* = Auto: send only if LM clients found */
        Globals.lm_interval = 60;
        Globals.announce_as = ANNOUNCE_AS_NT_SERVER;
@@ -1534,19 +1578,18 @@ static void init_globals(BOOL first_time_only)
        Globals.bNTPipeSupport = True;  /* Do NT pipes by default. */
        Globals.bNTStatusSupport = True; /* Use NT status by default. */
        Globals.bStatCache = True;      /* use stat cache by default */
-       Globals.iMaxStatCacheSize = 0;  /* unlimited size in kb by default. */
+       Globals.iMaxStatCacheSize = 1024; /* one Meg by default. */
        Globals.restrict_anonymous = 0;
-       Globals.bClientLanManAuth = True;       /* Do use the LanMan hash if it is available */
-       Globals.bClientPlaintextAuth = True;    /* Do use a plaintext password if is requested by the server */
-       Globals.bLanmanAuth = True;     /* Do use the LanMan hash if it is available */
-       Globals.bNTLMAuth = True;       /* Do use NTLMv1 if it is available (otherwise NTLMv2) */
+       Globals.bClientLanManAuth = False;      /* Do NOT use the LanMan hash if it is available */
+       Globals.bClientPlaintextAuth = False;   /* Do NOT use a plaintext password even if is requested by the server */
+       Globals.bLanmanAuth = False;    /* Do NOT use the LanMan hash, even if it is supplied */
+       Globals.bNTLMAuth = True;       /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
        Globals.bClientNTLMv2Auth = False; /* Client should not use NTLMv2, as we can't tell that the server supports it. */
        /* Note, that we will use NTLM2 session security (which is different), if it is available */
 
        Globals.map_to_guest = 0;       /* By Default, "Never" */
        Globals.oplock_break_wait_time = 0;     /* By Default, 0 msecs. */
        Globals.enhanced_browsing = True; 
-       Globals.iLockSpinCount = 0; /* Unused. */
        Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
 #ifdef MMAP_BLACKLIST
        Globals.bUseMmap = False;
@@ -1612,19 +1655,28 @@ static void init_globals(BOOL first_time_only)
        string_set(&Globals.szTemplateShell, "/bin/false");
        string_set(&Globals.szTemplateHomedir, "/home/%D/%U");
        string_set(&Globals.szWinbindSeparator, "\\");
+
        string_set(&Globals.szCupsServer, "");
        string_set(&Globals.szIPrintServer, "");
 
+       string_set(&Globals.ctdbdSocket, "");
+       Globals.szClusterAddresses = NULL;
+       Globals.clustering = False;
+
        Globals.winbind_cache_time = 300;       /* 5 minutes */
        Globals.bWinbindEnumUsers = False;
        Globals.bWinbindEnumGroups = False;
        Globals.bWinbindUseDefaultDomain = False;
        Globals.bWinbindTrustedDomainsOnly = False;
        Globals.bWinbindNestedGroups = True;
+       Globals.winbind_expand_groups = 1;
        Globals.szWinbindNssInfo = str_list_make("template", NULL);
        Globals.bWinbindRefreshTickets = False;
        Globals.bWinbindOfflineLogon = False;
 
+       Globals.iIdmapCacheTime = 900; /* 15 minutes by default */
+       Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
+
        Globals.bPassdbExpandExplicit = False;
 
        Globals.name_cache_timeout = 660; /* In seconds */
@@ -1652,33 +1704,11 @@ static void init_globals(BOOL first_time_only)
        Globals.bUsershareOwnerOnly = True;
        /* By default disallow guest access to usershares. */
        Globals.bUsershareAllowGuests = False;
-}
-
-static TALLOC_CTX *lp_talloc;
 
-/******************************************************************* a
- Free up temporary memory - called from the main loop.
-********************************************************************/
+       Globals.iKeepalive = DEFAULT_KEEPALIVE;
 
-void lp_TALLOC_FREE(void)
-{
-       if (!lp_talloc)
-               return;
-       TALLOC_FREE(lp_talloc);
-       lp_talloc = NULL;
-}
-
-TALLOC_CTX *tmp_talloc_ctx(void)
-{
-       if (lp_talloc == NULL) {
-               lp_talloc = talloc_init("tmp_talloc_ctx");
-       }
-
-       if (lp_talloc == NULL) {
-               smb_panic("Could not create temporary talloc context\n");
-       }
-
-       return lp_talloc;
+       /* By default no shares out of the registry */
+       Globals.bRegistryShares = False;
 }
 
 /*******************************************************************
@@ -1700,9 +1730,6 @@ static char *lp_string(const char *s)
        DEBUG(10, ("lp_string(%s)\n", s));
 #endif
 
-       if (!lp_talloc)
-               lp_talloc = talloc_init("lp_talloc");
-
        tmpstr = alloc_sub_basic(get_current_username(),
                                 current_user_info.domain, s);
        if (trim_char(tmpstr, '\"', '\"')) {
@@ -1712,7 +1739,7 @@ static char *lp_string(const char *s)
                                                 current_user_info.domain, s);
                }
        }
-       ret = talloc_strdup(lp_talloc, tmpstr);
+       ret = talloc_strdup(talloc_tos(), tmpstr);
        SAFE_FREE(tmpstr);
                        
        return (ret);
@@ -1749,6 +1776,8 @@ static char *lp_string(const char *s)
 
 #define FN_LOCAL_PARM_BOOL(fn_name,val) \
  BOOL fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
+#define FN_LOCAL_PARM_INTEGER(fn_name,val) \
+ int fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
 #define FN_LOCAL_PARM_STRING(fn_name,val) \
  char *fn_name(const struct share_params *p) {return(lp_string((LP_SNUM_OK(p->service) && ServicePtrs[(p->service)]->val) ? ServicePtrs[(p->service)]->val : sDefault.val));}
 #define FN_LOCAL_CHAR(fn_name,val) \
@@ -1803,7 +1832,48 @@ FN_GLOBAL_STRING(lp_socket_address, &Globals.szSocketAddress)
 FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
 static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
 FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
-FN_GLOBAL_STRING(lp_passdb_backend, &Globals.szPassdbBackend)
+/* FN_GLOBAL_STRING(lp_passdb_backend, &Globals.szPassdbBackend)
+ * lp_passdb_backend() should be replace by the this macro again after
+ * some releases.
+ * */
+const char *lp_passdb_backend(void)
+{
+       char *delim, *quote;
+
+       delim = strchr( Globals.szPassdbBackend, ' ');
+       /* no space at all */
+       if (delim == NULL) {
+               goto out;
+       }
+
+       quote = strchr(Globals.szPassdbBackend, '"');
+       /* no quote char or non in the first part */
+       if (quote == NULL || quote > delim) {
+               *delim = '\0';
+               goto warn;
+       }
+
+       quote = strchr(quote+1, '"');
+       if (quote == NULL) {
+               DEBUG(0, ("WARNING: Your 'passdb backend' configuration is invalid due to a missing second \" char.\n"));
+               goto out;
+       } else if (*(quote+1) == '\0') {
+               /* space, fitting quote char, and one backend only */
+               goto out;
+       } else {
+               /* terminate string after the fitting quote char */
+               *(quote+1) = '\0';
+       }
+
+warn:
+       DEBUG(0, ("WARNING: Your 'passdb backend' configuration includes multiple backends.  This\n"
+               "is deprecated since Samba 3.0.23.  Please check WHATSNEW.txt or the section 'Passdb\n"
+               "Changes' from the ChangeNotes as part of the Samba HOWTO collection.  Only the first\n"
+               "backend (%s) is used.  The rest is ignored.\n", Globals.szPassdbBackend));
+
+out:
+       return Globals.szPassdbBackend;
+}
 FN_GLOBAL_LIST(lp_preload_modules, &Globals.szPreloadModules)
 FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
 FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
@@ -1835,10 +1905,18 @@ FN_GLOBAL_BOOL(lp_winbind_enum_groups, &Globals.bWinbindEnumGroups)
 FN_GLOBAL_BOOL(lp_winbind_use_default_domain, &Globals.bWinbindUseDefaultDomain)
 FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, &Globals.bWinbindTrustedDomainsOnly)
 FN_GLOBAL_BOOL(lp_winbind_nested_groups, &Globals.bWinbindNestedGroups)
+FN_GLOBAL_INTEGER(lp_winbind_expand_groups, &Globals.winbind_expand_groups)
 FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, &Globals.bWinbindRefreshTickets)
 FN_GLOBAL_BOOL(lp_winbind_offline_logon, &Globals.bWinbindOfflineLogon)
-
-FN_GLOBAL_LIST(lp_idmap_backend, &Globals.szIdmapBackend)
+FN_GLOBAL_BOOL(lp_winbind_normalize_names, &Globals.bWinbindNormalizeNames)
+FN_GLOBAL_BOOL(lp_winbind_rpc_only, &Globals.bWinbindRpcOnly)
+
+FN_GLOBAL_LIST(lp_idmap_domains, &Globals.szIdmapDomains)
+FN_GLOBAL_LIST(lp_idmap_backend, &Globals.szIdmapBackend) /* deprecated */
+FN_GLOBAL_STRING(lp_idmap_alloc_backend, &Globals.szIdmapAllocBackend)
+FN_GLOBAL_INTEGER(lp_idmap_cache_time, &Globals.iIdmapCacheTime)
+FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, &Globals.iIdmapNegativeCacheTime)
+FN_GLOBAL_INTEGER(lp_keepalive, &Globals.iKeepalive)
 FN_GLOBAL_BOOL(lp_passdb_expand_explicit, &Globals.bPassdbExpandExplicit)
 
 FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix)
@@ -1858,6 +1936,7 @@ FN_GLOBAL_LIST(lp_usershare_prefix_deny_list, &Globals.szUsersharePrefixDenyList
 
 FN_GLOBAL_LIST(lp_eventlog_list, &Globals.szEventLogs)
 
+FN_GLOBAL_BOOL(lp_registry_shares, &Globals.bRegistryShares)
 FN_GLOBAL_BOOL(lp_usershare_allow_guests, &Globals.bUsershareAllowGuests)
 FN_GLOBAL_BOOL(lp_usershare_owner_only, &Globals.bUsershareOwnerOnly)
 FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
@@ -1870,7 +1949,6 @@ FN_GLOBAL_BOOL(lp_wins_proxy, &Globals.bWINSproxy)
 FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
 FN_GLOBAL_BOOL(lp_domain_logons, &Globals.bDomainLogons)
 FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
-FN_GLOBAL_BOOL(lp_readbmpx, &Globals.bReadbmpx)
 FN_GLOBAL_BOOL(lp_readraw, &Globals.bReadRaw)
 FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
 FN_GLOBAL_BOOL(lp_writeraw, &Globals.bWriteRaw)
@@ -1882,9 +1960,11 @@ FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel)
 FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
 FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
 FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
+FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, &Globals.bDebugPrefixTimestamp)
 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
 FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
+FN_GLOBAL_BOOL(lp_debug_class, &Globals.bDebugClass)
 FN_GLOBAL_BOOL(lp_enable_core_files, &Globals.bEnableCoreFiles)
 FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
 FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)
@@ -1913,8 +1993,8 @@ FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions)
 FN_GLOBAL_BOOL(lp_use_spnego, &Globals.bUseSpnego)
 FN_GLOBAL_BOOL(lp_client_use_spnego, &Globals.bClientUseSpnego)
 FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
-FN_GLOBAL_BOOL(lp_kernel_change_notify, &Globals.bKernelChangeNotify)
-FN_GLOBAL_BOOL(lp_fam_change_notify, &Globals.bFamChangeNotify)
+FN_LOCAL_PARM_BOOL(lp_change_notify, bChangeNotify)
+FN_LOCAL_PARM_BOOL(lp_kernel_change_notify, bKernelChangeNotify)
 FN_GLOBAL_BOOL(lp_use_kerberos_keytab, &Globals.bUseKerberosKeytab)
 FN_GLOBAL_BOOL(lp_defer_sharing_violations, &Globals.bDeferSharingViolations)
 FN_GLOBAL_BOOL(lp_enable_privileges, &Globals.bEnablePrivileges)
@@ -1947,7 +2027,6 @@ FN_GLOBAL_INTEGER(lp_lm_interval, &Globals.lm_interval)
 FN_GLOBAL_INTEGER(lp_machine_password_timeout, &Globals.machine_password_timeout)
 FN_GLOBAL_INTEGER(lp_map_to_guest, &Globals.map_to_guest)
 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
-FN_GLOBAL_INTEGER(lp_lock_spin_count, &Globals.iLockSpinCount)
 FN_GLOBAL_INTEGER(lp_lock_spin_time, &Globals.iLockSpinTime)
 FN_GLOBAL_INTEGER(lp_usershare_max_shares, &Globals.iUsershareMaxShares)
 
@@ -1967,6 +2046,9 @@ FN_GLOBAL_LIST(lp_svcctl_list, &Globals.szServicesList)
 FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
 FN_GLOBAL_STRING(lp_cups_server, &Globals.szCupsServer)
 FN_GLOBAL_STRING(lp_iprint_server, &Globals.szIPrintServer)
+FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, &Globals.ctdbdSocket)
+FN_GLOBAL_LIST(lp_cluster_addresses, &Globals.szClusterAddresses)
+FN_GLOBAL_BOOL(lp_clustering, &Globals.clustering);
 FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
 FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
 FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
@@ -1975,6 +2057,7 @@ FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
 FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
 FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
 static FN_LOCAL_STRING(_lp_printername, szPrintername)
+FN_LOCAL_CONST_STRING(lp_printjob_username, szPrintjobUsername)
 FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
 FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
 FN_LOCAL_STRING(lp_magicscript, szMagicScript)
@@ -1989,7 +2072,6 @@ FN_LOCAL_STRING(lp_fstype, fstype)
 FN_LOCAL_LIST(lp_vfs_objects, szVfsObjects)
 FN_LOCAL_STRING(lp_msdfs_proxy, szMSDfsProxy)
 static FN_LOCAL_STRING(lp_volume, volume)
-FN_LOCAL_PARM_STRING(lp_mangled_map, szMangledMap)
 FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
 FN_LOCAL_STRING(lp_hide_files, szHideFiles)
 FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
@@ -2016,9 +2098,9 @@ FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
 FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
 FN_LOCAL_BOOL(lp_store_dos_attributes, bStoreDosAttributes)
 FN_LOCAL_BOOL(lp_dmapi_support, bDmapiSupport)
-FN_LOCAL_BOOL(lp_locking, bLocking)
-FN_LOCAL_INTEGER(lp_strict_locking, iStrictLocking)
-FN_LOCAL_BOOL(lp_posix_locking, bPosixLocking)
+FN_LOCAL_PARM_BOOL(lp_locking, bLocking)
+FN_LOCAL_PARM_INTEGER(lp_strict_locking, iStrictLocking)
+FN_LOCAL_PARM_BOOL(lp_posix_locking, bPosixLocking)
 FN_LOCAL_BOOL(lp_share_modes, bShareModes)
 FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
 FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
@@ -2076,7 +2158,7 @@ FN_LOCAL_INTEGER(lp_allocation_roundup_size, iallocation_roundup_size)
 FN_LOCAL_INTEGER(lp_aio_read_size, iAioReadSize)
 FN_LOCAL_INTEGER(lp_aio_write_size, iAioWriteSize)
 FN_LOCAL_INTEGER(lp_map_readonly, iMap_readonly)
-FN_LOCAL_INTEGER(lp_change_notify_timeout, ichange_notify_timeout)
+FN_LOCAL_INTEGER(lp_directory_name_cache_size, iDirectoryNameCacheSize)
 FN_LOCAL_CHAR(lp_magicchar, magic_char)
 FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
 FN_GLOBAL_LIST(lp_winbind_nss_info, &Globals.szWinbindNssInfo)
@@ -2084,22 +2166,26 @@ FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase)
 FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
 FN_GLOBAL_INTEGER(lp_client_signing, &Globals.client_signing)
 FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing)
+FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrapping)
 
 /* local prototypes */
 
 static int map_parameter(const char *pszParmName);
+static int map_parameter_canonical(const char *pszParmName, BOOL *inverse);
 static BOOL set_boolean(BOOL *pb, const char *pszParmValue);
+static const char *get_boolean(BOOL bool_value);
 static int getservicebyname(const char *pszServiceName,
                            service * pserviceDest);
 static void copy_service(service * pserviceDest,
                         service * pserviceSource, BOOL *pcopymapDest);
-static BOOL service_ok(int iService);
 static BOOL do_parameter(const char *pszParmName, const char *pszParmValue);
 static BOOL do_section(const char *pszSectionName);
 static void init_copymap(service * pservice);
 static BOOL hash_a_service(const char *name, int number);
 static void free_service_byindex(int iService);
 static char * canonicalize_servicename(const char *name);
+static void show_parameter(int parmIndex);
+static BOOL is_synonym_of(int parm1, int parm2, BOOL *inverse);
 
 /* This is a helper function for parametrical options support. */
 /* It returns a pointer to parametrical option value if it exists or NULL otherwise */
@@ -2166,7 +2252,7 @@ static int lp_int(const char *s)
                return (-1);
        }
 
-       return atoi(s); 
+       return (int)strtol(s, NULL, 0);
 }
 
 /*******************************************************************
@@ -2180,7 +2266,7 @@ static unsigned long lp_ulong(const char *s)
                return (0);
        }
 
-       return strtoul(s, NULL, 10);
+       return strtoul(s, NULL, 0);
 }
 
 /*******************************************************************
@@ -2232,6 +2318,7 @@ static int lp_enum(const char *s,const struct enum_list *_enum)
  * lp_parm_string is only used to let old modules find this symbol
  */
 #undef lp_parm_string
+ char *lp_parm_string(const char *servicename, const char *type, const char *option);
  char *lp_parm_string(const char *servicename, const char *type, const char *option)
 {
        return lp_parm_talloc_string(lp_servicenumber(servicename), type, option, NULL);
@@ -2239,7 +2326,7 @@ static int lp_enum(const char *s,const struct enum_list *_enum)
 
 /* Return parametric option from a given service. Type is a part of option before ':' */
 /* Parametric option has following syntax: 'Type: option = value' */
-/* the returned value is talloced in lp_talloc */
+/* the returned value is talloced on the talloc_tos() */
 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
 {
        param_opt_struct *data = get_parametrics(snum, type, option);
@@ -2604,6 +2691,10 @@ BOOL lp_add_home(const char *pszHomename, int iDefaultService,
 
 int lp_add_service(const char *pszService, int iDefaultService)
 {
+       if (iDefaultService < 0) {
+               return add_a_service(&sDefault, pszService);
+       }
+
        return (add_a_service(ServicePtrs[iDefaultService], pszService));
 }
 
@@ -2677,6 +2768,125 @@ BOOL lp_add_printer(const char *pszPrintername, int iDefaultService)
        return (True);
 }
 
+
+/***************************************************************************
+ Check whether the given parameter name is valid.
+ Parametric options (names containing a colon) are considered valid.
+***************************************************************************/
+
+BOOL lp_parameter_is_valid(const char *pszParmName)
+{
+       return ((map_parameter(pszParmName) != -1) ||
+               (strchr(pszParmName, ':') != NULL));
+}
+
+/***************************************************************************
+ Check whether the given name is the name of a global parameter.
+ Returns True for strings belonging to parameters of class
+ P_GLOBAL, False for all other strings, also for parametric options
+ and strings not belonging to any option.
+***************************************************************************/
+
+BOOL lp_parameter_is_global(const char *pszParmName)
+{
+       int num = map_parameter(pszParmName);
+
+       if (num >= 0) {
+               return (parm_table[num].p_class == P_GLOBAL);
+       }
+
+       return False;
+}
+
+/**************************************************************************
+ Check whether the given name is the canonical name of a parameter.
+ Returns False if it is not a valid parameter Name.
+ For parametric options, True is returned.
+**************************************************************************/
+
+BOOL lp_parameter_is_canonical(const char *parm_name)
+{
+       if (!lp_parameter_is_valid(parm_name)) {
+               return False;
+       }
+
+       return (map_parameter(parm_name) ==
+               map_parameter_canonical(parm_name, NULL));
+}
+
+/**************************************************************************
+ Determine the canonical name for a parameter.
+ Indicate when it is an inverse (boolean) synonym instead of a
+ "usual" synonym.
+**************************************************************************/
+
+BOOL lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
+                              BOOL *inverse)
+{
+       int num;
+
+       if (!lp_parameter_is_valid(parm_name)) {
+               *canon_parm = NULL;
+               return False;
+       }
+
+       num = map_parameter_canonical(parm_name, inverse);
+       if (num < 0) {
+               /* parametric option */
+               *canon_parm = parm_name;
+       } else {
+               *canon_parm = parm_table[num].label;
+       }
+
+       return True;
+
+}
+
+/**************************************************************************
+ Determine the canonical name for a parameter.
+ Turn the value given into the inverse boolean expression when
+ the synonym is an invers boolean synonym.
+
+ Return True if parm_name is a valid parameter name and
+ in case it is an invers boolean synonym, if the val string could
+ successfully be converted to the reverse bool.
+ Return false in all other cases.
+**************************************************************************/
+
+BOOL lp_canonicalize_parameter_with_value(const char *parm_name,
+                                         const char *val,
+                                         const char **canon_parm,
+                                         const char **canon_val)
+{
+       int num;
+       BOOL inverse;
+
+       if (!lp_parameter_is_valid(parm_name)) {
+               *canon_parm = NULL;
+               *canon_val = NULL;
+               return False;
+       }
+
+       num = map_parameter_canonical(parm_name, &inverse);
+       if (num < 0) {
+               /* parametric option */
+               *canon_parm = parm_name;
+               *canon_val = val;
+       } else {
+               *canon_parm = parm_table[num].label;
+               if (inverse) {
+                       if (!lp_invert_boolean(val, canon_val)) {
+                               *canon_val = NULL;
+                               return False;
+                       }
+               } else {
+                       *canon_val = val;
+               }
+       }
+
+       return True;
+}
+
 /***************************************************************************
  Map a parameter's string representation to something we can use. 
  Returns False if the parameter string is not recognised, else TRUE.
@@ -2703,14 +2913,75 @@ static int map_parameter(const char *pszParmName)
 }
 
 /***************************************************************************
- Show all parameter's name, type, [values,] and flags.
+ Map a parameter's string representation to the index of the canonical
+ form of the parameter (it might be a synonym).
+ Returns -1 if the parameter string is not recognised.
 ***************************************************************************/
 
-void show_parameter_list(void)
+static int map_parameter_canonical(const char *pszParmName, BOOL *inverse)
 {
-       int classIndex, parmIndex, enumIndex, flagIndex;
+       int parm_num, canon_num;
+       BOOL loc_inverse = False;
+
+       parm_num = map_parameter(pszParmName);
+       if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
+               /* invalid, parametric or no canidate for synonyms ... */
+               goto done;
+       }
+
+       for (canon_num = 0; parm_table[canon_num].label; canon_num++) {
+               if (is_synonym_of(parm_num, canon_num, &loc_inverse)) {
+                       parm_num = canon_num;
+                       goto done;
+               }
+       }
+
+done:
+       if (inverse != NULL) {
+               *inverse = loc_inverse;
+       }
+       return parm_num;
+}
+
+/***************************************************************************
+ return true if parameter number parm1 is a synonym of parameter
+ number parm2 (parm2 being the principal name).
+ set inverse to True if parm1 is P_BOOLREV and parm2 is P_BOOL,
+ False otherwise.
+***************************************************************************/
+
+static BOOL is_synonym_of(int parm1, int parm2, BOOL *inverse)
+{
+       if ((parm_table[parm1].ptr == parm_table[parm2].ptr) &&
+           (parm_table[parm1].flags & FLAG_HIDE) &&
+           !(parm_table[parm2].flags & FLAG_HIDE))
+       {
+               if (inverse != NULL) {
+                       if ((parm_table[parm1].type == P_BOOLREV) &&
+                           (parm_table[parm2].type == P_BOOL))
+                       {
+                               *inverse = True;
+                       } else {
+                               *inverse = False;
+                       }
+               }
+               return True;
+       }
+       return False;
+}
+
+/***************************************************************************
+ Show one parameter's name, type, [values,] and flags.
+ (helper functions for show_parameter_list)
+***************************************************************************/
+
+static void show_parameter(int parmIndex)
+{
+       int enumIndex, flagIndex;
+       int parmIndex2;
        BOOL hadFlag;
-       const char *section_names[] = { "local", "global", NULL};
+       BOOL hadSyn;
+       BOOL inverse;
        const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
                "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING", "P_GSTRING",
                "P_UGSTRING", "P_ENUM", "P_SEP"};
@@ -2721,35 +2992,68 @@ void show_parameter_list(void)
                "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
                "FLAG_DEPRECATED", "FLAG_HIDE", "FLAG_DOS_STRING", NULL};
 
-       for ( classIndex=0; section_names[classIndex]; classIndex++) {
+       printf("%s=%s", parm_table[parmIndex].label,
+              type[parm_table[parmIndex].type]);
+       if (parm_table[parmIndex].type == P_ENUM) {
+               printf(",");
+               for (enumIndex=0;
+                    parm_table[parmIndex].enum_list[enumIndex].name;
+                    enumIndex++)
+               {
+                       printf("%s%s",
+                              enumIndex ? "|" : "",
+                              parm_table[parmIndex].enum_list[enumIndex].name);
+               }
+       }
+       printf(",");
+       hadFlag = False;
+       for (flagIndex=0; flag_names[flagIndex]; flagIndex++) {
+               if (parm_table[parmIndex].flags & flags[flagIndex]) {
+                       printf("%s%s",
+                               hadFlag ? "|" : "",
+                               flag_names[flagIndex]);
+                       hadFlag = True;
+               }
+       }
+
+       /* output synonyms */
+       hadSyn = False;
+       for (parmIndex2=0; parm_table[parmIndex2].label; parmIndex2++) {
+               if (is_synonym_of(parmIndex, parmIndex2, &inverse)) {
+                       printf(" (%ssynonym of %s)", inverse ? "inverse " : "",
+                              parm_table[parmIndex2].label);
+               } else if (is_synonym_of(parmIndex2, parmIndex, &inverse)) {
+                       if (!hadSyn) {
+                               printf(" (synonyms: ");
+                               hadSyn = True;
+                       } else {
+                               printf(", ");
+                       }
+                       printf("%s%s", parm_table[parmIndex2].label,
+                              inverse ? "[i]" : "");
+               }
+       }
+       if (hadSyn) {
+               printf(")");
+       }
+
+       printf("\n");
+}
+
+/***************************************************************************
+ Show all parameter's name, type, [values,] and flags.
+***************************************************************************/
+
+void show_parameter_list(void)
+{
+       int classIndex, parmIndex;
+       const char *section_names[] = { "local", "global", NULL};
+
+       for (classIndex=0; section_names[classIndex]; classIndex++) {
                printf("[%s]\n", section_names[classIndex]);
                for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) {
                        if (parm_table[parmIndex].p_class == classIndex) {
-                               printf("%s=%s", 
-                                       parm_table[parmIndex].label,
-                                       type[parm_table[parmIndex].type]);
-                               switch (parm_table[parmIndex].type) {
-                               case P_ENUM:
-                                       printf(",");
-                                       for (enumIndex=0; parm_table[parmIndex].enum_list[enumIndex].name; enumIndex++)
-                                               printf("%s%s",
-                                                       enumIndex ? "|" : "",
-                                                       parm_table[parmIndex].enum_list[enumIndex].name);
-                                       break;
-                               default:
-                                       break;
-                               }
-                               printf(",");
-                               hadFlag = False;
-                               for ( flagIndex=0; flag_names[flagIndex]; flagIndex++ ) {
-                                       if (parm_table[parmIndex].flags & flags[flagIndex]) {
-                                               printf("%s%s",
-                                                       hadFlag ? "|" : "",
-                                                       flag_names[flagIndex]);
-                                               hadFlag = True;
-                                       }
-                               }
-                               printf("\n");
+                               show_parameter(parmIndex);
                        }
                }
        }
@@ -2764,25 +3068,90 @@ void show_parameter_list(void)
 static BOOL set_boolean(BOOL *pb, const char *pszParmValue)
 {
        BOOL bRetval;
+       BOOL value;
 
        bRetval = True;
+       value = False;
        if (strwicmp(pszParmValue, "yes") == 0 ||
            strwicmp(pszParmValue, "true") == 0 ||
            strwicmp(pszParmValue, "1") == 0)
-               *pb = True;
+               value = True;
        else if (strwicmp(pszParmValue, "no") == 0 ||
                    strwicmp(pszParmValue, "False") == 0 ||
                    strwicmp(pszParmValue, "0") == 0)
-               *pb = False;
+               value = False;
        else {
-               DEBUG(0,
+               DEBUG(2,
                      ("ERROR: Badly formed boolean in configuration file: \"%s\".\n",
                       pszParmValue));
                bRetval = False;
        }
+
+       if ((pb != NULL) && (bRetval != False)) {
+               *pb = value;
+       }
+
        return (bRetval);
 }
 
+
+/***************************************************************************
+ Check if a given string correctly represents a boolean value.
+***************************************************************************/
+
+BOOL lp_string_is_valid_boolean(const char *parm_value)
+{
+       return set_boolean(NULL, parm_value);
+}
+
+/***************************************************************************
+ Get the standard string representation of a boolean value ("yes" or "no")
+***************************************************************************/
+
+static const char *get_boolean(BOOL bool_value)
+{
+       static const char *yes_str = "yes";
+       static const char *no_str = "no";
+
+       return (bool_value ? yes_str : no_str);
+}
+
+/***************************************************************************
+ Provide the string of the negated boolean value associated to the boolean
+ given as a string. Returns False if the passed string does not correctly
+ represent a boolean.
+***************************************************************************/
+
+BOOL lp_invert_boolean(const char *str, const char **inverse_str)
+{
+       BOOL val;
+
+       if (!set_boolean(&val, str)) {
+               return False;
+       }
+
+       *inverse_str = get_boolean(!val);
+       return True;
+}
+
+/***************************************************************************
+ Provide the canonical string representation of a boolean value given
+ as a string. Return True on success, False if the string given does
+ not correctly represent a boolean.
+***************************************************************************/
+
+BOOL lp_canonicalize_boolean(const char *str, const char**canon_str)
+{
+       BOOL val;
+
+       if (!set_boolean(&val, str)) {
+               return False;
+       }
+
+       *canon_str = get_boolean(val);
+       return True;
+}
+
 /***************************************************************************
 Find a service by name. Otherwise works like get_service.
 ***************************************************************************/
@@ -2908,7 +3277,7 @@ Check a service for consistency. Return False if the service is in any way
 incomplete or faulty, else True.
 ***************************************************************************/
 
-static BOOL service_ok(int iService)
+BOOL service_ok(int iService)
 {
        BOOL bRetval;
 
@@ -2941,7 +3310,7 @@ static BOOL service_ok(int iService)
                ServicePtrs[iService]->bAvailable = False;
        }
 
-       /* If a service is flagged unavailable, log the fact at level 0. */
+       /* If a service is flagged unavailable, log the fact at level 1. */
        if (!ServicePtrs[iService]->bAvailable)
                DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
                          ServicePtrs[iService]->szService));
@@ -2949,6 +3318,244 @@ static BOOL service_ok(int iService)
        return (bRetval);
 }
 
+/*
+ * lp_regdb_open - regdb helper function 
+ *
+ * this should be considered an interim solution that becomes
+ * superfluous once the registry code has been rewritten
+ * do allow use of the tdb portion of the registry alone.
+ *
+ * in the meanwhile this provides a lean access
+ * to the registry globals.
+ */
+
+static struct tdb_wrap *lp_regdb_open(void)
+{
+       struct tdb_wrap *reg_tdb = NULL;
+       const char *vstring = "INFO/version";
+       uint32 vers_id;
+
+       become_root();
+       reg_tdb = tdb_wrap_open(NULL, lock_path("registry.tdb"), 0, 
+                               REG_TDB_FLAGS, O_RDWR, 0600);
+       unbecome_root();
+       if (!reg_tdb) {
+               DEBUG(1, ("lp_regdb_open: failed to open %s: %s\n",
+                        lock_path("registry.tdb"), strerror(errno)));
+               goto done;
+       }
+       else {
+               DEBUG(10, ("lp_regdb_open: reg tdb opened.\n"));
+       }
+
+       vers_id = tdb_fetch_int32(reg_tdb->tdb, vstring);
+       if (vers_id != REGVER_V1) {
+               DEBUG(10, ("lp_regdb_open: INFO: registry tdb %s has wrong "
+                         "INFO/version (got %d, expected %d)\n",
+                         lock_path("registry.tdb"), vers_id, REGVER_V1));
+               /* this is apparently not implemented in the tdb */
+       }
+
+done:
+       return reg_tdb;
+}
+
+/*
+ * process_registry_globals
+ *
+ * this is the interim version of process_registry globals
+ *
+ * until we can do it as we would like using the api and only
+ * using the tdb portion of the registry (see below),
+ * this just provides the needed functionality of regdb_fetch_values
+ * and regdb_unpack_values, circumventing any fancy stuff, to
+ * give us access to the registry globals.
+ */
+static BOOL process_registry_globals(BOOL (*pfunc)(const char *, const char *))
+{
+       BOOL ret = False;
+       struct tdb_wrap *reg_tdb = NULL;
+       WERROR err;
+       char *keystr;
+       TDB_DATA data;
+       /* vars for the tdb unpack loop */
+       int len = 0;
+       int i;
+       int buflen;
+       uint8 *buf;
+       uint32 type;
+       uint32 size;
+       uint32 num_values = 0;
+       uint8 *data_p;
+       pstring valname;
+       char * valstr;
+       struct registry_value *value = NULL;
+
+       include_registry_globals = True;
+
+       ZERO_STRUCT(data);
+
+       reg_tdb = lp_regdb_open();
+       if (!reg_tdb) {
+               DEBUG(1, ("Error opening the registry!\n"));
+               goto done;
+       }
+
+       /* reg_tdb is from now on used as talloc ctx.
+        * freeing it closes the tdb (if refcount is 0) */
+
+       keystr = talloc_asprintf(reg_tdb,"%s/%s/%s", REG_VALUE_PREFIX, 
+                                KEY_SMBCONF, GLOBAL_NAME);
+       normalize_dbkey(keystr);
+
+       DEBUG(10, ("process_registry_globals: fetching key '%s'\n",
+                  keystr));
+
+       data = tdb_fetch_bystring(reg_tdb->tdb, keystr);
+       if (!data.dptr) {
+               ret = True;
+               goto done;
+       }
+
+       buf = data.dptr;
+       buflen = data.dsize;
+
+       /* unpack number of values */
+       len = tdb_unpack(buf, buflen, "d", &num_values);
+       DEBUG(10, ("process_registry_globals: got %d values from tdb\n",
+                  num_values));
+
+       /* unpack the values */
+       for (i=0; i < num_values; i++) {
+               type = REG_NONE;
+               size = 0;
+               data_p = NULL;
+               len += tdb_unpack(buf+len, buflen-len, "fdB",
+                                 valname,
+                                 &type,
+                                 &size,
+                                 &data_p);
+               if (registry_smbconf_valname_forbidden(valname)) {
+                       DEBUG(10, ("process_registry_globals: Ignoring "
+                                  "parameter '%s' in registry.\n", valname));
+                       continue;
+               }
+               DEBUG(10, ("process_registry_globals: got value '%s'\n",
+                          valname));
+               if (size && data_p) {
+                       err = registry_pull_value(reg_tdb, 
+                                                 &value,
+                                                 type,
+                                                 data_p,
+                                                 size,
+                                                 size);
+                       SAFE_FREE(data_p);
+                       if (!W_ERROR_IS_OK(err)) {
+                               goto done;
+                       }
+                       switch(type) {
+                       case REG_DWORD:
+                               valstr = talloc_asprintf(reg_tdb, "%d", 
+                                                        value->v.dword);
+                               pfunc(valname, valstr);
+                               break;
+                       case REG_SZ:
+                               pfunc(valname, value->v.sz.str);
+                               break;
+                       default:
+                               /* ignore other types */
+                               break;
+                       }
+               }
+       }
+
+       ret = pfunc("registry shares", "yes");
+       regdb_last_seqnum = tdb_get_seqnum(reg_tdb->tdb);
+
+done:
+       TALLOC_FREE(reg_tdb);
+       SAFE_FREE(data.dptr);
+       return ret;
+}
+
+#if 0
+/*
+ * this is process_registry_globals as it _should_ be (roughly)
+ * using the reg_api functions...
+ * 
+ */
+static BOOL process_registry_globals(BOOL (*pfunc)(const char *, const char *))
+{
+       BOOL ret = False;
+       TALLOC_CTX *ctx = NULL;
+       char *regpath = NULL;
+       WERROR werr = WERR_OK;
+       struct registry_key *key = NULL;
+       struct registry_value *value = NULL;
+       char *valname = NULL;
+       char *valstr = NULL;
+       uint32 idx = 0;
+       NT_USER_TOKEN *token;
+
+       ctx = talloc_init("process_registry_globals");
+       if (!ctx) {
+               smb_panic("Failed to create talloc context!");
+       }
+
+       include_registry_globals = True;
+
+       if (!registry_init_regdb()) {
+               DEBUG(1, ("Error initializing the registry.\n"));
+               goto done;
+       }
+
+       if (!(token = registry_create_admin_token(ctx))) {
+               DEBUG(1, ("Error creating admin token\n"));
+               goto done;
+       }
+
+       regpath = talloc_asprintf(ctx,"%s\\%s", KEY_SMBCONF, GLOBAL_NAME);
+       werr = reg_open_path(ctx, regpath, REG_KEY_READ, token, &key);
+       if (!W_ERROR_IS_OK(werr)) {
+               DEBUG(1, ("Registry smbconf global section does not exist.\n"));
+               DEBUGADD(1, ("Error opening registry path '%s\\%s: %s\n",
+                            KEY_SMBCONF, GLOBAL_NAME, dos_errstr(werr)));
+               goto done;
+       }
+
+       for (idx = 0;
+            W_ERROR_IS_OK(werr = reg_enumvalue(ctx, key, idx, &valname,
+                                               &value));
+            idx++)
+       {
+               DEBUG(5, ("got global registry parameter '%s'\n", valname));
+               switch(value->type) {
+               case REG_DWORD:
+                       valstr = talloc_asprintf(ctx, "%d", value->v.dword);
+                       pfunc(valname, valstr);
+                       TALLOC_FREE(valstr);
+                       break;
+               case REG_SZ:
+                       pfunc(valname, value->v.sz.str);
+                       break;
+               default:
+                       /* ignore other types */
+                       break;
+               }
+               TALLOC_FREE(value);
+               TALLOC_FREE(valstr);
+       }
+
+       ret = pfunc("registry shares", "yes");
+
+       regdb_last_seqnum = regdb_get_seqnum();
+
+done:
+       talloc_destroy(ctx);
+       return ret;
+}
+#endif /* if 0 */
+
 static struct file_lists {
        struct file_lists *next;
        char *name;
@@ -3002,9 +3609,21 @@ static void add_to_file_list(const char *fname, const char *subfname)
 BOOL lp_file_list_changed(void)
 {
        struct file_lists *f = file_lists;
+       struct tdb_wrap *reg_tdb = NULL;
 
        DEBUG(6, ("lp_file_list_changed()\n"));
 
+       if (include_registry_globals) {
+               reg_tdb = lp_regdb_open();
+               if (reg_tdb && (regdb_last_seqnum != tdb_get_seqnum(reg_tdb->tdb)))
+               {
+                       DEBUGADD(6, ("regdb seqnum changed: old = %d, new = %d\n",
+                                   regdb_last_seqnum, tdb_get_seqnum(reg_tdb->tdb)));
+                       TALLOC_FREE(reg_tdb);
+                       return True;
+               }
+       }
+
        while (f) {
                pstring n2;
                time_t mod_time;
@@ -3105,6 +3724,17 @@ static BOOL handle_include(int snum, const char *pszParmValue, char **ptr)
        pstring fname;
        pstrcpy(fname, pszParmValue);
 
+       if (strequal(fname, INCLUDE_REGISTRY_NAME)) {
+               if (bInGlobalSection) {
+                       return process_registry_globals(do_parameter);
+               }
+               else {
+                       DEBUG(1, ("\"include = registry\" only effective "
+                                 "in %s section\n", GLOBAL_NAME));
+                       return False;
+               }
+       }
+
        standard_sub_basic(get_current_username(), current_user_info.domain,
                           fname,sizeof(fname));
 
@@ -3261,10 +3891,8 @@ static const char *append_ldap_suffix( const char *str )
        const char *suffix_string;
 
 
-       if (!lp_talloc)
-               lp_talloc = talloc_init("lp_talloc");
-
-       suffix_string = talloc_asprintf( lp_talloc, "%s,%s", str, Globals.szLdapSuffix );
+       suffix_string = talloc_asprintf(talloc_tos(), "%s,%s", str,
+                                       Globals.szLdapSuffix );
        if ( !suffix_string ) {
                DEBUG(0,("append_ldap_suffix: talloc_asprintf() failed!\n"));
                return "";
@@ -3864,7 +4492,6 @@ static void dump_a_service(service * pService, FILE * f)
 
 BOOL dump_a_parameter(int snum, char *parm_name, FILE * f, BOOL isGlobal)
 {
-       service * pService = ServicePtrs[snum];
        int i;
        BOOL result = False;
        parm_class p_class;
@@ -3907,11 +4534,13 @@ BOOL dump_a_parameter(int snum, char *parm_name, FILE * f, BOOL isGlobal)
                {
                        void *ptr;
 
-                       if (isGlobal)
+                       if (isGlobal) {
                                ptr = parm_table[i].ptr;
-                       else
+                       } else {
+                               service * pService = ServicePtrs[snum];
                                ptr = ((char *)pService) +
                                        PTR_DIFF(parm_table[i].ptr, &sDefault);
+                       }
 
                        print_parameter(&parm_table[i],
                                        ptr, f);
@@ -3925,7 +4554,24 @@ BOOL dump_a_parameter(int snum, char *parm_name, FILE * f, BOOL isGlobal)
 }
 
 /***************************************************************************
- Return info about the next service  in a service. snum==GLOBAL_SECTION_SNUM gives the globals.
+ Return info about the requested parameter (given as a string).
+ Return NULL when the string is not a valid parameter name.
+***************************************************************************/
+
+struct parm_struct *lp_get_parameter(const char *param_name)
+{
+       int num = map_parameter(param_name);
+
+       if (num < 0) {
+               return NULL;
+       }
+
+       return &parm_table[num];
+}
+
+/***************************************************************************
+ Return info about the next parameter in a service.
+ snum==GLOBAL_SECTION_SNUM gives the globals.
  Return NULL when out of parameters.
 ***************************************************************************/
 
@@ -3945,6 +4591,9 @@ struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
                            && (parm_table[*i].ptr ==
                                parm_table[(*i) - 1].ptr))
                                continue;
+                       
+                       if (is_default(*i) && !allparameters)
+                               continue;
 
                        return &parm_table[(*i)++];
                }
@@ -4568,7 +5217,7 @@ static int process_usershare_file(const char *dir_name, const char *file_name, i
        /* Should we allow printers to be shared... ? */
        ctx = talloc_init("usershare_sd_xctx");
        if (!ctx) {
-               SAFE_FREE(lines);
+               file_lines_free(lines);
                return 1;
        }
 
@@ -4576,11 +5225,11 @@ static int process_usershare_file(const char *dir_name, const char *file_name, i
                        iService, lines, numlines, sharepath,
                        comment, &psd, &guest_ok) != USERSHARE_OK) {
                talloc_destroy(ctx);
-               SAFE_FREE(lines);
+               file_lines_free(lines);
                return -1;
        }
 
-       SAFE_FREE(lines);
+       file_lines_free(lines);
 
        /* Everything ok - add the service possibly using a template. */
        if (iService < 0) {
@@ -4601,7 +5250,7 @@ static int process_usershare_file(const char *dir_name, const char *file_name, i
        }
 
        /* Write the ACL of the new/modified share. */
-       if (!set_share_security(ctx, service_name, psd)) {
+       if (!set_share_security(service_name, psd)) {
                 DEBUG(0, ("process_usershare_file: Failed to set share "
                        "security for user share %s\n",
                        service_name ));
@@ -4874,7 +5523,7 @@ int load_usershare_shares(void)
                        /* Remove from the share ACL db. */
                        DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
                                lp_servicename(iService) ));
-                       delete_share_security(iService);
+                       delete_share_security(lp_servicename(iService));
                        free_service_byindex(iService);
                }
        }
@@ -4892,8 +5541,6 @@ void gfree_loadparm(void)
        struct file_lists *next;
        int i;
 
-       lp_TALLOC_FREE();
-
        /* Free the file lists */
 
        f = file_lists;
@@ -5108,7 +5755,7 @@ int lp_servicenumber(const char *pszServiceName)
 
                if (!usershare_exists(iService, &last_mod)) {
                        /* Remove the share security tdb entry for it. */
-                       delete_share_security(iService);
+                       delete_share_security(lp_servicename(iService));
                        /* Remove it from the array. */
                        free_service_byindex(iService);
                        /* Doesn't exist anymore. */
@@ -5141,12 +5788,16 @@ struct share_params *get_share_params(TALLOC_CTX *mem_ctx,
                                      const char *sharename)
 {
        struct share_params *result;
-       fstring sname;
+       char *sname;
        int snum;
 
-       fstrcpy(sname, sharename);
+       if (!(sname = SMB_STRDUP(sharename))) {
+               return NULL;
+       }
 
        snum = find_service(sname);
+       SAFE_FREE(sname);
+
        if (snum < 0) {
                return NULL;
        }
@@ -5196,19 +5847,50 @@ struct share_params *next_share(struct share_iterator *list)
        return result;
 }
 
+struct share_params *next_printer(struct share_iterator *list)
+{
+       struct share_params *result;
+
+       while ((result = next_share(list)) != NULL) {
+               if (lp_print_ok(result->service)) {
+                       break;
+               }
+       }
+       return result;
+}
+
+/*
+ * This is a hack for a transition period until we transformed all code from
+ * service numbers to struct share_params.
+ */
+
+struct share_params *snum2params_static(int snum)
+{
+       static struct share_params result;
+       result.service = snum;
+       return &result;
+}
+
 /*******************************************************************
  A useful volume label function. 
 ********************************************************************/
 
-char *volume_label(int snum)
+const char *volume_label(int snum)
 {
-       char *ret = lp_volume(snum);
-       if (!*ret)
-               return lp_servicename(snum);
-       return (ret);
+       char *ret;
+       const char *label = lp_volume(snum);
+       if (!*label) {
+               label = lp_servicename(snum);
+       }
+               
+       /* This returns a 33 byte guarenteed null terminated string. */
+       ret = talloc_strndup(talloc_tos(), label, 32);
+       if (!ret) {
+               return "";
+       }               
+       return ret;
 }
 
-
 /*******************************************************************
  Set the server type we will announce as via nmbd.
 ********************************************************************/
@@ -5533,17 +6215,23 @@ void lp_set_posix_pathnames(void)
  Global state for POSIX lock processing - CIFS unix extensions.
 ********************************************************************/
 
+BOOL posix_default_lock_was_set;
 static enum brl_flavour posix_cifsx_locktype; /* By default 0 == WINDOWS_LOCK */
 
-enum brl_flavour lp_posix_cifsu_locktype(void)
+enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
 {
-       return posix_cifsx_locktype;
+       if (posix_default_lock_was_set) {
+               return posix_cifsx_locktype;
+       } else {
+               return fsp->posix_open ? POSIX_LOCK : WINDOWS_LOCK;
+       }
 }
 
 /*******************************************************************
 ********************************************************************/
 
-void lp_set_posix_cifsx_locktype(enum brl_flavour val)
+void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
 {
+       posix_default_lock_was_set = True;
        posix_cifsx_locktype = val;
 }