Fix bug found by tridge in 2.2.x. Ensure that %U substitution is
authorJeremy Allison <jra@samba.org>
Thu, 28 Aug 2003 23:57:34 +0000 (23:57 +0000)
committerJeremy Allison <jra@samba.org>
Thu, 28 Aug 2003 23:57:34 +0000 (23:57 +0000)
restored on next valid packet if a logon fails. This has relevence
if people are using su.exe within logon scripts !
Jeremy.
(This used to be commit d405a93a9d3f9a1d93bb3289b00683fba3160bbe)

source3/auth/auth_domain.c
source3/lib/substitute.c
source3/smbd/process.c

index aacea261febddf86eaa41e47c2bae2feb68a62a3..43e7597cd9626356243688eaa8da2b8c33259606 100644 (file)
@@ -26,9 +26,6 @@
 
 extern BOOL global_machine_password_needs_changing;
 
-extern userdom_struct current_user_info;
-
-
 /**
  * Connect to a remote server for domain security authenticaion.
  *
index 71c7b9ab1c394b229aba29e08337c98e5677de8b..a73f9d85dabb8c3a6220df3beaa74443d4e7d511 100644 (file)
@@ -98,16 +98,17 @@ const char* get_local_machine_name(void)
        return local_machine;
 }
 
+/*******************************************************************
+ Setup the string used by %U substitution.
+********************************************************************/
 
-/*
-  setup the string used by %U substitution 
-*/
 void sub_set_smb_name(const char *name)
 {
        fstring tmp;
 
        /* don't let anonymous logins override the name */
-       if (! *name) return;
+       if (! *name)
+               return;
 
        fstrcpy(tmp,name);
        trim_string(tmp," "," ");
@@ -115,6 +116,18 @@ void sub_set_smb_name(const char *name)
        alpha_strcpy(smb_user_name,tmp,SAFE_NETBIOS_CHARS,sizeof(smb_user_name)-1);
 }
 
+/*******************************************************************
+ Setup the strings used by substitutions. Called per packet. Ensure
+ %U name is set correctly also.
+********************************************************************/
+
+void set_current_user_info(const userdom_struct *pcui)
+{
+       current_user_info = *pcui;
+       /* The following is safe as current_user_info.smb_name
+        * has already been sanitised in register_vuid. */
+       fstrcpy(smb_user_name, current_user_info.smb_name);
+}
 
 /*******************************************************************
  Given a pointer to a %$(NAME) expand it as an environment variable.
index 373c2f16ae358e6d686117a4ca1ab4152460a0a5..457ba8cc63f07ecc0ea34426788f40b776314948 100644 (file)
@@ -719,7 +719,7 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize
                        if(session_tag != UID_FIELD_INVALID)
                                vuser = get_valid_user_struct(session_tag);           
                        if(vuser != NULL)
-                               current_user_info = vuser->user;
+                               set_current_user_info(&vuser->user);
                }
 
                /* does this protocol need to be run as root? */