summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/substitute.c30
-rw-r--r--source3/smbd/sesssetup.c3
2 files changed, 26 insertions, 7 deletions
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c
index 884f038e6d..4d22518230 100644
--- a/source3/lib/substitute.c
+++ b/source3/lib/substitute.c
@@ -107,15 +107,37 @@ const char* get_local_machine_name(void)
void sub_set_smb_name(const char *name)
{
fstring tmp;
+ int len;
+ BOOL is_machine_account = False;
/* don't let anonymous logins override the name */
if (! *name)
return;
- fstrcpy(tmp,name);
- trim_char(tmp,' ',' ');
- strlower_m(tmp);
- alpha_strcpy(smb_user_name,tmp,SAFE_NETBIOS_CHARS,sizeof(smb_user_name)-1);
+
+ fstrcpy( tmp, name );
+ trim_char( tmp, ' ', ' ' );
+ strlower_m( tmp );
+
+ len = strlen( tmp );
+
+ if ( len == 0 )
+ return;
+
+ /* long story but here goes....we have to allow usernames
+ ending in '$' as they are valid machine account names.
+ So check for a machine account and re-add the '$'
+ at the end after the call to alpha_strcpy(). --jerry */
+
+ if ( tmp[len-1] == '$' )
+ is_machine_account = True;
+
+ alpha_strcpy( smb_user_name, tmp, SAFE_NETBIOS_CHARS, sizeof(smb_user_name)-1 );
+
+ if ( is_machine_account ) {
+ len = strlen( smb_user_name );
+ smb_user_name[len-1] = '$';
+ }
}
char* sub_get_smb_name( void )
diff --git a/source3/smbd/sesssetup.c b/source3/smbd/sesssetup.c
index 34b161c92f..9ac258cb5e 100644
--- a/source3/smbd/sesssetup.c
+++ b/source3/smbd/sesssetup.c
@@ -954,9 +954,6 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,
return ERROR_NT(NT_STATUS_LOGON_FAILURE);
}
fstrcpy(sub_user, user);
-
- /* setup the string used by %U */
- sub_set_smb_name(user);
} else {
fstrcpy(sub_user, lp_guestaccount());
}