fstrcpy(smb_user_name, current_user_info.smb_name);
}
+/*******************************************************************
+ 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.
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);
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)));
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());
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);
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);
* 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;
}