diff options
author | Andrew Tridgell <tridge@samba.org> | 2002-11-19 23:44:24 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2002-11-19 23:44:24 +0000 |
commit | 18e55a69ffd30a621484ccc9f5210da132067dc5 (patch) | |
tree | b94a9f66fdaea41b59c9ca0cd2de972fcaa6e330 /source3/lib | |
parent | 22a08a5b12c73b13b875bf39cc1b868f507b00ce (diff) | |
download | samba-18e55a69ffd30a621484ccc9f5210da132067dc5.tar.gz samba-18e55a69ffd30a621484ccc9f5210da132067dc5.tar.bz2 samba-18e55a69ffd30a621484ccc9f5210da132067dc5.zip |
a better for for using %U in smb.conf
this follows the method used for remote_machine and also fixes the
problem of anonymous connections clobbering the string
(This used to be commit 9ead4fc3c3f8b83f03c762a4dab77a64aabccbf9)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/substitute.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c index 23cfce6c69..48d8e35dae 100644 --- a/source3/lib/substitute.c +++ b/source3/lib/substitute.c @@ -26,7 +26,8 @@ fstring remote_arch="UNKNOWN"; userdom_struct current_user_info; fstring remote_proto="UNKNOWN"; -static fstring remote_machine=""; +static fstring remote_machine; +static fstring smb_user_name; void set_local_machine_name(const char* local_name) @@ -59,6 +60,21 @@ const char* get_local_machine_name(void) return local_machine; } + +/* + setup the string used by %U substitution +*/ +void sub_set_smb_name(const char *name) +{ + fstring tmp; + + fstrcpy(tmp,name); + trim_string(tmp," "," "); + strlower(tmp); + alpha_strcpy(smb_user_name,tmp,SAFE_NETBIOS_CHARS,sizeof(smb_user_name)-1); +} + + /******************************************************************* Given a pointer to a %$(NAME) expand it as an environment variable. Return the number of characters by which the pointer should be advanced. @@ -676,20 +692,20 @@ char *alloc_sub_advanced(int snum, const char *user, void standard_sub_conn(connection_struct *conn, char *str, size_t len) { standard_sub_advanced(SNUM(conn), conn->user, conn->connectpath, - conn->gid, current_user_info.smb_name, str, len); + conn->gid, smb_user_name, str, len); } char *talloc_sub_conn(TALLOC_CTX *mem_ctx, connection_struct *conn, char *str) { return talloc_sub_advanced(mem_ctx, SNUM(conn), conn->user, conn->connectpath, conn->gid, - current_user_info.smb_name, str); + smb_user_name, str); } char *alloc_sub_conn(connection_struct *conn, char *str) { return alloc_sub_advanced(SNUM(conn), conn->user, conn->connectpath, - conn->gid, current_user_info.smb_name, str); + conn->gid, smb_user_name, str); } /**************************************************************************** @@ -710,5 +726,5 @@ void standard_sub_snum(int snum, char *str, size_t len) } standard_sub_advanced(snum, cached_user, "", -1, - current_user_info.smb_name, str, len); + smb_user_name, str, len); } |