#include "ads.h"
#include "../librpc/gen_ndr/svcctl.h"
+#include "smb_signing.h"
+#include "dbwrap.h"
+#include "smbldap.h"
+
#ifdef HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h>
#endif
char *key;
char *value;
char **list;
+ unsigned flags;
};
/*
int oplock_break_wait_time;
int winbind_cache_time;
int winbind_reconnect_delay;
- int winbind_max_idle_children;
+ int winbind_max_clients;
char **szWinbindNssInfo;
int iLockSpinTime;
char *szLdapMachineSuffix;
char *szSMBPerfcountModule;
bool bMapUntrustedToDomain;
bool bAsyncSMBEchoHandler;
+ bool bMulticastDnsRegister;
int ismb2_max_read;
int ismb2_max_write;
int ismb2_max_trans;
+ char *ncalrpc_dir;
};
static struct global Globals;
static void *lp_local_ptr(struct service *service, void *ptr);
static void add_to_file_list(const char *fname, const char *subfname);
+static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values);
static const struct enum_list enum_protocol[] = {
{PROTOCOL_SMB2, "SMB2"},
.enum_list = NULL,
.flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
},
- {
- .label = "update encrypted",
- .type = P_BOOL,
- .p_class = P_GLOBAL,
- .ptr = &Globals.bUpdateEncrypt,
- .special = NULL,
- .enum_list = NULL,
- .flags = FLAG_ADVANCED,
- },
{
.label = "client schannel",
.type = P_ENUM,
.enum_list = NULL,
.flags = FLAG_ADVANCED | FLAG_GLOBAL,
},
+ {
+ .label = "multicast dns register",
+ .type = P_BOOL,
+ .p_class = P_GLOBAL,
+ .ptr = &Globals.bMulticastDnsRegister,
+ .special = NULL,
+ .enum_list = NULL,
+ .flags = FLAG_ADVANCED | FLAG_GLOBAL,
+ },
{
.label = "panic action",
.type = P_STRING,
.enum_list = NULL,
.flags = FLAG_ADVANCED,
},
+ {
+ .label = "winbind max clients",
+ .type = P_INTEGER,
+ .p_class = P_GLOBAL,
+ .ptr = &Globals.winbind_max_clients,
+ .special = NULL,
+ .enum_list = NULL,
+ .flags = FLAG_ADVANCED,
+ },
{
.label = "winbind enum users",
.type = P_BOOL,
.enum_list = NULL,
.flags = FLAG_ADVANCED,
},
+ {
+ .label = "ncalrpc dir",
+ .type = P_STRING,
+ .p_class = P_GLOBAL,
+ .ptr = &Globals.ncalrpc_dir,
+ .special = NULL,
+ .enum_list = NULL,
+ .flags = FLAG_ADVANCED,
+ },
{NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
};
free_parameters_by_snum(GLOBAL_SECTION_SNUM);
}
+static int map_parameter(const char *pszParmName);
+
+struct lp_stored_option {
+ struct lp_stored_option *prev, *next;
+ const char *label;
+ const char *value;
+};
+
+static struct lp_stored_option *stored_options;
+
+/*
+ save options set by lp_set_cmdline() into a list. This list is
+ re-applied when we do a globals reset, so that cmdline set options
+ are sticky across reloads of smb.conf
+ */
+static bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
+{
+ struct lp_stored_option *entry, *entry_next;
+ for (entry = stored_options; entry != NULL; entry = entry_next) {
+ entry_next = entry->next;
+ if (strcmp(pszParmName, entry->label) == 0) {
+ DLIST_REMOVE(stored_options, entry);
+ talloc_free(entry);
+ break;
+ }
+ }
+
+ entry = talloc(NULL, struct lp_stored_option);
+ if (!entry) {
+ return false;
+ }
+
+ entry->label = talloc_strdup(entry, pszParmName);
+ if (!entry->label) {
+ talloc_free(entry);
+ return false;
+ }
+
+ entry->value = talloc_strdup(entry, pszParmValue);
+ if (!entry->value) {
+ talloc_free(entry);
+ return false;
+ }
+
+ DLIST_ADD_END(stored_options, entry, struct lp_stored_option);
+
+ return true;
+}
+
+static bool apply_lp_set_cmdline(void)
+{
+ struct lp_stored_option *entry = NULL;
+ for (entry = stored_options; entry != NULL; entry = entry->next) {
+ if (!lp_set_cmdline_helper(entry->label, entry->value, false)) {
+ DEBUG(0, ("Failed to re-apply cmdline parameter %s = %s\n",
+ entry->label, entry->value));
+ return false;
+ }
+ }
+ return true;
+}
+
/***************************************************************************
Initialise the global parameter structure.
***************************************************************************/
-static void init_globals(bool first_time_only)
+static void init_globals(bool reinit_globals)
{
static bool done_init = False;
char *s = NULL;
int i;
/* If requested to initialize only once and we've already done it... */
- if (first_time_only && done_init) {
+ if (!reinit_globals && done_init) {
/* ... then we have nothing more to do */
return;
}
free_global_parameters();
}
+ /* This memset and the free_global_parameters() above will
+ * wipe out smb.conf options set with lp_set_cmdline(). The
+ * apply_lp_set_cmdline() call puts these values back in the
+ * table once the defaults are set */
memset((void *)&Globals, '\0', sizeof(Globals));
for (i = 0; parm_table[i].label; i++) {
Globals.winbind_cache_time = 300; /* 5 minutes */
Globals.winbind_reconnect_delay = 30; /* 30 seconds */
+ Globals.winbind_max_clients = 200;
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_v3(talloc_autofree_context(), "template", NULL);
+ Globals.szWinbindNssInfo = str_list_make_v3(NULL, "template", NULL);
Globals.bWinbindRefreshTickets = False;
Globals.bWinbindOfflineLogon = False;
Globals.iminreceivefile = 0;
Globals.bMapUntrustedToDomain = false;
+ Globals.bMulticastDnsRegister = true;
Globals.ismb2_max_read = 1024*1024;
Globals.ismb2_max_write = 1024*1024;
Globals.ismb2_max_trans = 1024*1024;
+
+ string_set(&Globals.ncalrpc_dir, get_dyn_NCALRPCDIR());
+
+ /* Now put back the settings that were set with lp_set_cmdline() */
+ apply_lp_set_cmdline();
}
/*******************************************************************
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) \
- char *fn_name(const struct share_params *p) {return(lp_string((LP_SNUM_OK(p->service) && ServicePtrs[(p->service)]->val) ? ServicePtrs[(p->service)]->val : sDefault.val));}
#define FN_LOCAL_CHAR(fn_name,val) \
char fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
-FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)
FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel)
FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
FN_GLOBAL_BOOL(lp_async_smb_echo_handler, &Globals.bAsyncSMBEchoHandler)
+FN_GLOBAL_BOOL(lp_multicast_dns_register, &Globals.bMulticastDnsRegister)
FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
FN_LOCAL_CHAR(lp_magicchar, magic_char)
FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, &Globals.winbind_reconnect_delay)
+FN_GLOBAL_INTEGER(lp_winbind_max_clients, &Globals.winbind_max_clients)
FN_GLOBAL_LIST(lp_winbind_nss_info, &Globals.szWinbindNssInfo)
FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase)
FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing)
FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrapping)
+FN_GLOBAL_STRING(lp_ncalrpc_dir, &Globals.ncalrpc_dir)
+
/* local prototypes */
-static int map_parameter(const char *pszParmName);
static int map_parameter_canonical(const char *pszParmName, bool *inverse);
static const char *get_boolean(bool bool_value);
static int getservicebyname(const char *pszServiceName,
return (const char **)def;
if (data->list==NULL) {
- data->list = str_list_make_v3(talloc_autofree_context(), data->value, NULL);
+ data->list = str_list_make_v3(NULL, data->value, NULL);
}
return (const char **)data->list;
if (name) {
i = getservicebyname(name, NULL);
if (i >= 0) {
- /* Clean all parametric options for service */
- /* They will be added during parsing again */
- free_param_opts(&ServicePtrs[i]->param_opt);
return (i);
}
}
*/
static void set_param_opt(struct param_opt_struct **opt_list,
const char *opt_name,
- const char *opt_value)
+ const char *opt_value,
+ unsigned flags)
{
struct param_opt_struct *new_opt, *opt;
bool not_added;
while (opt) {
/* If we already have same option, override it */
if (strwicmp(opt->key, opt_name) == 0) {
+ if ((opt->flags & FLAG_CMDLINE) &&
+ !(flags & FLAG_CMDLINE)) {
+ /* it's been marked as not to be
+ overridden */
+ return;
+ }
string_free(&opt->value);
TALLOC_FREE(opt->list);
opt->value = SMB_STRDUP(opt_value);
+ opt->flags = flags;
not_added = false;
break;
}
new_opt->key = SMB_STRDUP(opt_name);
new_opt->value = SMB_STRDUP(opt_value);
new_opt->list = NULL;
+ new_opt->flags = flags;
DLIST_ADD(*opt_list, new_opt);
}
}
data = pserviceSource->param_opt;
while (data) {
- set_param_opt(&pserviceDest->param_opt, data->key, data->value);
+ set_param_opt(&pserviceDest->param_opt, data->key, data->value, data->flags);
data = data->next;
}
}
static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr)
{
TALLOC_FREE(Globals.szNetbiosAliases);
- Globals.szNetbiosAliases = str_list_make_v3(talloc_autofree_context(), pszParmValue, NULL);
+ Globals.szNetbiosAliases = str_list_make_v3(NULL, pszParmValue, NULL);
return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
}
TALLOC_FREE(pservice->copymap);
- pservice->copymap = bitmap_talloc(talloc_autofree_context(),
- NUMPARAMETERS);
+ pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS);
if (!pservice->copymap)
DEBUG(0,
("Couldn't allocate copymap!! (size %d)\n",
opt_list = (snum < 0)
? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
- set_param_opt(opt_list, pszParmName, pszParmValue);
+ set_param_opt(opt_list, pszParmName, pszParmValue, 0);
return (True);
}
+ /* if it's already been set by the command line, then we don't
+ override here */
+ if (parm_table[parmnum].flags & FLAG_CMDLINE) {
+ return true;
+ }
+
if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
pszParmName));
case P_LIST:
TALLOC_FREE(*((char ***)parm_ptr));
*(char ***)parm_ptr = str_list_make_v3(
- talloc_autofree_context(), pszParmValue, NULL);
+ NULL, pszParmValue, NULL);
break;
case P_STRING:
return (True);
}
+/***************************************************************************
+set a parameter, marking it with FLAG_CMDLINE. Parameters marked as
+FLAG_CMDLINE won't be overridden by loads from smb.conf.
+***************************************************************************/
+
+static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values)
+{
+ int parmnum, i;
+ parmnum = map_parameter(pszParmName);
+ if (parmnum >= 0) {
+ parm_table[parmnum].flags &= ~FLAG_CMDLINE;
+ if (!lp_do_parameter(-1, pszParmName, pszParmValue)) {
+ return false;
+ }
+ parm_table[parmnum].flags |= FLAG_CMDLINE;
+
+ /* we have to also set FLAG_CMDLINE on aliases. Aliases must
+ * be grouped in the table, so we don't have to search the
+ * whole table */
+ for (i=parmnum-1;i>=0 && parm_table[i].ptr == parm_table[parmnum].ptr;i--) {
+ parm_table[i].flags |= FLAG_CMDLINE;
+ }
+ for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].ptr == parm_table[parmnum].ptr;i++) {
+ parm_table[i].flags |= FLAG_CMDLINE;
+ }
+
+ if (store_values) {
+ store_lp_set_cmdline(pszParmName, pszParmValue);
+ }
+ return true;
+ }
+
+ /* it might be parametric */
+ if (strchr(pszParmName, ':') != NULL) {
+ set_param_opt(&Globals.param_opt, pszParmName, pszParmValue, FLAG_CMDLINE);
+ if (store_values) {
+ store_lp_set_cmdline(pszParmName, pszParmValue);
+ }
+ return true;
+ }
+
+ DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
+ return true;
+}
+
+bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
+{
+ return lp_set_cmdline_helper(pszParmName, pszParmValue, true);
+}
+
/***************************************************************************
Process a parameter.
***************************************************************************/
pszParmName, pszParmValue));
}
-/***************************************************************************
+/*
+ set a option from the commandline in 'a=b' format. Use to support --option
+*/
+bool lp_set_option(const char *option)
+{
+ char *p, *s;
+ bool ret;
+
+ s = talloc_strdup(NULL, option);
+ if (!s) {
+ return false;
+ }
+
+ p = strchr(s, '=');
+ if (!p) {
+ talloc_free(s);
+ return false;
+ }
+
+ *p = 0;
+
+ ret = lp_set_cmdline(s, p+1);
+ talloc_free(s);
+ return ret;
+}
+
+/**************************************************************************
Print a parameter of the specified type.
***************************************************************************/
DEBUG(0, ("Failed to add a new service\n"));
return (False);
}
+ /* Clean all parametric options for service */
+ /* They will be added during parsing again */
+ free_param_opts(&ServicePtrs[iServiceIndex]->param_opt);
}
return (bRetval);
False on failure.
***************************************************************************/
-bool lp_load_ex(const char *pszFname,
- bool global_only,
- bool save_defaults,
- bool add_ipc,
- bool initialize_globals,
- bool allow_include_registry,
- bool allow_registry_shares)
+static bool lp_load_ex(const char *pszFname,
+ bool global_only,
+ bool save_defaults,
+ bool add_ipc,
+ bool initialize_globals,
+ bool allow_include_registry,
+ bool allow_registry_shares)
{
char *n2 = NULL;
bool bRetval;
bGlobalOnly = global_only;
bAllowIncludeRegistry = allow_include_registry;
- init_globals(! initialize_globals);
+ init_globals(initialize_globals);
debug_init();
free_file_list();
/* start over */
DEBUG(1, ("lp_load_ex: changing to config backend "
"registry\n"));
- init_globals(false);
+ init_globals(true);
lp_kill_all_services();
return lp_load_ex(pszFname, global_only, save_defaults,
add_ipc, initialize_globals,
const char *sharename)
{
struct share_params *result;
- char *sname;
+ char *sname = NULL;
int snum;
- if (!(sname = SMB_STRDUP(sharename))) {
- return NULL;
- }
-
- snum = find_service(sname);
- SAFE_FREE(sname);
-
- if (snum < 0) {
+ snum = find_service(mem_ctx, sharename, &sname);
+ if (snum < 0 || sname == NULL) {
return NULL;
}