summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-02-02 16:05:55 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:55:31 -0500
commit9dbb5769fe70d3c0e2a2c679a42104bc15d42bc7 (patch)
tree2eb2f466e42bd049d74656d2f763f5d0519dc771 /source3
parenteed0e6875b3a4708a9c7cfa8bbddf207b85ca396 (diff)
downloadsamba-9dbb5769fe70d3c0e2a2c679a42104bc15d42bc7.tar.gz
samba-9dbb5769fe70d3c0e2a2c679a42104bc15d42bc7.tar.bz2
samba-9dbb5769fe70d3c0e2a2c679a42104bc15d42bc7.zip
r5174: ensure that we consistently use the current_user_info.smb_name vs. smb_name when parsing smb.conf and reloading config files
(This used to be commit be537eaebe84b2ccae089e5982263df8a96e7a5b)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/substitute.c12
-rw-r--r--source3/param/loadparm.c31
2 files changed, 19 insertions, 24 deletions
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c
index 6ec3bb4a76..615a8d73b0 100644
--- a/source3/lib/substitute.c
+++ b/source3/lib/substitute.c
@@ -135,6 +135,18 @@ void set_current_user_info(const userdom_struct *pcui)
}
/*******************************************************************
+ return the current active user name
+*******************************************************************/
+
+const char* get_current_username( void )
+{
+ if ( current_user_info.smb_name[0] == '\0' )
+ return smb_user_name;
+
+ return current_user_info.smb_name;
+}
+
+/*******************************************************************
Given a pointer to a %$(NAME) expand it as an environment variable.
Return the number of characters by which the pointer should be advanced.
Based on code by Branko Cibej <branko.cibej@hermes.si>
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 97d9389aa6..01213a8fb3 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -1584,11 +1584,11 @@ static char *lp_string(const char *s)
if (!lp_talloc)
lp_talloc = talloc_init("lp_talloc");
- tmpstr = alloc_sub_basic(current_user_info.smb_name, s);
+ tmpstr = alloc_sub_basic(get_current_username(), s);
if (trim_char(tmpstr, '\"', '\"')) {
if (strchr(tmpstr,'\"') != NULL) {
SAFE_FREE(tmpstr);
- tmpstr = alloc_sub_basic(current_user_info.smb_name,s);
+ tmpstr = alloc_sub_basic(get_current_username(),s);
}
}
ret = talloc_strdup(lp_talloc, tmpstr);
@@ -2694,23 +2694,15 @@ static void add_to_file_list(const char *fname, const char *subfname)
BOOL lp_file_list_changed(void)
{
struct file_lists *f = file_lists;
- char *username;
DEBUG(6, ("lp_file_list_changed()\n"));
- /* get the username for substituion -- preference to the current_user_info */
- if ( strlen( current_user_info.smb_name ) != 0 )
- username = current_user_info.smb_name;
- else
- username = sub_get_smb_name();
-
-
while (f) {
pstring n2;
time_t mod_time;
pstrcpy(n2, f->name);
- standard_sub_basic( username, n2, sizeof(n2) );
+ standard_sub_basic( get_current_username(), n2, sizeof(n2) );
DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
f->name, n2, ctime(&f->modtime)));
@@ -2744,7 +2736,7 @@ static BOOL handle_netbios_name(int snum, const char *pszParmValue, char **ptr)
pstrcpy(netbios_name, pszParmValue);
- standard_sub_basic(current_user_info.smb_name, netbios_name,sizeof(netbios_name));
+ standard_sub_basic(get_current_username(), netbios_name,sizeof(netbios_name));
ret = set_global_myname(netbios_name);
string_set(&Globals.szNetbiosName,global_myname());
@@ -2800,7 +2792,7 @@ static BOOL handle_include(int snum, const char *pszParmValue, char **ptr)
pstring fname;
pstrcpy(fname, pszParmValue);
- standard_sub_basic(current_user_info.smb_name, fname,sizeof(fname));
+ standard_sub_basic(get_current_username(), fname,sizeof(fname));
add_to_file_list(pszParmValue, fname);
@@ -3894,19 +3886,10 @@ BOOL lp_load(const char *pszFname, BOOL global_only, BOOL save_defaults,
pstring n2;
BOOL bRetval;
param_opt_struct *data, *pdata;
- char *username;
pstrcpy(n2, pszFname);
- /* get the username for substituion -- preference to the current_user_info */
-
- if ( strlen( current_user_info.smb_name ) != 0 ) {
- username = current_user_info.smb_name;
- } else {
- username = sub_get_smb_name();
- }
-
- standard_sub_basic( username, n2,sizeof(n2) );
+ standard_sub_basic( get_current_username(), n2,sizeof(n2) );
add_to_file_list(pszFname, n2);
@@ -4046,7 +4029,7 @@ int lp_servicenumber(const char *pszServiceName)
* service names
*/
fstrcpy(serviceName, ServicePtrs[iService]->szService);
- standard_sub_basic(current_user_info.smb_name, serviceName,sizeof(serviceName));
+ standard_sub_basic(get_current_username(), serviceName,sizeof(serviceName));
if (strequal(serviceName, pszServiceName))
break;
}