summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/lib/util.c16
-rw-r--r--source3/param/loadparm.c4
-rw-r--r--source3/passdb/smbpass.c11
-rw-r--r--source3/printing/printing.c8
-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
9 files changed, 57 insertions, 52 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index c6311b3068..3cc48bb78f 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1753,7 +1753,7 @@ int reply_lanman2(char *outbuf);
int reply_nt1(char *outbuf);
void close_cnum(int cnum, uint16 vuid);
void exit_server(char *reason);
-void standard_sub(int cnum,char *str,uint16 vuid);
+void standard_sub(int cnum,char *str);
char *smb_fn_name(int type);
int chain_reply(char *inbuf,char *outbuf,int size,int bufsize);
int construct_reply(char *inbuf,char *outbuf,int size,int bufsize);
diff --git a/source3/lib/util.c b/source3/lib/util.c
index f5cfb974a2..2416110857 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -4000,16 +4000,32 @@ void standard_sub_basic(char *str)
{
char *s, *p;
char pidstr[10];
+ struct passwd *pass;
+ char *username = sam_logon_in_ssb ? samlogon_user : sesssetup_user;
for (s = str ; s && *s && (p = strchr(s,'%')); s = p )
{
switch (*(p+1))
{
+ case 'G' :
+ {
+ if ((pass = Get_Pwnam(username,False))!=NULL)
+ {
+ string_sub(p,"%G",gidtoname(pass->pw_gid));
+ }
+ else
+ {
+ p += 2;
+ }
+ break;
+ }
+ case 'N' : string_sub(p,"%N", automount_server(username)); break;
case 'I' : string_sub(p,"%I", client_addr(Client)); break;
case 'L' : string_sub(p,"%L", local_machine); break;
case 'M' : string_sub(p,"%M", client_name(Client)); break;
case 'R' : string_sub(p,"%R", remote_proto); break;
case 'T' : string_sub(p,"%T", timestring()); break;
+ case 'U' : string_sub(p,"%U", username); break;
case 'a' : string_sub(p,"%a", remote_arch); break;
case 'd' :
{
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 9ae845486a..ddc5cf3ab1 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -754,8 +754,8 @@ static void init_globals(void)
Globals.syslog = 1;
Globals.bSyslogOnly = False;
Globals.os_level = 0;
- Globals.max_ttl = 60*60*4; /* 4 hours default */
- Globals.max_wins_ttl = 60*60*24*3; /* 3 days default */
+ Globals.max_ttl = 60*60*24*3; /* 3 days default */
+ Globals.max_wins_ttl = 60*60*24*6; /* 6 days default */
Globals.min_wins_ttl = 60*60*6; /* 6 hours default */
Globals.ReadSize = 16*1024;
Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
diff --git a/source3/passdb/smbpass.c b/source3/passdb/smbpass.c
index defadadf69..31567eafd8 100644
--- a/source3/passdb/smbpass.c
+++ b/source3/passdb/smbpass.c
@@ -17,17 +17,6 @@
* Mass Ave, Cambridge, MA 02139, USA.
*/
-/*X*X*X*X*X*X*X**X*X*X*X*X*X*X**X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*
- *X*X*X*X*X*X*X**X*X*X*X*X*X*X**X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*
- *X*X*X*X*X*X*X**X*X*X*X*X*X*X**X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*
-
- DO NOT CALL ANY OF THE ROUTINES IN THIS MODULE DIRECTLY.
- USE passdb.c INSTEAD.
-
- *X*X*X*X*X*X*X**X*X*X*X*X*X*X**X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*
- *X*X*X*X*X*X*X**X*X*X*X*X*X*X**X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*
- *X*X*X*X*X*X*X**X*X*X*X*X*X*X**X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*/
-
#include "includes.h"
extern int DEBUGLEVEL;
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index bbc0ff6144..c7db5744e2 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -103,7 +103,7 @@ static char *build_print_command(int cnum, char *command, char *syscmd, char *fi
string_sub(syscmd, "%p", tstr);
- standard_sub(cnum,syscmd,UID_FIELD_INVALID);
+ standard_sub(cnum,syscmd);
return (syscmd);
}
@@ -1056,7 +1056,7 @@ int get_printqueue(int snum,int cnum,print_queue_struct **queue,
pstrcpy(syscmd,lpq_command);
string_sub(syscmd,"%p",printername);
- standard_sub(cnum,syscmd,UID_FIELD_INVALID);
+ standard_sub(cnum,syscmd);
sprintf(outfile,"%s/lpq.%08x",tmpdir(),str_checksum(syscmd));
@@ -1147,7 +1147,7 @@ void del_printqueue(int cnum,int snum,int jobid)
pstrcpy(syscmd,lprm_command);
string_sub(syscmd,"%p",printername);
string_sub(syscmd,"%j",jobstr);
- standard_sub(cnum,syscmd,UID_FIELD_INVALID);
+ standard_sub(cnum,syscmd);
ret = smbrun(syscmd,NULL,False);
DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
@@ -1185,7 +1185,7 @@ void status_printjob(int cnum,int snum,int jobid,int status)
pstrcpy(syscmd,lpstatus_command);
string_sub(syscmd,"%p",printername);
string_sub(syscmd,"%j",jobstr);
- standard_sub(cnum,syscmd,UID_FIELD_INVALID);
+ standard_sub(cnum,syscmd);
ret = smbrun(syscmd,NULL,False);
DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
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()));