svn commit: samba r5174 - in branches/SAMBA_3_0/source: lib param

jerry at samba.org jerry at samba.org
Wed Feb 2 16:05:56 GMT 2005


Author: jerry
Date: 2005-02-02 16:05:55 +0000 (Wed, 02 Feb 2005)
New Revision: 5174

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5174

Log:
ensure that we consistently use the current_user_info.smb_name vs. smb_name when parsing smb.conf and reloading config files
Modified:
   branches/SAMBA_3_0/source/lib/substitute.c
   branches/SAMBA_3_0/source/param/loadparm.c


Changeset:
Modified: branches/SAMBA_3_0/source/lib/substitute.c
===================================================================
--- branches/SAMBA_3_0/source/lib/substitute.c	2005-02-02 12:02:16 UTC (rev 5173)
+++ branches/SAMBA_3_0/source/lib/substitute.c	2005-02-02 16:05:55 UTC (rev 5174)
@@ -135,6 +135,18 @@
 }
 
 /*******************************************************************
+ 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 at hermes.si>

Modified: branches/SAMBA_3_0/source/param/loadparm.c
===================================================================
--- branches/SAMBA_3_0/source/param/loadparm.c	2005-02-02 12:02:16 UTC (rev 5173)
+++ branches/SAMBA_3_0/source/param/loadparm.c	2005-02-02 16:05:55 UTC (rev 5174)
@@ -1584,11 +1584,11 @@
 	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 @@
 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 @@
 
 	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 @@
 	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,20 +3886,11 @@
 	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( get_current_username(), n2,sizeof(n2) );
 
-	standard_sub_basic( username, n2,sizeof(n2) );
-
 	add_to_file_list(pszFname, n2);
 
 	bRetval = False;
@@ -4046,7 +4029,7 @@
 			 * 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;
 		}



More information about the samba-cvs mailing list