diff options
author | Andrew Tridgell <tridge@samba.org> | 2000-04-23 08:30:37 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2000-04-23 08:30:37 +0000 |
commit | b2461e93dd7c94b94ddf167659ed3515b1c90b44 (patch) | |
tree | 89c7cd7ce69e6955de3e8b5617f2e0798def5f7b /source3/lib | |
parent | b1686a61091fb10ebaac837c95554076ed49e67a (diff) | |
download | samba-b2461e93dd7c94b94ddf167659ed3515b1c90b44.tar.gz samba-b2461e93dd7c94b94ddf167659ed3515b1c90b44.tar.bz2 samba-b2461e93dd7c94b94ddf167659ed3515b1c90b44.zip |
split out standard_sub_basic() again to fix a bug where %p was being
substituted in the loadparm code and thus leaving lpq with no printer
(This used to be commit b7c7a4d564d36885aa7c3efb2a87caec470df7fe)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/substitute.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c index e7d620db16..6f6d2a9c16 100644 --- a/source3/lib/substitute.c +++ b/source3/lib/substitute.c @@ -157,15 +157,13 @@ static char *automount_server(char *user_name) return server_name; } - /**************************************************************************** Do some standard substitutions in a string. ****************************************************************************/ -static void standard_sub_advanced(int snum, char *user, char *connectpath, gid_t gid, char *str) +void standard_sub_basic(char *str) { - char *p, *s, *home; + char *p, *s; fstring pidstr; - struct passwd *pass; for (s=str; (p=strchr(s, '%'));s=p) { int l = sizeof(pstring) - (int)(p-str); @@ -176,7 +174,6 @@ static void standard_sub_advanced(int snum, char *user, char *connectpath, gid_t case 'M' : string_sub(p,"%M", client_name(),l); break; case 'R' : string_sub(p,"%R", remote_proto,l); break; case 'T' : string_sub(p,"%T", timestring(False),l); break; - case 'U' : string_sub(p,"%U", user,l); break; case 'a' : string_sub(p,"%a", remote_arch,l); break; case 'd' : slprintf(pidstr,sizeof(pidstr), "%d",(int)getpid()); @@ -186,6 +183,31 @@ static void standard_sub_advanced(int snum, char *user, char *connectpath, gid_t case 'm' : string_sub(p,"%m", remote_machine,l); break; case 'v' : string_sub(p,"%v", VERSION,l); break; case '$' : p += expand_env_var(p,l); break; /* Expand environment variables */ + case '\0': + p++; + break; /* don't run off the end of the string */ + + default: p+=2; + break; + } + } +} + + +/**************************************************************************** + Do some standard substitutions in a string. +****************************************************************************/ +static void standard_sub_advanced(int snum, char *user, char *connectpath, gid_t gid, char *str) +{ + char *p, *s, *home; + fstring pidstr; + struct passwd *pass; + + for (s=str; (p=strchr(s, '%'));s=p) { + int l = sizeof(pstring) - (int)(p-str); + + switch (*(p+1)) { + case 'U' : string_sub(p,"%U", user,l); break; case 'G' : if ((pass = Get_Pwnam(user,False))!=NULL) { string_sub(p,"%G",gidtoname(pass->pw_gid),l); @@ -234,6 +256,8 @@ static void standard_sub_advanced(int snum, char *user, char *connectpath, gid_t break; } } + + standard_sub_basic(str); } /**************************************************************************** @@ -252,15 +276,6 @@ void standard_sub_snum(int snum, char *str) standard_sub_advanced(snum, "", "", -1, str); } - -/******************************************************************* - Substitute strings with useful parameters. -********************************************************************/ -void standard_sub_basic(char *str) -{ - standard_sub_advanced(-1, "", "", -1, str); -} - /******************************************************************* Substitute strings with useful parameters. ********************************************************************/ |