[PATCH] loadparm: Do not talloc empty params
Stefan Metzmacher
metze at samba.org
Mon Nov 30 08:30:46 UTC 2015
Am 28.11.2015 um 00:26 schrieb Jeremy Allison:
> On Fri, Nov 27, 2015 at 08:20:39PM +0100, Stefan Metzmacher wrote:
>> Am 27.11.2015 um 13:32 schrieb Volker Lendecke:
>>> On Fri, Nov 27, 2015 at 09:30:45AM +0100, Stefan Metzmacher wrote:
>>>> Hi Volker,
>>>>
>>>> Am 27.11.2015 um 07:41 schrieb Volker Lendecke:
>>>>> On Thu, Nov 26, 2015 at 09:26:26PM +0100, Volker Lendecke wrote:
>>>>>> On Thu, Nov 26, 2015 at 09:09:12PM +0100, Volker Lendecke wrote:
>>>>>>> Hi!
>>>>>>>
>>>>>>> Review appreciated!
>>>>>>
>>>>>> Survived autobuild, but obviously buggy. More later.
>>>>>
>>>>> This is better I think.
>>>>>
>>>>> Review appreciated!
>>>>
>>>> What about doing this "" to NULL handling within lpcfg_string_set()
>>>> instead of just one caller.
>>>>
>>>> We could do the same in lpcfg_string_set_upper() in order to be
>>>> consistent...
>>>
>>> Won't work, with such a patch samba.docs fails.
>>
>> I think we need to copy of share the string_set() string_free() logic.
>
> Let's not make the perfect the enemy of the good.
>
> I'll take a look at this next week when I'm back
> in at work, but if it's not a trivial change I
> think we should push Volker's code as-is, and
> tidy up later.
>
> The memory savings are *significant*!
Sure,
here's my alternative it passed two private autobuilds.
I think we should backport this to 4.2 and 4.3 as I
guess it's a regression compared to 4.1 that got
introduced by commit 2dd7c890792cf12049ec13b88aa4e9de23035f9d.
Do we have a bug report already?
metze
-------------- next part --------------
From 4a035d4d69ed8c8dc88c554d068735af7005bec8 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Sat, 28 Nov 2015 10:32:05 +0100
Subject: [PATCH] TODO:BUG: lib/param: add a fixed unified
lpcfg_string_{free,set,set_upper}() infrastructure
This reduces the memory footprint of empty string options.
This fixes a regression introduced by commit
2dd7c890792cf12049ec13b88aa4e9de23035f9d.
BUG:
Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
lib/param/loadparm.c | 48 +++++++++---
source3/param/loadparm.c | 194 +++++++++++++++++++----------------------------
2 files changed, 114 insertions(+), 128 deletions(-)
diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c
index e0711bc..a73b493 100644
--- a/lib/param/loadparm.c
+++ b/lib/param/loadparm.c
@@ -515,16 +515,36 @@ bool lpcfg_parm_bool(struct loadparm_context *lp_ctx,
}
+/* this is used to prevent lots of mallocs of size 1 */
+static const char lpcfg_string_emtpy[] = "";
+
+/**
+ Free a string value.
+**/
+void lpcfg_string_free(char **s)
+{
+ if (s == NULL) {
+ return;
+ }
+ if (*s == lpcfg_string_emtpy) {
+ *s = NULL;
+ return;
+ }
+ TALLOC_FREE(*s);
+}
+
/**
* Set a string value, deallocating any existing space, and allocing the space
* for the string
*/
bool lpcfg_string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
{
- talloc_free(*dest);
+ lpcfg_string_free(dest);
- if (src == NULL)
- src = "";
+ if ((src == NULL) || (*src == '\0')) {
+ *dest = discard_const_p(char, lpcfg_string_emtpy);
+ return true;
+ }
*dest = talloc_strdup(mem_ctx, src);
if ((*dest) == NULL) {
@@ -541,10 +561,12 @@ bool lpcfg_string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
*/
bool lpcfg_string_set_upper(TALLOC_CTX *mem_ctx, char **dest, const char *src)
{
- talloc_free(*dest);
+ lpcfg_string_free(dest);
- if (src == NULL)
- src = "";
+ if ((src == NULL) || (*src == '\0')) {
+ *dest = discard_const_p(char, lpcfg_string_emtpy);
+ return true;
+ }
*dest = strupper_talloc(mem_ctx, src);
if ((*dest) == NULL) {
@@ -816,9 +838,8 @@ void set_param_opt(TALLOC_CTX *mem_ctx,
overridden */
return;
}
- TALLOC_FREE(opt->value);
TALLOC_FREE(opt->list);
- opt->value = talloc_strdup(opt, opt_value);
+ lpcfg_string_set(opt, &opt->value, opt_value);
opt->priority = priority;
return;
}
@@ -831,8 +852,10 @@ void set_param_opt(TALLOC_CTX *mem_ctx,
if (new_opt == NULL) {
smb_panic("OOM");
}
- new_opt->key = talloc_strdup(new_opt, opt_name);
- new_opt->value = talloc_strdup(new_opt, opt_value);
+ new_opt->key = NULL;
+ lpcfg_string_set(new_opt, &new_opt->key, opt_name);
+ new_opt->value = NULL;
+ lpcfg_string_set(new_opt, &new_opt->value, opt_value);
new_opt->list = NULL;
new_opt->priority = priority;
@@ -2445,13 +2468,16 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
if ((parm_table[i].type == P_STRING ||
parm_table[i].type == P_USTRING) &&
!(lp_ctx->flags[i] & FLAG_CMDLINE)) {
+ TALLOC_CTX *parent_mem;
char **r;
if (parm_table[i].p_class == P_LOCAL) {
+ parent_mem = lp_ctx->sDefault;
r = (char **)(((char *)lp_ctx->sDefault) + parm_table[i].offset);
} else {
+ parent_mem = lp_ctx->globals;
r = (char **)(((char *)lp_ctx->globals) + parm_table[i].offset);
}
- *r = talloc_strdup(lp_ctx, "");
+ lpcfg_string_set(parent_mem, r, "");
}
}
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index ff1afd4..c1929ba 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -263,44 +263,6 @@ static void set_allowed_client_auth(void);
static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue);
static void free_param_opts(struct parmlist_entry **popts);
-/* this is used to prevent lots of mallocs of size 1 */
-static const char null_string[] = "";
-
-/**
- Free a string value.
-**/
-
-static void string_free(char **s)
-{
- if (!s || !(*s))
- return;
- if (*s == null_string)
- *s = NULL;
- TALLOC_FREE(*s);
-}
-
-/**
- Set a string value, deallocating any existing space, and allocing the space
- for the string
-**/
-
-static bool string_set(TALLOC_CTX *mem_ctx, char **dest,const char *src)
-{
- string_free(dest);
-
- if (!src) {
- src = "";
- }
-
- (*dest) = talloc_strdup(mem_ctx, src);
- if ((*dest) == NULL) {
- DEBUG(0,("Out of memory in string_init\n"));
- return false;
- }
-
- return true;
-}
-
/**
* Function to return the default value for the maximum number of open
* file descriptors permitted. This function tries to consult the
@@ -364,7 +326,7 @@ static void free_one_parameter_common(void *parm_ptr,
if ((parm.type == P_STRING) ||
(parm.type == P_USTRING))
{
- string_free((char**)parm_ptr);
+ lpcfg_string_free((char**)parm_ptr);
} else if (parm.type == P_LIST || parm.type == P_CMDLIST) {
TALLOC_FREE(*((char***)parm_ptr));
}
@@ -521,10 +483,7 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
if (!done_init) {
/* The logfile can be set before this is invoked. Free it if so. */
- if (Globals.logfile != NULL) {
- string_free(&Globals.logfile);
- Globals.logfile = NULL;
- }
+ lpcfg_string_free(&Globals.logfile);
done_init = true;
} else {
free_global_parameters();
@@ -547,13 +506,13 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
if ((parm_table[i].type == P_STRING ||
parm_table[i].type == P_USTRING))
{
- string_set(Globals.ctx, (char **)lp_parm_ptr(NULL, &parm_table[i]), "");
+ lpcfg_string_set(Globals.ctx, (char **)lp_parm_ptr(NULL, &parm_table[i]), "");
}
}
- string_set(Globals.ctx, &sDefault.fstype, FSTYPE_STRING);
- string_set(Globals.ctx, &sDefault.printjob_username, "%U");
+ lpcfg_string_set(Globals.ctx, &sDefault.fstype, FSTYPE_STRING);
+ lpcfg_string_set(Globals.ctx, &sDefault.printjob_username, "%U");
init_printer_values(lp_ctx, Globals.ctx, &sDefault);
@@ -562,36 +521,36 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
DEBUG(3, ("Initialising global parameters\n"));
/* Must manually force to upper case here, as this does not go via the handler */
- string_set(Globals.ctx, &Globals.netbios_name, myhostname_upper());
+ lpcfg_string_set(Globals.ctx, &Globals.netbios_name, myhostname_upper());
- string_set(Globals.ctx, &Globals.smb_passwd_file, get_dyn_SMB_PASSWD_FILE());
- string_set(Globals.ctx, &Globals.private_dir, get_dyn_PRIVATE_DIR());
+ lpcfg_string_set(Globals.ctx, &Globals.smb_passwd_file, get_dyn_SMB_PASSWD_FILE());
+ lpcfg_string_set(Globals.ctx, &Globals.private_dir, get_dyn_PRIVATE_DIR());
/* use the new 'hash2' method by default, with a prefix of 1 */
- string_set(Globals.ctx, &Globals.mangling_method, "hash2");
+ lpcfg_string_set(Globals.ctx, &Globals.mangling_method, "hash2");
Globals.mangle_prefix = 1;
- string_set(Globals.ctx, &Globals.guest_account, GUEST_ACCOUNT);
+ lpcfg_string_set(Globals.ctx, &Globals.guest_account, GUEST_ACCOUNT);
/* using UTF8 by default allows us to support all chars */
- string_set(Globals.ctx, &Globals.unix_charset, DEFAULT_UNIX_CHARSET);
+ lpcfg_string_set(Globals.ctx, &Globals.unix_charset, DEFAULT_UNIX_CHARSET);
/* Use codepage 850 as a default for the dos character set */
- string_set(Globals.ctx, &Globals.dos_charset, DEFAULT_DOS_CHARSET);
+ lpcfg_string_set(Globals.ctx, &Globals.dos_charset, DEFAULT_DOS_CHARSET);
/*
* Allow the default PASSWD_CHAT to be overridden in local.h.
*/
- string_set(Globals.ctx, &Globals.passwd_chat, DEFAULT_PASSWD_CHAT);
+ lpcfg_string_set(Globals.ctx, &Globals.passwd_chat, DEFAULT_PASSWD_CHAT);
- string_set(Globals.ctx, &Globals.workgroup, DEFAULT_WORKGROUP);
+ lpcfg_string_set(Globals.ctx, &Globals.workgroup, DEFAULT_WORKGROUP);
- string_set(Globals.ctx, &Globals.passwd_program, "");
- string_set(Globals.ctx, &Globals.lock_directory, get_dyn_LOCKDIR());
- string_set(Globals.ctx, &Globals.state_directory, get_dyn_STATEDIR());
- string_set(Globals.ctx, &Globals.cache_directory, get_dyn_CACHEDIR());
- string_set(Globals.ctx, &Globals.pid_directory, get_dyn_PIDDIR());
- string_set(Globals.ctx, &Globals.nbt_client_socket_address, "0.0.0.0");
+ lpcfg_string_set(Globals.ctx, &Globals.passwd_program, "");
+ lpcfg_string_set(Globals.ctx, &Globals.lock_directory, get_dyn_LOCKDIR());
+ lpcfg_string_set(Globals.ctx, &Globals.state_directory, get_dyn_STATEDIR());
+ lpcfg_string_set(Globals.ctx, &Globals.cache_directory, get_dyn_CACHEDIR());
+ lpcfg_string_set(Globals.ctx, &Globals.pid_directory, get_dyn_PIDDIR());
+ lpcfg_string_set(Globals.ctx, &Globals.nbt_client_socket_address, "0.0.0.0");
/*
* By default support explicit binding to broadcast
* addresses.
@@ -602,21 +561,21 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
if (s == NULL) {
smb_panic("init_globals: ENOMEM");
}
- string_set(Globals.ctx, &Globals.server_string, s);
+ lpcfg_string_set(Globals.ctx, &Globals.server_string, s);
TALLOC_FREE(s);
#ifdef DEVELOPER
- string_set(Globals.ctx, &Globals.panic_action, "/bin/sleep 999999999");
+ lpcfg_string_set(Globals.ctx, &Globals.panic_action, "/bin/sleep 999999999");
#endif
- string_set(Globals.ctx, &Globals.socket_options, DEFAULT_SOCKET_OPTIONS);
+ lpcfg_string_set(Globals.ctx, &Globals.socket_options, DEFAULT_SOCKET_OPTIONS);
- string_set(Globals.ctx, &Globals.logon_drive, "");
+ lpcfg_string_set(Globals.ctx, &Globals.logon_drive, "");
/* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
- string_set(Globals.ctx, &Globals.logon_home, "\\\\%N\\%U");
- string_set(Globals.ctx, &Globals.logon_path, "\\\\%N\\%U\\profile");
+ lpcfg_string_set(Globals.ctx, &Globals.logon_home, "\\\\%N\\%U");
+ lpcfg_string_set(Globals.ctx, &Globals.logon_path, "\\\\%N\\%U\\profile");
Globals.name_resolve_order = str_list_make_v3_const(NULL, "lmhosts wins host bcast", NULL);
- string_set(Globals.ctx, &Globals.password_server, "*");
+ lpcfg_string_set(Globals.ctx, &Globals.password_server, "*");
Globals.algorithmic_rid_base = BASE_RID;
@@ -657,7 +616,7 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
Globals.syslog = 1;
Globals.syslog_only = false;
Globals.timestamp_logs = true;
- string_set(Globals.ctx, &Globals.log_level, "0");
+ lpcfg_string_set(Globals.ctx, &Globals.log_level, "0");
Globals.debug_prefix_timestamp = false;
Globals.debug_hires_timestamp = true;
Globals.debug_pid = false;
@@ -673,9 +632,9 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
#if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
Globals.nis_homedir = false;
#ifdef WITH_NISPLUS_HOME
- string_set(Globals.ctx, &Globals.homedir_map, "auto_home.org_dir");
+ lpcfg_string_set(Globals.ctx, &Globals.homedir_map, "auto_home.org_dir");
#else
- string_set(Globals.ctx, &Globals.homedir_map, "auto.home");
+ lpcfg_string_set(Globals.ctx, &Globals.homedir_map, "auto.home");
#endif
#endif
Globals.time_server = false;
@@ -720,14 +679,14 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
Globals.change_notify = true,
Globals.kernel_change_notify = true,
- string_set(Globals.ctx, &Globals.passdb_backend, "tdbsam");
- string_set(Globals.ctx, &Globals.ldap_suffix, "");
- string_set(Globals.ctx, &Globals._ldap_machine_suffix, "");
- string_set(Globals.ctx, &Globals._ldap_user_suffix, "");
- string_set(Globals.ctx, &Globals._ldap_group_suffix, "");
- string_set(Globals.ctx, &Globals._ldap_idmap_suffix, "");
+ lpcfg_string_set(Globals.ctx, &Globals.passdb_backend, "tdbsam");
+ lpcfg_string_set(Globals.ctx, &Globals.ldap_suffix, "");
+ lpcfg_string_set(Globals.ctx, &Globals._ldap_machine_suffix, "");
+ lpcfg_string_set(Globals.ctx, &Globals._ldap_user_suffix, "");
+ lpcfg_string_set(Globals.ctx, &Globals._ldap_group_suffix, "");
+ lpcfg_string_set(Globals.ctx, &Globals._ldap_idmap_suffix, "");
- string_set(Globals.ctx, &Globals.ldap_admin_dn, "");
+ lpcfg_string_set(Globals.ctx, &Globals.ldap_admin_dn, "");
Globals.ldap_ssl = LDAP_SSL_START_TLS;
Globals.ldap_ssl_ads = false;
Globals.ldap_deref = -1;
@@ -777,17 +736,17 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
Globals.wins_dns_proxy = true;
Globals.allow_trusted_domains = true;
- string_set(Globals.ctx, &Globals.idmap_backend, "tdb");
+ lpcfg_string_set(Globals.ctx, &Globals.idmap_backend, "tdb");
- string_set(Globals.ctx, &Globals.template_shell, "/bin/false");
- string_set(Globals.ctx, &Globals.template_homedir, "/home/%D/%U");
- string_set(Globals.ctx, &Globals.winbind_separator, "\\");
- string_set(Globals.ctx, &Globals.winbindd_socket_directory, dyn_WINBINDD_SOCKET_DIR);
+ lpcfg_string_set(Globals.ctx, &Globals.template_shell, "/bin/false");
+ lpcfg_string_set(Globals.ctx, &Globals.template_homedir, "/home/%D/%U");
+ lpcfg_string_set(Globals.ctx, &Globals.winbind_separator, "\\");
+ lpcfg_string_set(Globals.ctx, &Globals.winbindd_socket_directory, dyn_WINBINDD_SOCKET_DIR);
- string_set(Globals.ctx, &Globals.cups_server, "");
- string_set(Globals.ctx, &Globals.iprint_server, "");
+ lpcfg_string_set(Globals.ctx, &Globals.cups_server, "");
+ lpcfg_string_set(Globals.ctx, &Globals.iprint_server, "");
- string_set(Globals.ctx, &Globals._ctdbd_socket, "");
+ lpcfg_string_set(Globals.ctx, &Globals._ctdbd_socket, "");
Globals.cluster_addresses = NULL;
Globals.clustering = false;
@@ -833,9 +792,9 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
if (s == NULL) {
smb_panic("init_globals: ENOMEM");
}
- string_set(Globals.ctx, &Globals.usershare_path, s);
+ lpcfg_string_set(Globals.ctx, &Globals.usershare_path, s);
TALLOC_FREE(s);
- string_set(Globals.ctx, &Globals.usershare_template_share, "");
+ lpcfg_string_set(Globals.ctx, &Globals.usershare_template_share, "");
Globals.usershare_max_shares = 0;
/* By default disallow sharing of directories not owned by the sharer. */
Globals.usershare_owner_only = true;
@@ -858,7 +817,7 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
Globals.smb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
Globals.smb2_leases = false;
- string_set(Globals.ctx, &Globals.ncalrpc_dir, get_dyn_NCALRPCDIR());
+ lpcfg_string_set(Globals.ctx, &Globals.ncalrpc_dir, get_dyn_NCALRPCDIR());
Globals.server_services = str_list_make_v3_const(NULL, "s3fs rpc nbt wrepl ldap cldap kdc drepl winbindd ntp_signd kcc dnsupdate dns", NULL);
@@ -866,20 +825,20 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
Globals.tls_enabled = true;
- string_set(Globals.ctx, &Globals._tls_keyfile, "tls/key.pem");
- string_set(Globals.ctx, &Globals._tls_certfile, "tls/cert.pem");
- string_set(Globals.ctx, &Globals._tls_cafile, "tls/ca.pem");
- string_set(Globals.ctx, &Globals.tls_priority, "NORMAL:-VERS-SSL3.0");
+ lpcfg_string_set(Globals.ctx, &Globals._tls_keyfile, "tls/key.pem");
+ lpcfg_string_set(Globals.ctx, &Globals._tls_certfile, "tls/cert.pem");
+ lpcfg_string_set(Globals.ctx, &Globals._tls_cafile, "tls/ca.pem");
+ lpcfg_string_set(Globals.ctx, &Globals.tls_priority, "NORMAL:-VERS-SSL3.0");
- string_set(Globals.ctx, &Globals.share_backend, "classic");
+ lpcfg_string_set(Globals.ctx, &Globals.share_backend, "classic");
Globals._preferred_master = Auto;
Globals.allow_dns_updates = DNS_UPDATE_SIGNED;
- string_set(Globals.ctx, &Globals.ntp_signd_socket_directory, get_dyn_NTP_SIGND_SOCKET_DIR());
+ lpcfg_string_set(Globals.ctx, &Globals.ntp_signd_socket_directory, get_dyn_NTP_SIGND_SOCKET_DIR());
- string_set(Globals.ctx, &Globals.winbindd_privileged_socket_directory, get_dyn_WINBINDD_PRIVILEGED_SOCKET_DIR());
+ lpcfg_string_set(Globals.ctx, &Globals.winbindd_privileged_socket_directory, get_dyn_WINBINDD_PRIVILEGED_SOCKET_DIR());
s = talloc_asprintf(talloc_tos(), "%s/samba_kcc", get_dyn_SCRIPTSBINDIR());
if (s == NULL) {
@@ -1284,8 +1243,8 @@ static void free_param_opts(struct parmlist_entry **popts)
}
opt = *popts;
while (opt != NULL) {
- string_free(&opt->key);
- string_free(&opt->value);
+ lpcfg_string_free(&opt->key);
+ lpcfg_string_free(&opt->value);
TALLOC_FREE(opt->list);
next_opt = opt->next;
TALLOC_FREE(opt);
@@ -1309,7 +1268,7 @@ static void free_service(struct loadparm_service *pservice)
free_parameters(pservice);
- string_free(&pservice->szService);
+ lpcfg_string_free(&pservice->szService);
TALLOC_FREE(pservice->copymap);
free_param_opts(&pservice->param_opt);
@@ -1383,7 +1342,7 @@ static int add_a_service(const struct loadparm_service *pservice, const char *na
copy_service(ServicePtrs[i], pservice, NULL);
if (name)
- string_set(ServicePtrs[i], &ServicePtrs[i]->szService, name);
+ lpcfg_string_set(ServicePtrs[i], &ServicePtrs[i]->szService, name);
DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
i, ServicePtrs[i]->szService));
@@ -1472,7 +1431,7 @@ bool lp_add_home(const char *pszHomename, int iDefaultService,
if (!(*(ServicePtrs[iDefaultService]->path))
|| strequal(ServicePtrs[iDefaultService]->path,
lp_path(talloc_tos(), GLOBAL_SECTION_SNUM))) {
- string_set(ServicePtrs[i], &ServicePtrs[i]->path, pszHomedir);
+ lpcfg_string_set(ServicePtrs[i], &ServicePtrs[i]->path, pszHomedir);
}
if (!(*(ServicePtrs[i]->comment))) {
@@ -1480,7 +1439,7 @@ bool lp_add_home(const char *pszHomename, int iDefaultService,
if (comment == NULL) {
return false;
}
- string_set(ServicePtrs[i], &ServicePtrs[i]->comment, comment);
+ lpcfg_string_set(ServicePtrs[i], &ServicePtrs[i]->comment, comment);
TALLOC_FREE(comment);
}
@@ -1528,10 +1487,10 @@ static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
return false;
}
- string_set(ServicePtrs[i], &ServicePtrs[i]->path, tmpdir());
- string_set(ServicePtrs[i], &ServicePtrs[i]->username, "");
- string_set(ServicePtrs[i], &ServicePtrs[i]->comment, comment);
- string_set(ServicePtrs[i], &ServicePtrs[i]->fstype, "IPC");
+ lpcfg_string_set(ServicePtrs[i], &ServicePtrs[i]->path, tmpdir());
+ lpcfg_string_set(ServicePtrs[i], &ServicePtrs[i]->username, "");
+ lpcfg_string_set(ServicePtrs[i], &ServicePtrs[i]->comment, comment);
+ lpcfg_string_set(ServicePtrs[i], &ServicePtrs[i]->fstype, "IPC");
ServicePtrs[i]->max_connections = 0;
ServicePtrs[i]->available = true;
ServicePtrs[i]->read_only = true;
@@ -1565,8 +1524,8 @@ bool lp_add_printer(const char *pszPrintername, int iDefaultService)
/* entry (if/when the 'available' keyword is implemented!). */
/* the printer name is set to the service name. */
- string_set(ServicePtrs[i], &ServicePtrs[i]->_printername, pszPrintername);
- string_set(ServicePtrs[i], &ServicePtrs[i]->comment, comment);
+ lpcfg_string_set(ServicePtrs[i], &ServicePtrs[i]->_printername, pszPrintername);
+ lpcfg_string_set(ServicePtrs[i], &ServicePtrs[i]->comment, comment);
/* set the browseable flag from the gloabl default */
ServicePtrs[i]->browseable = sDefault.browseable;
@@ -2288,9 +2247,9 @@ bool lp_include(struct loadparm_context *lp_ctx, struct loadparm_service *servic
add_to_file_list(NULL, &file_lists, pszParmValue, fname);
if (service == NULL) {
- string_set(Globals.ctx, ptr, fname);
+ lpcfg_string_set(Globals.ctx, ptr, fname);
} else {
- string_set(service, ptr, fname);
+ lpcfg_string_set(service, ptr, fname);
}
if (file_exist(fname)) {
@@ -2761,7 +2720,7 @@ void lp_add_one_printer(const char *name, const char *comment,
if (lp_servicenumber(name) < 0) {
lp_add_printer(name, printers);
if ((i = lp_servicenumber(name)) >= 0) {
- string_set(ServicePtrs[i], &ServicePtrs[i]->comment, comment);
+ lpcfg_string_set(ServicePtrs[i], &ServicePtrs[i]->comment, comment);
ServicePtrs[i]->autoloaded = true;
}
}
@@ -2845,9 +2804,10 @@ static void lp_save_defaults(void)
break;
case P_STRING:
case P_USTRING:
- parm_table[i].def.svalue = talloc_strdup(Globals.ctx, *(char **)lp_parm_ptr(NULL, &parm_table[i]));
+ lpcfg_string_set(Globals.ctx, &parm_table[i].def.svalue,
+ *(char **)lp_parm_ptr(NULL, &parm_table[i]));
if (parm_table[i].def.svalue == NULL) {
- smb_panic("talloc_strdup failed");
+ smb_panic("lpcfg_string_set() failed");
}
break;
case P_BOOL:
@@ -3323,8 +3283,8 @@ static int process_usershare_file(const char *dir_name, const char *file_name, i
/* And note when it was loaded. */
ServicePtrs[iService]->usershare_last_mod = sbuf.st_ex_mtime;
- string_set(ServicePtrs[iService], &ServicePtrs[iService]->path, sharepath);
- string_set(ServicePtrs[iService], &ServicePtrs[iService]->comment, comment);
+ lpcfg_string_set(ServicePtrs[iService], &ServicePtrs[iService]->path, sharepath);
+ lpcfg_string_set(ServicePtrs[iService], &ServicePtrs[iService]->comment, comment);
ret = iService;
@@ -4183,7 +4143,7 @@ const char *lp_printername(TALLOC_CTX *ctx, int snum)
void lp_set_logfile(const char *name)
{
- string_set(Globals.ctx, &Globals.logfile, name);
+ lpcfg_string_set(Globals.ctx, &Globals.logfile, name);
debug_set_logfile(name);
}
@@ -4286,7 +4246,7 @@ void set_store_dos_attributes(int snum, bool val)
void lp_set_mangling_method(const char *new_method)
{
- string_set(Globals.ctx, &Globals.mangling_method, new_method);
+ lpcfg_string_set(Globals.ctx, &Globals.mangling_method, new_method);
}
/*******************************************************************
--
1.9.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20151130/6af4550c/signature.sig>
More information about the samba-technical
mailing list