1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

merged the %U changes to 3.0

(This used to be commit 58fa6bfee8)
This commit is contained in:
Andrew Tridgell 2002-11-20 00:53:24 +00:00
parent 69f3c8f304
commit 91b7ac9fb9
5 changed files with 37 additions and 8 deletions

View File

@ -26,7 +26,8 @@ fstring remote_arch="UNKNOWN";
userdom_struct current_user_info; userdom_struct current_user_info;
fstring remote_proto="UNKNOWN"; 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) void set_local_machine_name(const char* local_name)
@ -59,6 +60,24 @@ const char* get_local_machine_name(void)
return local_machine; return local_machine;
} }
/*
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;
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. Given a pointer to a %$(NAME) expand it as an environment variable.
Return the number of characters by which the pointer should be advanced. Return the number of characters by which the pointer should be advanced.
@ -676,20 +695,20 @@ char *alloc_sub_advanced(int snum, const char *user,
void standard_sub_conn(connection_struct *conn, char *str, size_t len) void standard_sub_conn(connection_struct *conn, char *str, size_t len)
{ {
standard_sub_advanced(SNUM(conn), conn->user, conn->connectpath, 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) char *talloc_sub_conn(TALLOC_CTX *mem_ctx, connection_struct *conn, char *str)
{ {
return talloc_sub_advanced(mem_ctx, SNUM(conn), conn->user, return talloc_sub_advanced(mem_ctx, SNUM(conn), conn->user,
conn->connectpath, conn->gid, conn->connectpath, conn->gid,
current_user_info.smb_name, str); smb_user_name, str);
} }
char *alloc_sub_conn(connection_struct *conn, char *str) char *alloc_sub_conn(connection_struct *conn, char *str)
{ {
return alloc_sub_advanced(SNUM(conn), conn->user, conn->connectpath, 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 +729,5 @@ void standard_sub_snum(int snum, char *str, size_t len)
} }
standard_sub_advanced(snum, cached_user, "", -1, standard_sub_advanced(snum, cached_user, "", -1,
current_user_info.smb_name, str, len); smb_user_name, str, len);
} }

View File

@ -73,6 +73,7 @@ static BOOL winbindd_fill_pwent(char *dom_name, char *user_name,
by lp_string() calling standard_sub_basic(). */ by lp_string() calling standard_sub_basic(). */
fstrcpy(current_user_info.smb_name, user_name); fstrcpy(current_user_info.smb_name, user_name);
sub_set_smb_name(user_name);
fstrcpy(current_user_info.domain, dom_name); fstrcpy(current_user_info.domain, dom_name);
pstrcpy(homedir, lp_template_homedir()); pstrcpy(homedir, lp_template_homedir());

View File

@ -566,6 +566,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *
nt_workstation, nt_domain)); nt_workstation, nt_domain));
pstrcpy(current_user_info.smb_name, nt_username); pstrcpy(current_user_info.smb_name, nt_username);
sub_set_smb_name(nt_username);
/* /*
* Convert to a UNIX username. * Convert to a UNIX username.

View File

@ -612,9 +612,6 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
return NULL; return NULL;
} }
/* the %U substitution may have changed */
reload_services(True);
/* Remember that a different vuid can connect later without these checks... */ /* Remember that a different vuid can connect later without these checks... */
/* Preexecs are done here as they might make the dir we are to ChDir to below */ /* Preexecs are done here as they might make the dir we are to ChDir to below */

View File

@ -159,6 +159,11 @@ static int reply_spnego_kerberos(connection_struct *conn,
} }
ads_destroy(&ads); ads_destroy(&ads);
/* setup the string used by %U */
sub_set_smb_name(user);
reload_services(True);
/* the password is good - let them in */ /* the password is good - let them in */
pw = Get_Pwnam(user); pw = Get_Pwnam(user);
if (!pw && !strstr(user, lp_winbind_separator())) { if (!pw && !strstr(user, lp_winbind_separator())) {
@ -423,6 +428,9 @@ static int reply_spnego_auth(connection_struct *conn, char *inbuf, char *outbuf,
set_remote_machine_name(machine); set_remote_machine_name(machine);
/* setup the string used by %U */
sub_set_smb_name(user);
reload_services(True); reload_services(True);
#if 0 #if 0
@ -749,6 +757,9 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,
return ERROR_NT(NT_STATUS_UNSUCCESSFUL); return ERROR_NT(NT_STATUS_UNSUCCESSFUL);
} }
pstrcpy(sub_user, user); pstrcpy(sub_user, user);
/* setup the string used by %U */
sub_set_smb_name(user);
} else { } else {
pstrcpy(sub_user, lp_guestaccount()); pstrcpy(sub_user, lp_guestaccount());
} }