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,
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/>.
*/
/*
#include "includes.h"
-BOOL in_client = False; /* Not in the client by default */
-BOOL bLoaded = False;
+bool in_client = False; /* Not in the client by default */
+bool bLoaded = False;
-extern pstring user_socket_options;
extern enum protocol_types Protocol;
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)
#define USERSHARE_VALID 1
#define USERSHARE_PENDING_DELETE 2
-int keepalive = DEFAULT_KEEPALIVE;
-BOOL use_getwd_cache = True;
-
extern int extra_time_offset;
-static BOOL defaults_saved = False;
+static bool defaults_saved = False;
typedef struct _param_opt_struct param_opt_struct;
struct _param_opt_struct {
char *szWINSHook;
char *szUtmpDir;
char *szWtmpDir;
- BOOL bUtmp;
+ bool bUtmp;
char *szIdmapUID;
char *szIdmapGID;
- BOOL bPassdbExpandExplicit;
+ bool bPassdbExpandExplicit;
int AlgorithmicRidBase;
char *szTemplateHomedir;
char *szTemplateShell;
char *szWinbindSeparator;
- BOOL bWinbindEnumUsers;
- BOOL bWinbindEnumGroups;
- BOOL bWinbindUseDefaultDomain;
- BOOL bWinbindTrustedDomainsOnly;
- BOOL bWinbindNestedGroups;
- BOOL bWinbindRefreshTickets;
- BOOL bWinbindOfflineLogon;
- BOOL bWinbindNormalizeNames;
+ bool bWinbindEnumUsers;
+ bool bWinbindEnumGroups;
+ bool bWinbindUseDefaultDomain;
+ bool bWinbindTrustedDomainsOnly;
+ bool bWinbindNestedGroups;
+ int winbind_expand_groups;
+ bool bWinbindRefreshTickets;
+ bool bWinbindOfflineLogon;
+ bool bWinbindNormalizeNames;
+ bool bWinbindRpcOnly;
char **szIdmapDomains;
char **szIdmapBackend; /* deprecated */
char *szIdmapAllocBackend;
int pwordlevel;
int unamelevel;
int deadtime;
+ bool getwd_cache;
int maxprotocol;
int minprotocol;
int security;
char **AuthMethods;
- BOOL paranoid_server_security;
+ bool paranoid_server_security;
int maxdisksize;
int lpqcachetime;
int iMaxSmbdProcesses;
- BOOL bDisableSpoolss;
+ bool bDisableSpoolss;
int syslog;
int os_level;
- int enhanced_browsing;
+ bool enhanced_browsing;
int max_ttl;
int max_wins_ttl;
int min_wins_ttl;
int winbind_cache_time;
int winbind_max_idle_children;
char **szWinbindNssInfo;
- int iLockSpinCount;
int iLockSpinTime;
char *szLdapMachineSuffix;
char *szLdapUserSuffix;
int iAclCompat;
char *szCupsServer;
char *szIPrintServer;
- int ldap_passwd_sync;
+ char *ctdbdSocket;
+ char **szClusterAddresses;
+ bool clustering;
+ int ldap_passwd_sync;
int ldap_replication_sleep;
int ldap_timeout; /* This is initialised in init_globals */
int ldap_page_size;
- BOOL ldap_delete_dn;
- BOOL bMsAddPrinterWizard;
- BOOL bDNSproxy;
- BOOL bWINSsupport;
- BOOL bWINSproxy;
- BOOL bLocalMaster;
- BOOL bPreferredMaster;
- BOOL bDomainMaster;
- BOOL bDomainLogons;
- BOOL bEncryptPasswords;
- BOOL bUpdateEncrypt;
+ bool ldap_delete_dn;
+ bool bMsAddPrinterWizard;
+ bool bDNSproxy;
+ bool bWINSsupport;
+ bool bWINSproxy;
+ bool bLocalMaster;
+ int iPreferredMaster;
+ int iDomainMaster;
+ bool bDomainLogons;
+ bool bEncryptPasswords;
+ bool bUpdateEncrypt;
int clientSchannel;
int serverSchannel;
- BOOL bNullPasswords;
- BOOL bObeyPamRestrictions;
- BOOL bLoadPrinters;
+ bool bNullPasswords;
+ bool bObeyPamRestrictions;
+ bool bLoadPrinters;
int PrintcapCacheTime;
- BOOL bLargeReadwrite;
- BOOL bReadRaw;
- BOOL bWriteRaw;
- BOOL bReadbmpx;
- BOOL bSyslogOnly;
- BOOL bBrowseList;
- BOOL bNISHomeMap;
- BOOL bTimeServer;
- BOOL bBindInterfacesOnly;
- BOOL bPamPasswordChange;
- BOOL bUnixPasswdSync;
- BOOL bPasswdChatDebug;
+ bool bLargeReadwrite;
+ bool bReadRaw;
+ bool bWriteRaw;
+ bool bSyslogOnly;
+ bool bBrowseList;
+ bool bNISHomeMap;
+ bool bTimeServer;
+ bool bBindInterfacesOnly;
+ bool bPamPasswordChange;
+ bool bUnixPasswdSync;
+ bool bPasswdChatDebug;
int iPasswdChatTimeout;
- BOOL bTimestampLogs;
- BOOL bNTSmbSupport;
- BOOL bNTPipeSupport;
- BOOL bNTStatusSupport;
- BOOL bStatCache;
+ bool bTimestampLogs;
+ bool bNTSmbSupport;
+ bool bNTPipeSupport;
+ bool bNTStatusSupport;
+ bool bStatCache;
int iMaxStatCacheSize;
- BOOL bKernelOplocks;
- BOOL bAllowTrustedDomains;
- BOOL bLanmanAuth;
- BOOL bNTLMAuth;
- BOOL bUseSpnego;
- BOOL bClientLanManAuth;
- BOOL bClientNTLMv2Auth;
- BOOL bClientPlaintextAuth;
- BOOL bClientUseSpnego;
- BOOL bDebugPrefixTimestamp;
- BOOL bDebugHiresTimestamp;
- BOOL bDebugPid;
- BOOL bDebugUid;
- BOOL bEnableCoreFiles;
- BOOL bHostMSDfs;
- BOOL bUseMmap;
- BOOL bHostnameLookups;
- BOOL bUnixExtensions;
- BOOL bDisableNetbios;
- BOOL bUseKerberosKeytab;
- BOOL bDeferSharingViolations;
- BOOL bEnablePrivileges;
- BOOL bASUSupport;
- BOOL bUsershareOwnerOnly;
- BOOL bUsershareAllowGuests;
- BOOL bRegistryShares;
+ bool bKernelOplocks;
+ bool bAllowTrustedDomains;
+ bool bLanmanAuth;
+ bool bNTLMAuth;
+ bool bUseSpnego;
+ bool bClientLanManAuth;
+ 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 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 iIdmapExpireTime;
- int iIdmapNegativeTime;
+ int iIdmapCacheTime;
+ int iIdmapNegativeCacheTime;
- BOOL bResetOnZeroVC;
+ bool bResetOnZeroVC;
+ int iKeepalive;
+ int iminreceivefile;
param_opt_struct *param_opt;
} global;
* This structure describes a single service.
*/
typedef struct {
- BOOL valid;
- BOOL autoloaded;
+ bool valid;
+ bool autoloaded;
int usershare;
time_t usershare_last_mod;
char *szService;
char **szHostsdeny;
char *szMagicScript;
char *szMagicOutput;
- char *szMangledMap;
char *szVetoFiles;
char *szHideFiles;
char *szVetoOplockFiles;
char *fstype;
char **szVfsObjects;
char *szMSDfsProxy;
+ char *szAioWriteBehind;
char *szDfree;
int iMinPrintSpace;
int iMaxPrintJobs;
int iCSCPolicy;
int iBlock_size;
int iDfreeCacheTime;
- BOOL bPreexecClose;
- BOOL bRootpreexecClose;
+ bool bPreexecClose;
+ bool bRootpreexecClose;
int iCaseSensitive;
- BOOL bCasePreserve;
- BOOL bShortCasePreserve;
- BOOL bHideDotFiles;
- BOOL bHideSpecialFiles;
- BOOL bHideUnReadable;
- BOOL bHideUnWriteableFiles;
- BOOL bBrowseable;
- BOOL bAvailable;
- BOOL bRead_only;
- BOOL bNo_set_dir;
- BOOL bGuest_only;
- BOOL bGuest_ok;
- BOOL bPrint_ok;
- BOOL bMap_system;
- BOOL bMap_hidden;
- BOOL bMap_archive;
- BOOL bStoreDosAttributes;
- BOOL bDmapiSupport;
- BOOL bLocking;
+ bool bCasePreserve;
+ bool bShortCasePreserve;
+ bool bHideDotFiles;
+ bool bHideSpecialFiles;
+ bool bHideUnReadable;
+ bool bHideUnWriteableFiles;
+ bool bBrowseable;
+ bool bAvailable;
+ bool bRead_only;
+ bool bNo_set_dir;
+ bool bGuest_only;
+ bool bGuest_ok;
+ bool bPrint_ok;
+ bool bMap_system;
+ bool bMap_hidden;
+ bool bMap_archive;
+ bool bStoreDosAttributes;
+ bool bDmapiSupport;
+ bool bLocking;
int iStrictLocking;
- BOOL bPosixLocking;
- BOOL bShareModes;
- BOOL bOpLocks;
- BOOL bLevel2OpLocks;
- BOOL bOnlyUser;
- BOOL bMangledNames;
- BOOL bWidelinks;
- BOOL bSymlinks;
- BOOL bSyncAlways;
- BOOL bStrictAllocate;
- BOOL bStrictSync;
+ bool bPosixLocking;
+ bool bShareModes;
+ bool bOpLocks;
+ bool bLevel2OpLocks;
+ bool bOnlyUser;
+ bool bMangledNames;
+ bool bWidelinks;
+ bool bSymlinks;
+ bool bSyncAlways;
+ bool bStrictAllocate;
+ bool bStrictSync;
char magic_char;
- BOOL *copymap;
- BOOL bDeleteReadonly;
- BOOL bFakeOplocks;
- BOOL bDeleteVetoFiles;
- BOOL bDosFilemode;
- BOOL bDosFiletimes;
- BOOL bDosFiletimeResolution;
- BOOL bFakeDirCreateTimes;
- BOOL bBlockingLocks;
- BOOL bInheritPerms;
- BOOL bInheritACLS;
- BOOL bInheritOwner;
- BOOL bMSDfsRoot;
- BOOL bUseClientDriver;
- BOOL bDefaultDevmode;
- BOOL bForcePrintername;
- BOOL bNTAclSupport;
- BOOL bForceUnknownAclUser;
- BOOL bUseSendfile;
- BOOL bProfileAcls;
- BOOL bMap_acl_inherit;
- BOOL bAfs_Share;
- BOOL bEASupport;
- BOOL bAclCheckPermissions;
- BOOL bAclMapFullControl;
- BOOL bAclGroupControl;
- BOOL bChangeNotify;
- BOOL bKernelChangeNotify;
+ struct bitmap *copymap;
+ bool bDeleteReadonly;
+ bool bFakeOplocks;
+ bool bDeleteVetoFiles;
+ bool bDosFilemode;
+ bool bDosFiletimes;
+ bool bDosFiletimeResolution;
+ bool bFakeDirCreateTimes;
+ bool bBlockingLocks;
+ bool bInheritPerms;
+ bool bInheritACLS;
+ bool bInheritOwner;
+ bool bMSDfsRoot;
+ bool bUseClientDriver;
+ bool bDefaultDevmode;
+ bool bForcePrintername;
+ bool bNTAclSupport;
+ bool bForceUnknownAclUser;
+ bool bUseSendfile;
+ bool bProfileAcls;
+ bool bMap_acl_inherit;
+ bool bAfs_Share;
+ bool bEASupport;
+ bool bAclCheckPermissions;
+ bool bAclMapFullControl;
+ bool bAclGroupControl;
+ bool bChangeNotify;
+ bool bKernelChangeNotify;
int iallocation_roundup_size;
int iAioReadSize;
int iAioWriteSize;
int iMap_readonly;
+ int iDirectoryNameCacheSize;
+ int ismb_encrypt;
param_opt_struct *param_opt;
char dummy[3]; /* for alignment */
NULL, /* szHostsdeny */
NULL, /* szMagicScript */
NULL, /* szMagicOutput */
- NULL, /* szMangledMap */
NULL, /* szVetoFiles */
NULL, /* szHideFiles */
NULL, /* szVetoOplockFiles */
NULL, /* fstype */
NULL, /* vfs objects */
NULL, /* szMSDfsProxy */
+ NULL, /* szAioWriteBehind */
NULL, /* szDfree */
0, /* iMinPrintSpace */
1000, /* iMaxPrintJobs */
0, /* iAioReadSize */
0, /* iAioWriteSize */
MAP_READONLY_YES, /* iMap_readonly */
-
+#ifdef BROKEN_DIRECTORY_HANDLING
+ 0, /* iDirectoryNameCacheSize */
+#else
+ 100, /* iDirectoryNameCacheSize */
+#endif
+ Auto, /* ismb_encrypt */
NULL, /* Parametric options */
"" /* dummy */
static service **ServicePtrs = NULL;
static int iNumServices = 0;
static int iServiceIndex = 0;
-static TDB_CONTEXT *ServiceHash;
+static struct db_context *ServiceHash;
static int *invalid_services = NULL;
static int num_invalid_services = 0;
-static BOOL bInGlobalSection = True;
-static BOOL bGlobalOnly = False;
+static bool bInGlobalSection = True;
+static bool bGlobalOnly = False;
static int server_role;
static int default_server_announce;
#define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
/* prototypes for the special type handlers */
-static BOOL handle_include( int snum, const char *pszParmValue, char **ptr);
-static BOOL handle_copy( int snum, const char *pszParmValue, char **ptr);
-static BOOL handle_netbios_name( int snum, const char *pszParmValue, char **ptr);
-static BOOL handle_idmap_uid( int snum, const char *pszParmValue, char **ptr);
-static BOOL handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
-static BOOL handle_debug_list( int snum, const char *pszParmValue, char **ptr );
-static BOOL handle_workgroup( int snum, const char *pszParmValue, char **ptr );
-static BOOL handle_netbios_aliases( int snum, const char *pszParmValue, char **ptr );
-static BOOL handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
-static BOOL handle_charset( int snum, const char *pszParmValue, char **ptr );
-static BOOL handle_printing( int snum, const char *pszParmValue, char **ptr);
+static bool handle_include( int snum, const char *pszParmValue, char **ptr);
+static bool handle_copy( int snum, const char *pszParmValue, char **ptr);
+static bool handle_netbios_name( int snum, const char *pszParmValue, char **ptr);
+static bool handle_idmap_uid( int snum, const char *pszParmValue, char **ptr);
+static bool handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
+static bool handle_debug_list( int snum, const char *pszParmValue, char **ptr );
+static bool handle_workgroup( int snum, const char *pszParmValue, char **ptr );
+static bool handle_netbios_aliases( int snum, const char *pszParmValue, char **ptr );
+static bool handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
+static bool handle_charset( int snum, const char *pszParmValue, char **ptr );
+static bool handle_printing( int snum, const char *pszParmValue, char **ptr);
static void set_server_role(void);
static void set_default_server_announce_type(void);
{-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"},
{"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},
{"allocation roundup size", P_INTEGER, P_LOCAL, &sDefault.iallocation_roundup_size, NULL, NULL, FLAG_ADVANCED},
{"aio read size", P_INTEGER, P_LOCAL, &sDefault.iAioReadSize, NULL, NULL, FLAG_ADVANCED},
{"aio write size", P_INTEGER, P_LOCAL, &sDefault.iAioWriteSize, NULL, NULL, FLAG_ADVANCED},
+ {"aio write behind", P_STRING, P_LOCAL, &sDefault.szAioWriteBehind, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL },
{"smb ports", P_STRING, P_GLOBAL, &Globals.smb_ports, NULL, NULL, FLAG_ADVANCED},
{"large readwrite", P_BOOL, P_GLOBAL, &Globals.bLargeReadwrite, NULL, NULL, FLAG_ADVANCED},
{"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},
+ {"min receivefile size", P_INTEGER, P_GLOBAL, &Globals.iminreceivefile, 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},
{"use spnego", P_BOOL, P_GLOBAL, &Globals.bUseSpnego, NULL, NULL, FLAG_ADVANCED},
{"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},
+ {"smb encrypt", P_ENUM, P_LOCAL, &sDefault.ismb_encrypt, 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},
{"block size", P_INTEGER, P_LOCAL, &sDefault.iBlock_size, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
{"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},
+ {"getwd cache", P_BOOL, P_GLOBAL, &Globals.getwd_cache, 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 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},
+ {"socket options", P_STRING, P_GLOBAL, &Globals.szSocketOptions, NULL, NULL, FLAG_ADVANCED},
{"strict allocate", P_BOOL, P_LOCAL, &sDefault.bStrictAllocate, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
{"strict sync", P_BOOL, P_LOCAL, &sDefault.bStrictSync, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
{"sync always", P_BOOL, P_LOCAL, &sDefault.bSyncAlways, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
{"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},
{"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},
{"os level", P_INTEGER, P_GLOBAL, &Globals.os_level, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED},
{"lm announce", P_ENUM, P_GLOBAL, &Globals.lm_announce, NULL, enum_bool_auto, FLAG_ADVANCED},
{"lm interval", P_INTEGER, P_GLOBAL, &Globals.lm_interval, NULL, NULL, FLAG_ADVANCED},
- {"preferred master", P_ENUM, P_GLOBAL, &Globals.bPreferredMaster, NULL, enum_bool_auto, FLAG_BASIC | FLAG_ADVANCED},
- {"prefered master", P_ENUM, P_GLOBAL, &Globals.bPreferredMaster, NULL, enum_bool_auto, FLAG_HIDE},
+ {"preferred master", P_ENUM, P_GLOBAL, &Globals.iPreferredMaster, NULL, enum_bool_auto, FLAG_BASIC | FLAG_ADVANCED},
+ {"prefered master", P_ENUM, P_GLOBAL, &Globals.iPreferredMaster, NULL, enum_bool_auto, FLAG_HIDE},
{"local master", P_BOOL, P_GLOBAL, &Globals.bLocalMaster, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED},
- {"domain master", P_ENUM, P_GLOBAL, &Globals.bDomainMaster, NULL, enum_bool_auto, FLAG_BASIC | FLAG_ADVANCED},
+ {"domain master", P_ENUM, P_GLOBAL, &Globals.iDomainMaster, NULL, enum_bool_auto, FLAG_BASIC | FLAG_ADVANCED},
{"browse list", P_BOOL, P_GLOBAL, &Globals.bBrowseList, NULL, NULL, FLAG_ADVANCED},
{"browseable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
{"browsable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL, FLAG_HIDE},
{"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},
{"passdb expand explicit", P_BOOL, P_GLOBAL, &Globals.bPassdbExpandExplicit, NULL, NULL, FLAG_ADVANCED},
{"idmap domains", P_LIST, P_GLOBAL, &Globals.szIdmapDomains, NULL, NULL, FLAG_ADVANCED},
- {"idmap backend", P_LIST, P_GLOBAL, &Globals.szIdmapBackend, NULL, NULL, FLAG_ADVANCED | FLAG_DEPRECATED },
+ {"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 expire time", P_INTEGER, P_GLOBAL, &Globals.iIdmapExpireTime, NULL, NULL, FLAG_ADVANCED},
- {"idmap negative time", P_INTEGER, P_GLOBAL, &Globals.iIdmapNegativeTime, NULL, NULL, FLAG_ADVANCED},
- {"idmap uid", P_STRING, P_GLOBAL, &Globals.szIdmapUID, handle_idmap_uid, NULL, FLAG_ADVANCED | FLAG_DEPRECATED },
- {"winbind uid", P_STRING, P_GLOBAL, &Globals.szIdmapUID, handle_idmap_uid, NULL, FLAG_HIDE | FLAG_DEPRECATED },
- {"idmap gid", P_STRING, P_GLOBAL, &Globals.szIdmapGID, handle_idmap_gid, NULL, FLAG_ADVANCED | FLAG_DEPRECATED },
- {"winbind gid", P_STRING, P_GLOBAL, &Globals.szIdmapGID, handle_idmap_gid, NULL, FLAG_HIDE | FLAG_DEPRECATED },
+ {"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},
{"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}
};
Initialise the global parameter structure.
***************************************************************************/
-static void init_globals(BOOL first_time_only)
+static void init_globals(bool first_time_only)
{
- static BOOL done_init = False;
- pstring s;
+ static bool done_init = False;
+ char *s = NULL;
/* If requested to initialize only once and we've already done it... */
if (first_time_only && done_init) {
DEBUG(3, ("Initialising global parameters\n"));
- string_set(&Globals.szSMBPasswdFile, dyn_SMB_PASSWD_FILE);
- string_set(&Globals.szPrivateDir, dyn_PRIVATE_DIR);
+ string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
+ string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
/* use the new 'hash2' method by default, with a prefix of 1 */
string_set(&Globals.szManglingMethod, "hash2");
* Allow the default PASSWD_CHAT to be overridden in local.h.
*/
string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
-
+
set_global_myname(myhostname());
string_set(&Globals.szNetbiosName,global_myname());
set_global_myworkgroup(WORKGROUP);
string_set(&Globals.szWorkgroup, lp_workgroup());
-
+
string_set(&Globals.szPasswdProgram, "");
- string_set(&Globals.szPidDir, dyn_PIDDIR);
- string_set(&Globals.szLockDir, dyn_LOCKDIR);
+ string_set(&Globals.szPidDir, get_dyn_PIDDIR());
+ string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
string_set(&Globals.szSocketAddress, "0.0.0.0");
- pstrcpy(s, "Samba ");
- pstrcat(s, SAMBA_VERSION_STRING);
+
+ if (asprintf(&s, "Samba %s", SAMBA_VERSION_STRING) < 0) {
+ smb_panic("init_globals: ENOMEM");
+ }
string_set(&Globals.szServerString, s);
- slprintf(s, sizeof(s) - 1, "%d.%d", DEFAULT_MAJOR_VERSION,
- DEFAULT_MINOR_VERSION);
+ SAFE_FREE(s);
+ if (asprintf(&s, "%d.%d", DEFAULT_MAJOR_VERSION,
+ DEFAULT_MINOR_VERSION) < 0) {
+ smb_panic("init_globals: ENOMEM");
+ }
string_set(&Globals.szAnnounceVersion, s);
+ SAFE_FREE(s);
#ifdef DEVELOPER
string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
#endif
- pstrcpy(user_socket_options, DEFAULT_SOCKET_OPTIONS);
+ string_set(&Globals.szSocketOptions, DEFAULT_SOCKET_OPTIONS);
string_set(&Globals.szLogonDrive, "");
/* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
Globals.pwordlevel = 0;
Globals.unamelevel = 0;
Globals.deadtime = 0;
+ Globals.getwd_cache = true;
Globals.bLargeReadwrite = True;
Globals.max_log_size = 5000;
Globals.max_open_files = MAX_OPEN_FILES;
Globals.serverSchannel = Auto;
Globals.bReadRaw = True;
Globals.bWriteRaw = True;
- Globals.bReadbmpx = False;
Globals.bNullPasswords = False;
Globals.bObeyPamRestrictions = False;
Globals.syslog = 1;
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.bStatCache = True; /* use stat cache 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.enhanced_browsing = true;
Globals.iLockSpinTime = WINDOWS_MINIMUM_LOCK_TIMEOUT_MS; /* msec. */
#ifdef MMAP_BLACKLIST
Globals.bUseMmap = False;
*/
Globals.bMsAddPrinterWizard = True;
- Globals.bPreferredMaster = Auto; /* depending on bDomainMaster */
Globals.os_level = 20;
Globals.bLocalMaster = True;
- Globals.bDomainMaster = Auto; /* depending on bDomainLogons */
+ Globals.iDomainMaster = Auto; /* depending on bDomainLogons */
Globals.bDomainLogons = False;
Globals.bBrowseList = True;
Globals.bWINSsupport = False;
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.iIdmapExpireTime = 900; /* 15 minutes by default */
- Globals.iIdmapNegativeTime = 120; /* 2 minutes by default */
+ Globals.iIdmapCacheTime = 900; /* 15 minutes by default */
+ Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
Globals.bPassdbExpandExplicit = False;
Globals.bEnablePrivileges = True;
Globals.bHostMSDfs = True;
Globals.bASUSupport = False;
-
+
/* User defined shares. */
- pstrcpy(s, dyn_LOCKDIR);
- pstrcat(s, "/usershares");
+ if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
+ smb_panic("init_globals: ENOMEM");
+ }
string_set(&Globals.szUsersharePath, s);
+ SAFE_FREE(s);
string_set(&Globals.szUsershareTemplateShare, "");
Globals.iUsershareMaxShares = 0;
/* By default disallow sharing of directories not owned by the sharer. */
/* By default disallow guest access to usershares. */
Globals.bUsershareAllowGuests = False;
+ Globals.iKeepalive = DEFAULT_KEEPALIVE;
+
/* By default no shares out of the registry */
Globals.bRegistryShares = False;
-}
-
-static TALLOC_CTX *lp_talloc;
-
-/******************************************************************* a
- Free up temporary memory - called from the main loop.
-********************************************************************/
-
-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;
+ Globals.iminreceivefile = 0;
}
/*******************************************************************
static char *lp_string(const char *s)
{
- char *ret, *tmpstr;
+ char *ret;
+ TALLOC_CTX *ctx = talloc_tos();
/* The follow debug is useful for tracking down memory problems
especially if you have an inner loop that is calling a lp_*()
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, '\"', '\"')) {
- if (strchr(tmpstr,'\"') != NULL) {
- SAFE_FREE(tmpstr);
- tmpstr = alloc_sub_basic(get_current_username(),
- current_user_info.domain, s);
+ ret = talloc_sub_basic(ctx,
+ get_current_username(),
+ current_user_info.domain,
+ s);
+ if (trim_char(ret, '\"', '\"')) {
+ if (strchr(ret,'\"') != NULL) {
+ TALLOC_FREE(ret);
+ ret = talloc_sub_basic(ctx,
+ get_current_username(),
+ current_user_info.domain,
+ s);
}
}
- ret = talloc_strdup(lp_talloc, tmpstr);
- SAFE_FREE(tmpstr);
-
- return (ret);
+ return ret;
}
/*
#define FN_GLOBAL_LIST(fn_name,ptr) \
const char **fn_name(void) {return(*(const char ***)(ptr));}
#define FN_GLOBAL_BOOL(fn_name,ptr) \
- BOOL fn_name(void) {return(*(BOOL *)(ptr));}
+ bool fn_name(void) {return(*(bool *)(ptr));}
#define FN_GLOBAL_CHAR(fn_name,ptr) \
char fn_name(void) {return(*(char *)(ptr));}
#define FN_GLOBAL_INTEGER(fn_name,ptr) \
#define FN_LOCAL_LIST(fn_name,val) \
const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
#define FN_LOCAL_BOOL(fn_name,val) \
- BOOL fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
+ bool fn_name(int i) {return(bool)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
#define FN_LOCAL_INTEGER(fn_name,val) \
int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
#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);}
+ bool fn_name(const struct share_params *p) {return(bool)(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) \
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_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_expire_time, &Globals.iIdmapExpireTime)
-FN_GLOBAL_INTEGER(lp_idmap_negative_time, &Globals.iIdmapNegativeTime)
+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)
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)
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)
FN_GLOBAL_INTEGER(lp_passwordlevel, &Globals.pwordlevel)
FN_GLOBAL_INTEGER(lp_usernamelevel, &Globals.unamelevel)
FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
+FN_GLOBAL_BOOL(lp_getwd_cache, &Globals.getwd_cache)
FN_GLOBAL_INTEGER(lp_maxprotocol, &Globals.maxprotocol)
FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
FN_GLOBAL_INTEGER(lp_security, &Globals.security)
FN_GLOBAL_INTEGER(lp_maxdisksize, &Globals.maxdisksize)
FN_GLOBAL_INTEGER(lp_lpqcachetime, &Globals.lpqcachetime)
FN_GLOBAL_INTEGER(lp_max_smbd_processes, &Globals.iMaxSmbdProcesses)
-FN_GLOBAL_INTEGER(_lp_disable_spoolss, &Globals.bDisableSpoolss)
+FN_GLOBAL_BOOL(_lp_disable_spoolss, &Globals.bDisableSpoolss)
FN_GLOBAL_INTEGER(lp_syslog, &Globals.syslog)
static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
FN_GLOBAL_INTEGER(lp_lm_announce, &Globals.lm_announce)
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)
+FN_GLOBAL_CONST_STRING(lp_socket_options, &Globals.szSocketOptions)
FN_LOCAL_STRING(lp_preexec, szPreExec)
FN_LOCAL_STRING(lp_postexec, szPostExec)
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)
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)
FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
+FN_LOCAL_STRING(lp_aio_write_behind, szAioWriteBehind)
FN_LOCAL_STRING(lp_dfree_command, szDfree)
FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
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_directory_name_cache_size, iDirectoryNameCacheSize)
+FN_LOCAL_INTEGER(lp_smb_encrypt, ismb_encrypt)
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)
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 BOOL set_boolean(BOOL *pb, const char *pszParmValue);
+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 do_parameter(const char *pszParmName, const char *pszParmValue);
-static BOOL do_section(const char *pszSectionName);
+ service * pserviceSource,
+ struct bitmap *pcopymapDest);
+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 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 */
/* Actual parametrical functions are quite simple */
static param_opt_struct *get_parametrics(int snum, const char *type, const char *option)
{
- BOOL global_section = False;
+ bool global_section = False;
char* param_key;
param_opt_struct *data;
return (-1);
}
- return atoi(s);
+ return (int)strtol(s, NULL, 0);
}
/*******************************************************************
return (0);
}
- return strtoul(s, NULL, 10);
+ return strtoul(s, NULL, 0);
}
/*******************************************************************
convenience routine to return boolean parameters.
********************************************************************/
-static BOOL lp_bool(const char *s)
+static bool lp_bool(const char *s)
{
- BOOL ret = False;
+ bool ret = False;
if (!s || !*s) {
MISSING_PARAMETER(lp_bool);
/* 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);
/* Return parametric option from a given service. Type is a part of option before ':' */
/* Parametric option has following syntax: 'Type: option = value' */
-BOOL lp_parm_bool(int snum, const char *type, const char *option, BOOL def)
+bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
{
param_opt_struct *data = get_parametrics(snum, type, option);
pservice->szService));
string_free(&pservice->szService);
- SAFE_FREE(pservice->copymap);
+ bitmap_free(pservice->copymap);
for (i = 0; parm_table[i].label; i++) {
if ((parm_table[i].type == P_STRING ||
/* we have to cleanup the hash record */
if (ServicePtrs[idx]->szService) {
- char *canon_name = canonicalize_servicename( ServicePtrs[idx]->szService );
+ char *canon_name = canonicalize_servicename(
+ ServicePtrs[idx]->szService );
- tdb_delete_bystring(ServiceHash, canon_name );
+ dbwrap_delete_bystring(ServiceHash, canon_name );
+ TALLOC_FREE(canon_name);
}
free_service(ServicePtrs[idx]);
static char *canonicalize_servicename(const char *src)
{
- static fstring canon; /* is fstring large enough? */
+ char *result;
if ( !src ) {
DEBUG(0,("canonicalize_servicename: NULL source name!\n"));
return NULL;
}
- fstrcpy( canon, src );
- strlower_m( canon );
+ result = talloc_strdup(talloc_tos(), src);
+ SMB_ASSERT(result != NULL);
- return canon;
+ strlower_m(result);
+ return result;
}
/***************************************************************************
Add a name/index pair for the services array to the hash table.
***************************************************************************/
-static BOOL hash_a_service(const char *name, int idx)
+static bool hash_a_service(const char *name, int idx)
{
char *canon_name;
if ( !ServiceHash ) {
- DEBUG(10,("hash_a_service: creating tdb servicehash\n"));
- ServiceHash = tdb_open("servicehash", 1031, TDB_INTERNAL,
- (O_RDWR|O_CREAT), 0600);
+ DEBUG(10,("hash_a_service: creating servicehash\n"));
+ ServiceHash = db_open_rbt(NULL);
if ( !ServiceHash ) {
DEBUG(0,("hash_a_service: open tdb servicehash failed!\n"));
return False;
DEBUG(10,("hash_a_service: hashing index %d for service name %s\n",
idx, name));
- if ( !(canon_name = canonicalize_servicename( name )) )
- return False;
+ canon_name = canonicalize_servicename( name );
+
+ dbwrap_store_bystring(ServiceHash, canon_name,
+ make_tdb_data((uint8 *)&idx, sizeof(idx)),
+ TDB_REPLACE);
- tdb_store_int32(ServiceHash, canon_name, idx);
+ TALLOC_FREE(canon_name);
return True;
}
/***************************************************************************
- Add a new home service, with the specified home directory, defaults coming
+ Add a new home service, with the specified home directory, defaults coming
from service ifrom.
***************************************************************************/
-BOOL lp_add_home(const char *pszHomename, int iDefaultService,
+bool lp_add_home(const char *pszHomename, int iDefaultService,
const char *user, const char *pszHomedir)
{
int i;
- pstring newHomedir;
i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
if (!(*(ServicePtrs[iDefaultService]->szPath))
|| strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(GLOBAL_SECTION_SNUM))) {
- pstrcpy(newHomedir, pszHomedir);
- string_set(&ServicePtrs[i]->szPath, newHomedir);
- }
+ string_set(&ServicePtrs[i]->szPath, pszHomedir);
+ }
if (!(*(ServicePtrs[i]->comment))) {
- pstring comment;
- slprintf(comment, sizeof(comment) - 1,
- "Home directory of %s", user);
+ char *comment = NULL;
+ if (asprintf(&comment, "Home directory of %s", user) < 0) {
+ return false;
+ }
string_set(&ServicePtrs[i]->comment, comment);
+ SAFE_FREE(comment);
}
/* set the browseable flag from the global default */
DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
user, ServicePtrs[i]->szPath ));
-
+
return (True);
}
Add the IPC service.
***************************************************************************/
-static BOOL lp_add_ipc(const char *ipc_name, BOOL guest_ok)
+static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
{
- pstring comment;
+ char *comment = NULL;
int i = add_a_service(&sDefault, ipc_name);
if (i < 0)
return (False);
- slprintf(comment, sizeof(comment) - 1,
- "IPC Service (%s)", Globals.szServerString);
+ if (asprintf(&comment, "IPC Service (%s)",
+ Globals.szServerString) < 0) {
+ return (False);
+ }
string_set(&ServicePtrs[i]->szPath, tmpdir());
string_set(&ServicePtrs[i]->szUsername, "");
DEBUG(3, ("adding IPC service\n"));
+ SAFE_FREE(comment);
return (True);
}
Add a new printer service, with defaults coming from service iFrom.
***************************************************************************/
-BOOL lp_add_printer(const char *pszPrintername, int iDefaultService)
+bool lp_add_printer(const char *pszPrintername, int iDefaultService)
{
const char *comment = "From Printcap";
int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
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.
}
/***************************************************************************
- 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;
- BOOL hadFlag;
- const char *section_names[] = { "local", "global", NULL};
+ 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;
+ 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"};
+ "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
+ "P_ENUM", "P_SEP"};
unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
FLAG_HIDE, FLAG_DOS_STRING};
"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);
}
}
}
represent a boolean.
***************************************************************************/
-static BOOL set_boolean(BOOL *pb, const char *pszParmValue)
+static bool set_boolean(bool *pb, const char *pszParmValue)
{
- BOOL bRetval;
+ 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.
***************************************************************************/
{
int iService = -1;
char *canon_name;
+ TDB_DATA data;
- if (ServiceHash != NULL) {
- if ( !(canon_name = canonicalize_servicename( pszServiceName )) )
- return -1;
+ if (ServiceHash == NULL) {
+ return -1;
+ }
- iService = tdb_fetch_int32(ServiceHash, canon_name );
+ canon_name = canonicalize_servicename(pszServiceName);
- if (LP_SNUM_OK(iService)) {
- if (pserviceDest != NULL) {
- copy_service(pserviceDest, ServicePtrs[iService], NULL);
- }
- } else {
- iService = -1;
- }
+ data = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name);
+
+ if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
+ iService = *(int *)data.dptr;
+ }
+
+ TALLOC_FREE(canon_name);
+
+ if ((iService != -1) && (LP_SNUM_OK(iService))
+ && (pserviceDest != NULL)) {
+ copy_service(pserviceDest, ServicePtrs[iService], NULL);
}
return (iService);
If pcopymapDest is NULL then copy all fields
***************************************************************************/
-static void copy_service(service * pserviceDest, service * pserviceSource, BOOL *pcopymapDest)
+static void copy_service(service * pserviceDest, service * pserviceSource,
+ struct bitmap *pcopymapDest)
{
int i;
- BOOL bcopyall = (pcopymapDest == NULL);
+ bool bcopyall = (pcopymapDest == NULL);
param_opt_struct *data, *pdata, *paramo;
- BOOL not_added;
+ bool not_added;
for (i = 0; parm_table[i].label; i++)
if (parm_table[i].ptr && parm_table[i].p_class == P_LOCAL &&
- (bcopyall || pcopymapDest[i])) {
+ (bcopyall || bitmap_query(pcopymapDest,i))) {
void *def_ptr = parm_table[i].ptr;
void *src_ptr =
((char *)pserviceSource) + PTR_DIFF(def_ptr,
switch (parm_table[i].type) {
case P_BOOL:
case P_BOOLREV:
- *(BOOL *)dest_ptr = *(BOOL *)src_ptr;
+ *(bool *)dest_ptr = *(bool *)src_ptr;
break;
case P_INTEGER:
if (bcopyall) {
init_copymap(pserviceDest);
if (pserviceSource->copymap)
- memcpy((void *)pserviceDest->copymap,
- (void *)pserviceSource->copymap,
- sizeof(BOOL) * NUMPARAMETERS);
+ bitmap_copy(pserviceDest->copymap,
+ pserviceSource->copymap);
}
data = pserviceSource->param_opt;
incomplete or faulty, else True.
***************************************************************************/
-BOOL service_ok(int iService)
+bool service_ok(int iService)
{
- BOOL bRetval;
+ bool bRetval;
bRetval = True;
if (ServicePtrs[iService]->szService[0] == '\0') {
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, state_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",
+ state_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",
+ state_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;
+ 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++) {
+ fstring valname;
+ 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,
+ (enum winreg_Type)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...
+ *
+ * We are *not* currently doing it like this due to the large
+ * linker dependecies of the registry code (see above).
+ */
+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;
}
}
+bool lp_include_registry_globals(void)
+{
+ return include_registry_globals;
+}
+
/*******************************************************************
Check if a config file has changed date.
********************************************************************/
-BOOL lp_file_list_changed(void)
+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;
+ char *n2 = NULL;
time_t mod_time;
- pstrcpy(n2, f->name);
- standard_sub_basic( get_current_username(),
+ n2 = alloc_sub_basic(get_current_username(),
current_user_info.domain,
- n2, sizeof(n2) );
-
+ f->name);
+ if (!n2) {
+ return false;
+ }
DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
f->name, n2, ctime(&f->modtime)));
ctime(&mod_time)));
f->modtime = mod_time;
SAFE_FREE(f->subfname);
- f->subfname = SMB_STRDUP(n2);
- return (True);
+ f->subfname = n2; /* Passing ownership of
+ return from alloc_sub_basic
+ above. */
+ return true;
}
+ SAFE_FREE(n2);
f = f->next;
}
return (False);
Note: We must *NOT* use string_set() here as ptr points to global_myname.
***************************************************************************/
-static BOOL handle_netbios_name(int snum, const char *pszParmValue, char **ptr)
+static bool handle_netbios_name(int snum, const char *pszParmValue, char **ptr)
{
- BOOL ret;
- pstring netbios_name;
-
- pstrcpy(netbios_name, pszParmValue);
-
- standard_sub_basic(get_current_username(), current_user_info.domain,
- netbios_name, sizeof(netbios_name));
+ bool ret;
+ char *netbios_name = alloc_sub_basic(get_current_username(),
+ current_user_info.domain,
+ pszParmValue);
ret = set_global_myname(netbios_name);
+ SAFE_FREE(netbios_name);
string_set(&Globals.szNetbiosName,global_myname());
-
+
DEBUG(4, ("handle_netbios_name: set global_myname to: %s\n",
global_myname()));
return ret;
}
-static BOOL handle_charset(int snum, const char *pszParmValue, char **ptr)
+static bool handle_charset(int snum, const char *pszParmValue, char **ptr)
{
if (strcmp(*ptr, pszParmValue) != 0) {
string_set(ptr, pszParmValue);
-static BOOL handle_workgroup(int snum, const char *pszParmValue, char **ptr)
+static bool handle_workgroup(int snum, const char *pszParmValue, char **ptr)
{
- BOOL ret;
+ bool ret;
ret = set_global_myworkgroup(pszParmValue);
string_set(&Globals.szWorkgroup,lp_workgroup());
return ret;
}
-static BOOL handle_netbios_scope(int snum, const char *pszParmValue, char **ptr)
+static bool handle_netbios_scope(int snum, const char *pszParmValue, char **ptr)
{
- BOOL ret;
+ bool ret;
ret = set_global_scope(pszParmValue);
string_set(&Globals.szNetbiosScope,global_scope());
return ret;
}
-static BOOL handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr)
+static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr)
{
str_list_free(&Globals.szNetbiosAliases);
Globals.szNetbiosAliases = str_list_make(pszParmValue, NULL);
Handle the include operation.
***************************************************************************/
-static BOOL handle_include(int snum, const char *pszParmValue, char **ptr)
+static bool handle_include(int snum, const char *pszParmValue, char **ptr)
{
- pstring fname;
- pstrcpy(fname, pszParmValue);
+ char *fname;
+
+ if (strequal(pszParmValue, 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));
+ fname = alloc_sub_basic(get_current_username(),
+ current_user_info.domain,
+ pszParmValue);
add_to_file_list(pszParmValue, fname);
string_set(ptr, fname);
- if (file_exist(fname, NULL))
- return (pm_process(fname, do_section, do_parameter));
+ if (file_exist(fname, NULL)) {
+ bool ret = pm_process(fname, do_section, do_parameter);
+ SAFE_FREE(fname);
+ return ret;
+ }
DEBUG(2, ("Can't find include file %s\n", fname));
-
- return (False);
+ SAFE_FREE(fname);
+ return false;
}
/***************************************************************************
Handle the interpretation of the copy parameter.
***************************************************************************/
-static BOOL handle_copy(int snum, const char *pszParmValue, char **ptr)
+static bool handle_copy(int snum, const char *pszParmValue, char **ptr)
{
- BOOL bRetval;
+ bool bRetval;
int iTemp;
service serviceTemp;
static uid_t idmap_uid_low, idmap_uid_high;
static gid_t idmap_gid_low, idmap_gid_high;
-BOOL lp_idmap_uid(uid_t *low, uid_t *high)
+bool lp_idmap_uid(uid_t *low, uid_t *high)
{
if (idmap_uid_low == 0 || idmap_uid_high == 0)
return False;
return True;
}
-BOOL lp_idmap_gid(gid_t *low, gid_t *high)
+bool lp_idmap_gid(gid_t *low, gid_t *high)
{
if (idmap_gid_low == 0 || idmap_gid_high == 0)
return False;
/* Do some simple checks on "idmap [ug]id" parameter values */
-static BOOL handle_idmap_uid(int snum, const char *pszParmValue, char **ptr)
+static bool handle_idmap_uid(int snum, const char *pszParmValue, char **ptr)
{
uint32 low, high;
return True;
}
-static BOOL handle_idmap_gid(int snum, const char *pszParmValue, char **ptr)
+static bool handle_idmap_gid(int snum, const char *pszParmValue, char **ptr)
{
uint32 low, high;
Handle the DEBUG level list.
***************************************************************************/
-static BOOL handle_debug_list( int snum, const char *pszParmValueIn, char **ptr )
+static bool handle_debug_list( int snum, const char *pszParmValueIn, char **ptr )
{
- pstring pszParmValue;
-
- pstrcpy(pszParmValue, pszParmValueIn);
string_set(ptr, pszParmValueIn);
- return debug_parse_levels( pszParmValue );
+ return debug_parse_levels(pszParmValueIn);
}
/***************************************************************************
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 "";
/***************************************************************************
***************************************************************************/
-static BOOL handle_printing(int snum, const char *pszParmValue, char **ptr)
+static bool handle_printing(int snum, const char *pszParmValue, char **ptr)
{
static int parm_num = -1;
service *s;
static void init_copymap(service * pservice)
{
int i;
- SAFE_FREE(pservice->copymap);
- pservice->copymap = SMB_MALLOC_ARRAY(BOOL,NUMPARAMETERS);
+ if (pservice->copymap) {
+ bitmap_free(pservice->copymap);
+ }
+ pservice->copymap = bitmap_allocate(NUMPARAMETERS);
if (!pservice->copymap)
DEBUG(0,
("Couldn't allocate copymap!! (size %d)\n",
(int)NUMPARAMETERS));
else
for (i = 0; i < NUMPARAMETERS; i++)
- pservice->copymap[i] = True;
+ bitmap_set(pservice->copymap, i);
}
/***************************************************************************
then assume we are in the globals.
***************************************************************************/
-BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
+bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
{
int parmnum, i, slen;
void *parm_ptr = NULL; /* where we are going to store the result */
void *def_ptr = NULL;
- pstring param_key;
+ char *param_key = NULL;
char *sep;
param_opt_struct *paramo, *data;
- BOOL not_added;
+ bool not_added;
parmnum = map_parameter(pszParmName);
if (parmnum < 0) {
if ((sep=strchr(pszParmName, ':')) != NULL) {
+ TALLOC_CTX *frame = talloc_stackframe();
+
*sep = '\0';
- ZERO_STRUCT(param_key);
- pstr_sprintf(param_key, "%s:", pszParmName);
+ param_key = talloc_asprintf(frame, "%s:", pszParmName);
+ if (!param_key) {
+ TALLOC_FREE(frame);
+ return false;
+ }
slen = strlen(param_key);
- pstrcat(param_key, sep+1);
+ param_key = talloc_asprintf_append(param_key, sep+1);
+ if (!param_key) {
+ TALLOC_FREE(frame);
+ return false;
+ }
trim_char(param_key+slen, ' ', ' ');
not_added = True;
- data = (snum < 0) ? Globals.param_opt :
+ data = (snum < 0) ? Globals.param_opt :
ServicePtrs[snum]->param_opt;
/* Traverse destination */
while (data) {
}
*sep = ':';
+ TALLOC_FREE(frame);
return (True);
}
DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
the same data pointer */
for (i = 0; parm_table[i].label; i++)
if (parm_table[i].ptr == parm_table[parmnum].ptr)
- ServicePtrs[snum]->copymap[i] = False;
+ bitmap_clear(ServicePtrs[snum]->copymap, i);
}
/* if it is a special case then go ahead */
switch (parm_table[parmnum].type)
{
case P_BOOL:
- *(BOOL *)parm_ptr = lp_bool(pszParmValue);
+ *(bool *)parm_ptr = lp_bool(pszParmValue);
break;
case P_BOOLREV:
- *(BOOL *)parm_ptr = !lp_bool(pszParmValue);
+ *(bool *)parm_ptr = !lp_bool(pszParmValue);
break;
case P_INTEGER:
strupper_m(*(char **)parm_ptr);
break;
- case P_GSTRING:
- pstrcpy((char *)parm_ptr, pszParmValue);
- break;
-
- case P_UGSTRING:
- pstrcpy((char *)parm_ptr, pszParmValue);
- strupper_m((char *)parm_ptr);
- break;
-
case P_ENUM:
lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
break;
Process a parameter.
***************************************************************************/
-static BOOL do_parameter(const char *pszParmName, const char *pszParmValue)
+static bool do_parameter(const char *pszParmName, const char *pszParmValue)
{
if (!bInGlobalSection && bGlobalOnly)
return (True);
break;
case P_BOOL:
- fprintf(f, "%s", BOOLSTR(*(BOOL *)ptr));
+ fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
break;
case P_BOOLREV:
- fprintf(f, "%s", BOOLSTR(!*(BOOL *)ptr));
+ fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
break;
case P_INTEGER:
fprintf(f, "%c", *(char *)ptr);
break;
- case P_OCTAL:
- fprintf(f, "%s", octal_string(*(int *)ptr));
+ case P_OCTAL: {
+ char *o = octal_string(*(int *)ptr);
+ fprintf(f, "%s", o);
+ TALLOC_FREE(o);
break;
+ }
case P_LIST:
if ((char ***)ptr && *(char ***)ptr) {
char **list = *(char ***)ptr;
-
for (; *list; list++) {
/* surround strings with whitespace in double quotes */
if ( strchr_m( *list, ' ' ) )
}
break;
- case P_GSTRING:
- case P_UGSTRING:
- if ((char *)ptr) {
- fprintf(f, "%s", (char *)ptr);
- }
- break;
-
case P_STRING:
case P_USTRING:
if (*(char **)ptr) {
Check if two parameters are equal.
***************************************************************************/
-static BOOL equal_parameter(parm_type type, void *ptr1, void *ptr2)
+static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
{
switch (type) {
case P_BOOL:
case P_BOOLREV:
- return (*((BOOL *)ptr1) == *((BOOL *)ptr2));
+ return (*((bool *)ptr1) == *((bool *)ptr2));
case P_INTEGER:
case P_ENUM:
case P_CHAR:
return (*((char *)ptr1) == *((char *)ptr2));
-
+
case P_LIST:
return str_list_compare(*(char ***)ptr1, *(char ***)ptr2);
- case P_GSTRING:
- case P_UGSTRING:
- {
- char *p1 = (char *)ptr1, *p2 = (char *)ptr2;
- if (p1 && !*p1)
- p1 = NULL;
- if (p2 && !*p2)
- p2 = NULL;
- return (p1 == p2 || strequal(p1, p2));
- }
case P_STRING:
case P_USTRING:
{
Returns True on success, False on failure.
***************************************************************************/
-static BOOL do_section(const char *pszSectionName)
+static bool do_section(const char *pszSectionName)
{
- BOOL bRetval;
- BOOL isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
+ bool bRetval;
+ bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
(strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
bRetval = False;
Determine if a partcular base parameter is currentl set to the default value.
***************************************************************************/
-static BOOL is_default(int i)
+static bool is_default(int i)
{
if (!defaults_saved)
return False;
case P_USTRING:
return strequal(parm_table[i].def.svalue,
*(char **)parm_table[i].ptr);
- case P_GSTRING:
- case P_UGSTRING:
- return strequal(parm_table[i].def.svalue,
- (char *)parm_table[i].ptr);
case P_BOOL:
case P_BOOLREV:
return parm_table[i].def.bvalue ==
- *(BOOL *)parm_table[i].ptr;
+ *(bool *)parm_table[i].ptr;
case P_CHAR:
return parm_table[i].def.cvalue ==
*(char *)parm_table[i].ptr;
Return True if a local parameter is currently set to the global default.
***************************************************************************/
-BOOL lp_is_default(int snum, struct parm_struct *parm)
+bool lp_is_default(int snum, struct parm_struct *parm)
{
int pdiff = PTR_DIFF(parm->ptr, &sDefault);
Display the contents of a parameter of a single services record.
***************************************************************************/
-BOOL dump_a_parameter(int snum, char *parm_name, FILE * f, BOOL isGlobal)
+bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
{
int i;
- BOOL result = False;
+ bool result = False;
parm_class p_class;
unsigned flag = 0;
fstring local_parm_name;
}
/***************************************************************************
- 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.
***************************************************************************/
&& (parm_table[*i].ptr ==
parm_table[(*i) - 1].ptr))
continue;
+
+ if (is_default(*i) && !allparameters)
+ continue;
return &parm_table[(*i)++];
}
/***************************************************************************
Display the contents of a single copy structure.
***************************************************************************/
-static void dump_copy_map(BOOL *pcopymap)
+static void dump_copy_map(bool *pcopymap)
{
int i;
if (!pcopymap)
Return TRUE if the passed service number is within range.
***************************************************************************/
-BOOL lp_snum_ok(int iService)
+bool lp_snum_ok(int iService)
{
return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
}
homes = lp_servicenumber(HOMES_NAME);
for (p = strtok(s, LIST_SEP); p; p = strtok(NULL, LIST_SEP)) {
- char *home = get_user_home_dir(p);
+ char *home;
if (lp_servicenumber(p) >= 0)
continue;
+ home = get_user_home_dir(talloc_tos(), p);
+
if (home && homes >= 0)
lp_add_home(p, homes, p, home);
+
+ TALLOC_FREE(home);
}
SAFE_FREE(s);
}
Have we loaded a services file yet?
***************************************************************************/
-BOOL lp_loaded(void)
+bool lp_loaded(void)
{
return (bLoaded);
}
Unload unused services.
***************************************************************************/
-void lp_killunused(BOOL (*snumused) (int))
+void lp_killunused(bool (*snumused) (int))
{
int i;
for (i = 0; i < iNumServices; i++) {
parm_table[i].def.svalue = NULL;
}
break;
- case P_GSTRING:
- case P_UGSTRING:
- if (parm_table[i].ptr) {
- parm_table[i].def.svalue = SMB_STRDUP((char *)parm_table[i].ptr);
- } else {
- parm_table[i].def.svalue = NULL;
- }
- break;
case P_BOOL:
case P_BOOLREV:
parm_table[i].def.bvalue =
- *(BOOL *)parm_table[i].ptr;
+ *(bool *)parm_table[i].ptr;
break;
case P_CHAR:
parm_table[i].def.cvalue =
case SEC_USER:
if (lp_domain_logons()) {
- if (Globals.bDomainMaster) /* auto or yes */
+ if (Globals.iDomainMaster) /* auto or yes */
server_role = ROLE_DOMAIN_PDC;
else
server_role = ROLE_DOMAIN_BDC;
get their sorry ass fired.
***************************************************************************/
-static BOOL check_usershare_stat(const char *fname, SMB_STRUCT_STAT *psbuf)
+static bool check_usershare_stat(const char *fname, SMB_STRUCT_STAT *psbuf)
{
if (!S_ISREG(psbuf->st_mode)) {
DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
Parse the contents of a usershare file.
***************************************************************************/
-enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
+enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
SMB_STRUCT_STAT *psbuf,
const char *servicename,
int snum,
char **lines,
int numlines,
- pstring sharepath,
- pstring comment,
+ char **pp_sharepath,
+ char **pp_comment,
SEC_DESC **ppsd,
- BOOL *pallow_guest)
+ bool *pallow_guest)
{
const char **prefixallowlist = lp_usershare_prefix_allow_list();
const char **prefixdenylist = lp_usershare_prefix_deny_list();
int us_vers;
SMB_STRUCT_DIR *dp;
SMB_STRUCT_STAT sbuf;
+ char *sharepath = NULL;
+ char *comment = NULL;
+
+ *pp_sharepath = NULL;
+ *pp_comment = NULL;
*pallow_guest = False;
return USERSHARE_MALFORMED_PATH;
}
- pstrcpy(sharepath, &lines[1][5]);
+ sharepath = talloc_strdup(ctx, &lines[1][5]);
+ if (!sharepath) {
+ return USERSHARE_POSIX_ERR;
+ }
trim_string(sharepath, " ", " ");
if (strncmp(lines[2], "comment=", 8) != 0) {
return USERSHARE_MALFORMED_COMMENT_DEF;
}
- pstrcpy(comment, &lines[2][8]);
+ comment = talloc_strdup(ctx, &lines[2][8]);
+ if (!comment) {
+ return USERSHARE_POSIX_ERR;
+ }
trim_string(comment, " ", " ");
trim_char(comment, '"', '"');
if (snum != -1 && (strcmp(sharepath, ServicePtrs[snum]->szPath) == 0)) {
/* Path didn't change, no checks needed. */
+ *pp_sharepath = sharepath;
+ *pp_comment = comment;
return USERSHARE_OK;
}
}
}
+ *pp_sharepath = sharepath;
+ *pp_comment = comment;
return USERSHARE_OK;
}
{
SMB_STRUCT_STAT sbuf;
SMB_STRUCT_STAT lsbuf;
- pstring fname;
- pstring sharepath;
- pstring comment;
+ char *fname = NULL;
+ char *sharepath = NULL;
+ char *comment = NULL;
fstring service_name;
char **lines = NULL;
int numlines = 0;
int iService = -1;
TALLOC_CTX *ctx = NULL;
SEC_DESC *psd = NULL;
- BOOL guest_ok = False;
+ bool guest_ok = False;
/* Ensure share name doesn't contain invalid characters. */
if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
fstrcpy(service_name, file_name);
- pstrcpy(fname, dir_name);
- pstrcat(fname, "/");
- pstrcat(fname, file_name);
+ if (asprintf(&fname, "%s/%s", dir_name, file_name) < 0) {
+ }
/* Minimize the race condition by doing an lstat before we
open and fstat. Ensure this isn't a symlink link. */
if (sys_lstat(fname, &lsbuf) != 0) {
DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
fname, strerror(errno) ));
+ SAFE_FREE(fname);
return -1;
}
/* This must be a regular file, not a symlink, directory or
other strange filetype. */
if (!check_usershare_stat(fname, &lsbuf)) {
+ SAFE_FREE(fname);
return -1;
}
- /* See if there is already a servicenum for this name. */
- /* tdb_fetch_int32 returns -1 if not found. */
- iService = (int)tdb_fetch_int32(ServiceHash, canonicalize_servicename(service_name) );
+ {
+ char *canon_name = canonicalize_servicename(service_name);
+ TDB_DATA data = dbwrap_fetch_bystring(
+ ServiceHash, canon_name, canon_name);
+
+ iService = -1;
+
+ if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) {
+ iService = *(int *)data.dptr;
+ }
+ TALLOC_FREE(canon_name);
+ }
if (iService != -1 && ServicePtrs[iService]->usershare_last_mod == lsbuf.st_mtime) {
/* Nothing changed - Mark valid and return. */
DEBUG(10,("process_usershare_file: service %s not changed.\n",
service_name ));
ServicePtrs[iService]->usershare = USERSHARE_VALID;
+ SAFE_FREE(fname);
return iService;
}
if (fd == -1) {
DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
fname, strerror(errno) ));
+ SAFE_FREE(fname);
return -1;
}
close(fd);
DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
fname, strerror(errno) ));
+ SAFE_FREE(fname);
return -1;
}
close(fd);
DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
"Symlink spoofing going on ?\n", fname ));
+ SAFE_FREE(fname);
return -1;
}
/* This must be a regular file, not a symlink, directory or
other strange filetype. */
if (!check_usershare_stat(fname, &sbuf)) {
+ SAFE_FREE(fname);
return -1;
}
if (lines == NULL) {
DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
fname, (unsigned int)sbuf.st_uid ));
+ SAFE_FREE(fname);
return -1;
}
+ SAFE_FREE(fname);
+
/* Should we allow printers to be shared... ? */
ctx = talloc_init("usershare_sd_xctx");
if (!ctx) {
}
if (parse_usershare_file(ctx, &sbuf, service_name,
- iService, lines, numlines, sharepath,
- comment, &psd, &guest_ok) != USERSHARE_OK) {
+ iService, lines, numlines, &sharepath,
+ &comment, &psd, &guest_ok) != USERSHARE_OK) {
talloc_destroy(ctx);
file_lines_free(lines);
return -1;
return -1;
}
- talloc_destroy(ctx);
-
/* If from a template it may be marked invalid. */
ServicePtrs[iService]->valid = True;
string_set(&ServicePtrs[iService]->szPath, sharepath);
string_set(&ServicePtrs[iService]->comment, comment);
+ talloc_destroy(ctx);
+
return iService;
}
Checks if a usershare entry has been modified since last load.
***************************************************************************/
-static BOOL usershare_exists(int iService, time_t *last_mod)
+static bool usershare_exists(int iService, time_t *last_mod)
{
SMB_STRUCT_STAT lsbuf;
const char *usersharepath = Globals.szUsersharePath;
- pstring fname;
+ char *fname;
- pstrcpy(fname, usersharepath);
- pstrcat(fname, "/");
- pstrcat(fname, ServicePtrs[iService]->szService);
+ if (asprintf(&fname, "%s/%s",
+ usersharepath,
+ ServicePtrs[iService]->szService) < 0) {
+ return false;
+ }
if (sys_lstat(fname, &lsbuf) != 0) {
- return False;
+ SAFE_FREE(fname);
+ return false;
}
if (!S_ISREG(lsbuf.st_mode)) {
- return False;
+ SAFE_FREE(fname);
+ return false;
}
+ SAFE_FREE(fname);
*last_mod = lsbuf.st_mtime;
- return True;
+ return true;
}
/***************************************************************************
/* Remove from the share ACL db. */
DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
lp_servicename(iService) ));
- delete_share_security(snum2params_static(iService));
+ delete_share_security(lp_servicename(iService));
free_service_byindex(iService);
}
}
struct file_lists *next;
int i;
- lp_TALLOC_FREE();
-
/* Free the file lists */
f = file_lists;
False on failure.
***************************************************************************/
-BOOL lp_load(const char *pszFname,
- BOOL global_only,
- BOOL save_defaults,
- BOOL add_ipc,
- BOOL initialize_globals)
+bool lp_load(const char *pszFname,
+ bool global_only,
+ bool save_defaults,
+ bool add_ipc,
+ bool initialize_globals)
{
- pstring n2;
- BOOL bRetval;
+ char *n2 = NULL;
+ bool bRetval;
param_opt_struct *data, *pdata;
- pstrcpy(n2, pszFname);
-
- standard_sub_basic( get_current_username(), current_user_info.domain,
- n2,sizeof(n2) );
+ n2 = alloc_sub_basic(get_current_username(),
+ current_user_info.domain,
+ pszFname);
+ if (!n2) {
+ smb_panic("lp_load: out of memory");
+ }
add_to_file_list(pszFname, n2);
bRetval = False;
DEBUG(3, ("lp_load: refreshing parameters\n"));
-
+
bInGlobalSection = True;
bGlobalOnly = global_only;
}
Globals.param_opt = NULL;
}
-
+
/* We get sections first, so have to start 'behind' to make up */
iServiceIndex = -1;
bRetval = pm_process(n2, do_section, do_parameter);
+ SAFE_FREE(n2);
/* finish up the last section */
DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
- if (bRetval)
- if (iServiceIndex >= 0)
+ if (bRetval) {
+ if (iServiceIndex >= 0) {
bRetval = service_ok(iServiceIndex);
+ }
+ }
lp_add_auto_services(lp_auto_services());
/* When 'restrict anonymous = 2' guest connections to ipc$
are denied */
lp_add_ipc("IPC$", (lp_restrict_anonymous() < 2));
- if ( lp_enable_asu_support() )
- lp_add_ipc("ADMIN$", False);
+ if ( lp_enable_asu_support() ) {
+ lp_add_ipc("ADMIN$", false);
+ }
}
set_server_role();
Display the contents of the services array in human-readable form.
***************************************************************************/
-void lp_dump(FILE *f, BOOL show_defaults, int maxtoprint)
+void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
{
int iService;
Display the contents of one service in human-readable form.
***************************************************************************/
-void lp_dump_one(FILE * f, BOOL show_defaults, int snum)
+void lp_dump_one(FILE * f, bool show_defaults, int snum)
{
if (VALID(snum)) {
if (ServicePtrs[snum]->szService[0] == '\0')
if (!usershare_exists(iService, &last_mod)) {
/* Remove the share security tdb entry for it. */
- delete_share_security(snum2params_static(iService));
+ delete_share_security(lp_servicename(iService));
/* Remove it from the array. */
free_service_byindex(iService);
/* Doesn't exist anymore. */
return (iService);
}
-BOOL share_defined(const char *service_name)
+bool share_defined(const char *service_name)
{
return (lp_servicenumber(service_name) != -1);
}
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.
********************************************************************/
If we are PDC then prefer us as DMB
************************************************************/
-BOOL lp_domain_master(void)
+bool lp_domain_master(void)
{
- if (Globals.bDomainMaster == Auto)
+ if (Globals.iDomainMaster == Auto)
return (lp_server_role() == ROLE_DOMAIN_PDC);
- return Globals.bDomainMaster;
+ return (bool)Globals.iDomainMaster;
}
/***********************************************************
If we are DMB then prefer us as LMB
************************************************************/
-BOOL lp_preferred_master(void)
+bool lp_preferred_master(void)
{
- if (Globals.bPreferredMaster == Auto)
+ if (Globals.iPreferredMaster == Auto)
return (lp_local_master() && lp_domain_master());
- return Globals.bPreferredMaster;
+ return (bool)Globals.iPreferredMaster;
}
/*******************************************************************
int lp_major_announce_version(void)
{
- static BOOL got_major = False;
+ static bool got_major = False;
static int major_version = DEFAULT_MAJOR_VERSION;
char *vers;
char *p;
int lp_minor_announce_version(void)
{
- static BOOL got_minor = False;
+ static bool got_minor = False;
static int minor_version = DEFAULT_MINOR_VERSION;
char *vers;
char *p;
void lp_set_logfile(const char *name)
{
string_set(&Globals.szLogFile, name);
- pstrcpy(debugf, name);
+ debug_set_logfile(name);
}
/*******************************************************************
static uint32 spoolss_state;
-BOOL lp_disable_spoolss( void )
+bool lp_disable_spoolss( void )
{
if ( spoolss_state == SVCCTL_STATE_UNKNOWN )
spoolss_state = _lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
Ensure we don't use sendfile if server smb signing is active.
********************************************************************/
-BOOL lp_use_sendfile(int snum)
+bool lp_use_sendfile(int snum)
{
/* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */
if (Protocol < PROTOCOL_NT1) {
return False;
}
- return (_lp_use_sendfile(snum) && (get_remote_arch() != RA_WIN95) && !srv_is_signing_active());
+ return (_lp_use_sendfile(snum) &&
+ (get_remote_arch() != RA_WIN95) &&
+ !srv_is_signing_active());
}
/*******************************************************************
Turn off sendfile if we find the underlying OS doesn't support it.
********************************************************************/
-void set_use_sendfile(int snum, BOOL val)
+void set_use_sendfile(int snum, bool val)
{
if (LP_SNUM_OK(snum))
ServicePtrs[snum]->bUseSendfile = val;
Turn off storing DOS attributes if this share doesn't support it.
********************************************************************/
-void set_store_dos_attributes(int snum, BOOL val)
+void set_store_dos_attributes(int snum, bool val)
{
if (!LP_SNUM_OK(snum))
return;
Global state for POSIX pathname processing.
********************************************************************/
-static BOOL posix_pathnames;
+static bool posix_pathnames;
-BOOL lp_posix_pathnames(void)
+bool lp_posix_pathnames(void)
{
return posix_pathnames;
}
Global state for POSIX lock processing - CIFS unix extensions.
********************************************************************/
-BOOL posix_default_lock_was_set;
+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(files_struct *fsp)
posix_default_lock_was_set = True;
posix_cifsx_locktype = val;
}
+
+int lp_min_receive_file_size(void)
+{
+ if (Globals.iminreceivefile < 0) {
+ return 0;
+ }
+ return MIN(Globals.iminreceivefile, BUFFER_SIZE);
+}