From bec1dfab27be3db888eeb451b4547f16e08e93c3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 30 Apr 2008 17:42:39 +0200 Subject: Remove "userdom_struct user" from "struct user_struct" (This used to be commit 420de035237bb08bc470c9eb820f3da2edaa6805) --- source3/smbd/lanman.c | 12 ++++++++---- source3/smbd/password.c | 49 +++++++++++++++++++++++++------------------------ source3/smbd/process.c | 8 +++++++- source3/smbd/service.c | 9 +++++---- source3/smbd/session.c | 2 +- source3/smbd/uid.c | 11 +++++++---- 6 files changed, 53 insertions(+), 38 deletions(-) (limited to 'source3/smbd') diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c index a3687451d5..a233893482 100644 --- a/source3/smbd/lanman.c +++ b/source3/smbd/lanman.c @@ -3340,7 +3340,7 @@ static bool api_RNetUserGetInfo(connection_struct *conn, uint16 vuid, if(vuser != NULL) { DEBUG(3,(" Username of UID %d is %s\n", (int)vuser->server_info->uid, - vuser->user.unix_name)); + vuser->server_info->unix_name)); } if (!str1 || !str2 || !UserName || !p) { @@ -3413,7 +3413,9 @@ static bool api_RNetUserGetInfo(connection_struct *conn, uint16 vuid, /* EEK! the cifsrap.txt doesn't have this in!!!! */ SIVAL(p,usri11_full_name,PTR_DIFF(p2,p)); /* full name */ - strlcpy(p2,((vuser != NULL) ? vuser->user.full_name : UserName),PTR_DIFF(endp,p2)); + strlcpy(p2,((vuser != NULL) + ? pdb_get_fullname(vuser->server_info->sam_account) + : UserName),PTR_DIFF(endp,p2)); p2 = skip_string(*rdata,*rdata_len,p2); if (!p2) { return False; @@ -3503,7 +3505,9 @@ static bool api_RNetUserGetInfo(connection_struct *conn, uint16 vuid, if (uLevel == 2) { SIVAL(p,60,0); /* auth_flags */ SIVAL(p,64,PTR_DIFF(p2,*rdata)); /* full_name */ - strlcpy(p2,((vuser != NULL) ? vuser->user.full_name : UserName),PTR_DIFF(endp,p2)); + strlcpy(p2,((vuser != NULL) + ? pdb_get_fullname(vuser->server_info->sam_account) + : UserName),PTR_DIFF(endp,p2)); p2 = skip_string(*rdata,*rdata_len,p2); if (!p2) { return False; @@ -3592,7 +3596,7 @@ static bool api_WWkstaUserLogon(connection_struct *conn,uint16 vuid, if(vuser != NULL) { DEBUG(3,(" Username of UID %d is %s\n", (int)vuser->server_info->uid, - vuser->user.unix_name)); + vuser->server_info->unix_name)); } uLevel = get_safe_SVAL(param,tpscnt,p,0,-1); diff --git a/source3/smbd/password.c b/source3/smbd/password.c index 5e2e713d43..a872ea2b48 100644 --- a/source3/smbd/password.c +++ b/source3/smbd/password.c @@ -253,40 +253,36 @@ int register_existing_vuid(uint16 vuid, DATA_BLOB response_blob, const char *smb_name) { - user_struct *vuser = get_partial_auth_user_struct(vuid); + fstring tmp; + user_struct *vuser; + + vuser = get_partial_auth_user_struct(vuid); if (!vuser) { goto fail; } /* Use this to keep tabs on all our info from the authentication */ - vuser->server_info = server_info; - - /* Ensure that the server_info will disappear with - * the vuser it is now attached to */ - - talloc_steal(vuser, vuser->server_info); - - fstrcpy(vuser->user.unix_name, server_info->unix_name); + vuser->server_info = talloc_move(vuser, &server_info); /* This is a potentially untrusted username */ - alpha_strcpy(vuser->user.smb_name, smb_name, ". _-$", - sizeof(vuser->user.smb_name)); + alpha_strcpy(tmp, smb_name, ". _-$", sizeof(tmp)); - fstrcpy(vuser->user.domain, pdb_get_domain(server_info->sam_account)); - fstrcpy(vuser->user.full_name, - pdb_get_fullname(server_info->sam_account)); + vuser->server_info->sanitized_username = talloc_strdup( + server_info, tmp); DEBUG(10,("register_existing_vuid: (%u,%u) %s %s %s guest=%d\n", - (unsigned int)vuser->server_info->uid, - (unsigned int)vuser->server_info->gid, - vuser->user.unix_name, vuser->user.smb_name, - vuser->user.domain, vuser->server_info->guest )); + (unsigned int)vuser->server_info->uid, + (unsigned int)vuser->server_info->gid, + vuser->server_info->unix_name, + vuser->server_info->sanitized_username, + pdb_get_domain(vuser->server_info->sam_account), + vuser->server_info->guest )); DEBUG(3, ("register_existing_vuid: User name: %s\t" - "Real name: %s\n", vuser->user.unix_name, - vuser->user.full_name)); + "Real name: %s\n", vuser->server_info->unix_name, + pdb_get_fullname(vuser->server_info->sam_account))); - if (!server_info->ptok) { + if (!vuser->server_info->ptok) { DEBUG(1, ("register_existing_vuid: server_info does not " "contain a user_token - cannot continue\n")); goto fail; @@ -294,7 +290,7 @@ int register_existing_vuid(uint16 vuid, DEBUG(3,("register_existing_vuid: UNIX uid %d is UNIX user %s, " "and will be vuid %u\n", (int)vuser->server_info->uid, - vuser->user.unix_name, vuser->vuid)); + vuser->server_info->unix_name, vuser->vuid)); next_vuid++; num_validated_vuids++; @@ -316,7 +312,7 @@ int register_existing_vuid(uint16 vuid, if (!vuser->server_info->guest) { vuser->homes_snum = register_homes_share( - vuser->user.unix_name); + vuser->server_info->unix_name); } if (srv_is_signing_negotiated() && !vuser->server_info->guest && @@ -327,7 +323,12 @@ int register_existing_vuid(uint16 vuid, } /* fill in the current_user_info struct */ - set_current_user_info( &vuser->user ); + set_current_user_info( + vuser->server_info->sanitized_username, + vuser->server_info->unix_name, + pdb_get_fullname(vuser->server_info->sam_account), + pdb_get_domain(vuser->server_info->sam_account)); + return vuser->vuid; fail: diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 5946989ae7..ab737a89a7 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -1387,7 +1387,13 @@ static connection_struct *switch_message(uint8 type, struct smb_request *req, in if(session_tag != UID_FIELD_INVALID) { vuser = get_valid_user_struct(session_tag); if (vuser) { - set_current_user_info(&vuser->user); + set_current_user_info( + vuser->server_info->sanitized_username, + vuser->server_info->unix_name, + pdb_get_fullname(vuser->server_info + ->sam_account), + pdb_get_domain(vuser->server_info + ->sam_account)); } } } diff --git a/source3/smbd/service.c b/source3/smbd/service.c index 7b0fdc8976..ff69fc4029 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -724,11 +724,12 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser, return NULL; } } else { - if (!user_ok_token(vuser->user.unix_name, + if (!user_ok_token(vuser->server_info->unix_name, vuser->server_info->ptok, snum)) { DEBUG(2, ("user '%s' (from session setup) not " "permitted to access this share " - "(%s)\n", vuser->user.unix_name, + "(%s)\n", + vuser->server_info->unix_name, lp_servicename(snum))); conn_free(conn); *status = NT_STATUS_ACCESS_DENIED; @@ -738,8 +739,8 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser, conn->vuid = vuser->vuid; conn->uid = vuser->server_info->uid; conn->gid = vuser->server_info->gid; - string_set(&conn->user,vuser->user.unix_name); - fstrcpy(user,vuser->user.unix_name); + string_set(&conn->user,vuser->server_info->unix_name); + fstrcpy(user,vuser->server_info->unix_name); guest = vuser->server_info->guest; } else if (lp_security() == SEC_SHARE) { NTSTATUS status2; diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 2b964d828f..5e5a184efa 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -164,7 +164,7 @@ bool session_claim(user_struct *vuser) hostname = client_addr(get_client_fd(),addr,sizeof(addr)); } - fstrcpy(sessionid.username, vuser->user.unix_name); + fstrcpy(sessionid.username, vuser->server_info->unix_name); fstrcpy(sessionid.hostname, hostname); sessionid.id_num = i; /* Only valid for utmp sessions */ sessionid.pid = pid; diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c index 0b87b93636..3779c3f608 100644 --- a/source3/smbd/uid.c +++ b/source3/smbd/uid.c @@ -97,12 +97,14 @@ static bool check_user_ok(connection_struct *conn, user_struct *vuser,int snum) } } - if (!user_ok_token(vuser->user.unix_name, vuser->server_info->ptok, + if (!user_ok_token(vuser->server_info->unix_name, + vuser->server_info->ptok, snum)) return(False); readonly_share = is_share_read_only_for_token( - vuser->user.unix_name, vuser->server_info->ptok, SNUM(conn)); + vuser->server_info->unix_name, vuser->server_info->ptok, + SNUM(conn)); token = conn->nt_user_token ? conn->nt_user_token : vuser->server_info->ptok; @@ -132,7 +134,7 @@ static bool check_user_ok(connection_struct *conn, user_struct *vuser,int snum) ent->read_only = readonly_share; ent->admin_user = token_contains_name_in_list( - vuser->user.unix_name, NULL, vuser->server_info->ptok, + vuser->server_info->unix_name, NULL, vuser->server_info->ptok, lp_admin_users(SNUM(conn))); conn->read_only = ent->read_only; @@ -188,7 +190,8 @@ bool change_to_user(connection_struct *conn, uint16 vuid) if ((vuser) && !check_user_ok(conn, vuser, snum)) { DEBUG(2,("change_to_user: SMB user %s (unix user %s, vuid %d) " "not permitted access to share %s.\n", - vuser->user.smb_name, vuser->user.unix_name, vuid, + vuser->server_info->sanitized_username, + vuser->server_info->unix_name, vuid, lp_servicename(snum))); return False; } -- cgit