summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/ipc.c10
-rw-r--r--source3/smbd/message.c2
-rw-r--r--source3/smbd/server.c50
-rw-r--r--source3/smbd/uid.c6
4 files changed, 34 insertions, 34 deletions
diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c
index 48c0277165..8be9c10a13 100644
--- a/source3/smbd/ipc.c
+++ b/source3/smbd/ipc.c
@@ -85,7 +85,7 @@ static int CopyExpanded(int cnum, int snum, char** dst, char* src, int* n)
StrnCpy(buf,src,sizeof(buf)/2);
string_sub(buf,"%S",lp_servicename(snum));
- standard_sub(cnum,buf,UID_FIELD_INVALID);
+ standard_sub(cnum,buf);
StrnCpy(*dst,buf,*n);
l = strlen(*dst) + 1;
(*dst) += l;
@@ -110,7 +110,7 @@ static int StrlenExpanded(int cnum, int snum, char* s)
if (!s) return(0);
StrnCpy(buf,s,sizeof(buf)/2);
string_sub(buf,"%S",lp_servicename(snum));
- standard_sub(cnum,buf,UID_FIELD_INVALID);
+ standard_sub(cnum,buf);
return strlen(buf) + 1;
}
@@ -120,7 +120,7 @@ static char* Expand(int cnum, int snum, char* s)
if (!s) return(NULL);
StrnCpy(buf,s,sizeof(buf)/2);
string_sub(buf,"%S",lp_servicename(snum));
- standard_sub(cnum,buf,UID_FIELD_INVALID);
+ standard_sub(cnum,buf);
return &buf[0];
}
@@ -2058,7 +2058,7 @@ static BOOL api_RNetServerGetInfo(int cnum,uint16 vuid, char *param,char *data,
SIVAL(p,6,0);
} else {
SIVAL(p,6,PTR_DIFF(p2,*rdata));
- standard_sub(cnum,comment,vuid);
+ standard_sub(cnum,comment);
StrnCpy(p2,comment,MAX(mdrcnt - struct_len,0));
p2 = skip_string(p2,1);
}
@@ -2584,7 +2584,7 @@ static BOOL api_WWkstaUserLogon(int cnum,uint16 vuid, char *param,char *data,
/* JHT - By calling lp_logon_script() and standard_sub() we have */
/* made sure all macros are fully substituted and available */
logon_script = lp_logon_script();
- standard_sub( cnum, logon_script, vuid );
+ standard_sub( cnum, logon_script );
PACKS(&desc,"z", logon_script); /* script path */
/* End of JHT mods */
diff --git a/source3/smbd/message.c b/source3/smbd/message.c
index 9fb506edd0..24477f31ff 100644
--- a/source3/smbd/message.c
+++ b/source3/smbd/message.c
@@ -78,7 +78,7 @@ static void msg_deliver(void)
string_sub(s,"%s",name);
string_sub(s,"%f",msgfrom);
string_sub(s,"%t",msgto);
- standard_sub(-1,s,UID_FIELD_INVALID);
+ standard_sub(-1,s);
smbrun(s,NULL,False);
}
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 6f5527714d..e4c00c141f 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -3537,7 +3537,7 @@ int make_connection(char *service,char *user,char *password, int pwlen, char *de
{
pstring s;
pstrcpy(s,lp_pathname(snum));
- standard_sub(cnum,s,vuid);
+ standard_sub(cnum,s);
string_set(&pcon->connectpath,s);
DEBUG(3,("Connect path is %s\n",s));
}
@@ -3574,7 +3574,7 @@ int make_connection(char *service,char *user,char *password, int pwlen, char *de
{
pstring cmd;
pstrcpy(cmd,lp_rootpreexec(SNUM(cnum)));
- standard_sub(cnum,cmd,vuid);
+ standard_sub(cnum,cmd);
DEBUG(5,("cmd=%s\n",cmd));
smbrun(cmd,NULL,False);
}
@@ -3628,7 +3628,7 @@ int make_connection(char *service,char *user,char *password, int pwlen, char *de
{
pstring cmd;
pstrcpy(cmd,lp_preexec(SNUM(cnum)));
- standard_sub(cnum,cmd,vuid);
+ standard_sub(cnum,cmd);
smbrun(cmd,NULL,False);
}
@@ -4222,7 +4222,7 @@ void close_cnum(int cnum, uint16 vuid)
{
pstring cmd;
strcpy(cmd,lp_postexec(SNUM(cnum)));
- standard_sub(cnum,cmd,vuid);
+ standard_sub(cnum,cmd);
smbrun(cmd,NULL,False);
unbecome_user();
}
@@ -4233,7 +4233,7 @@ void close_cnum(int cnum, uint16 vuid)
{
pstring cmd;
strcpy(cmd,lp_rootpostexec(SNUM(cnum)));
- standard_sub(cnum,cmd,vuid);
+ standard_sub(cnum,cmd);
smbrun(cmd,NULL,False);
}
@@ -4338,16 +4338,10 @@ void exit_server(char *reason)
/****************************************************************************
do some standard substitutions in a string
****************************************************************************/
-void standard_sub(int cnum,char *str,uint16 vuid)
+void standard_sub(int cnum,char *str)
{
if (VALID_CNUM(cnum)) {
char *p, *s, *home;
- struct passwd *pass;
- char *username = sesssetup_user;
- user_struct *vuser = get_valid_user_struct(vuid);
-
- if(vuser != NULL)
- pstrcpy( sesssetup_user, vuser->requested_name);
for ( s=str ; (p=strchr(s, '%')) != NULL ; s=p ) {
switch (*(p+1)) {
@@ -4359,23 +4353,15 @@ void standard_sub(int cnum,char *str,uint16 vuid)
case 'P' : string_sub(p,"%P",Connections[cnum].connectpath); break;
case 'S' : string_sub(p,"%S",lp_servicename(Connections[cnum].service)); break;
case 'g' : string_sub(p,"%g",gidtoname(Connections[cnum].gid)); break;
- case 'G' :
- {
- if ((pass = Get_Pwnam(sesssetup_user,False))!=NULL)
- string_sub(p,"%G",gidtoname(pass->pw_gid));
- else
- p += 2;
- break;
- }
case 'u' : string_sub(p,"%u",Connections[cnum].user); break;
- case 'U' : string_sub(p,"%U", username); break;
/*
* Patch from jkf@soton.ac.uk
+ * Left the %N (NIS server name) in standard_sub_basic as it
+ * is a feature for logon servers, hence uses the username.
* The %p (NIS server path) code is here as it is used
* instead of the default "path =" string in [homes] and so
* needs the service name, not the username.
*/
- case 'N' : string_sub(p,"%N", automount_server(username)); break;
case 'p' : string_sub(p,"%p",automount_path(lp_servicename(Connections[cnum].service))); break;
case '\0' : p++; break; /* don't run off the end of the string */
default : p+=2; break;
@@ -4595,11 +4581,31 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize
{
int cnum = SVAL(inbuf,smb_tid);
int flags = smb_messages[match].flags;
+ static uint16 last_session_tag = UID_FIELD_INVALID;
/* In share mode security we must ignore the vuid. */
uint16 session_tag = (lp_security() == SEC_SHARE) ? UID_FIELD_INVALID : SVAL(inbuf,smb_uid);
/* Ensure this value is replaced in the incoming packet. */
SSVAL(inbuf,smb_uid,session_tag);
+ /*
+ * Ensure the correct username is in sesssetup_user.
+ * This is a really ugly bugfix for problems with
+ * multiple session_setup_and_X's being done and
+ * allowing %U and %G substitutions to work correctly.
+ * There is a reason this code is done here, don't
+ * move it unless you know what you're doing... :-).
+ * JRA.
+ */
+ if(session_tag != last_session_tag ) {
+ user_struct *vuser = NULL;
+
+ last_session_tag = session_tag;
+ if(session_tag != UID_FIELD_INVALID)
+ vuser = get_valid_user_struct(session_tag);
+ if(vuser != NULL)
+ pstrcpy( sesssetup_user, vuser->requested_name);
+ }
+
/* does this protocol need to be run as root? */
if (!(flags & AS_USER))
unbecome_user();
diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c
index c01fa1b052..a8e340e46f 100644
--- a/source3/smbd/uid.c
+++ b/source3/smbd/uid.c
@@ -28,7 +28,6 @@ static int initial_gid;
/* what user is current? */
struct current_user current_user;
-extern pstring sesssetup_user;
pstring OriginalDir;
@@ -278,11 +277,6 @@ BOOL become_user(connection_struct *conn, int cnum, uint16 vuid)
current_user.cnum = cnum;
current_user.vuid = vuid;
- /* Ensure sesssetup_user is set correctly if we are using
- user security. */
- if(vuser != NULL)
- pstrcpy( sesssetup_user, vuser->requested_name);
-
DEBUG(5,("become_user uid=(%d,%d) gid=(%d,%d)\n",
getuid(),geteuid(),getgid(),getegid()));