diff options
author | Volker Lendecke <vl@samba.org> | 2008-05-07 13:16:20 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2008-05-10 11:17:00 +0200 |
commit | ddcea20947fb3ca5ccd9e2a1e024ac8296dc4055 (patch) | |
tree | b68591292420fca0bdb914d613c30c074b1a30b4 | |
parent | ca2580028744c8c9301487ffee87befdd94be383 (diff) | |
download | samba-ddcea20947fb3ca5ccd9e2a1e024ac8296dc4055.tar.gz samba-ddcea20947fb3ca5ccd9e2a1e024ac8296dc4055.tar.bz2 samba-ddcea20947fb3ca5ccd9e2a1e024ac8296dc4055.zip |
Replace find_forced_user by a direct call to make_serverinfo_from_username
(This used to be commit 7991e6764b4187ba86802569dfdc5816e6137f78)
-rw-r--r-- | source3/smbd/service.c | 63 |
1 files changed, 26 insertions, 37 deletions
diff --git a/source3/smbd/service.c b/source3/smbd/service.c index a95f756132..e3635d45db 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -523,31 +523,6 @@ static NTSTATUS share_sanity_checks(int snum, fstring dev) return NT_STATUS_OK; } -static NTSTATUS find_forced_user(connection_struct *conn, bool vuser_is_guest, fstring username) -{ - int snum = conn->params->service; - char *fuser, *found_username; - NTSTATUS result; - - if (!(fuser = talloc_string_sub(conn, lp_force_user(snum), "%S", - lp_servicename(snum)))) { - return NT_STATUS_NO_MEMORY; - } - - result = create_token_from_username(conn, fuser, vuser_is_guest, - &conn->uid, &conn->gid, &found_username, - &conn->nt_user_token); - if (!NT_STATUS_IS_OK(result)) { - return result; - } - - fstrcpy(username, found_username); - - TALLOC_FREE(fuser); - TALLOC_FREE(found_username); - return NT_STATUS_OK; -} - /* * Go through lookup_name etc to find the force'd group. * @@ -766,13 +741,8 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser, conn->force_user = true; } - conn->vuid = (vuser != NULL) ? vuser->vuid : UID_FIELD_INVALID; - - conn->uid = conn->server_info->uid; - conn->gid = conn->server_info->gid; - string_set(&conn->user, conn->server_info->unix_name); - add_session_user(conn->user); + add_session_user(conn->server_info->unix_name); safe_strcpy(conn->client_address, client_addr(get_client_fd(),addr,sizeof(addr)), @@ -815,20 +785,39 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser, */ if (*lp_force_user(snum)) { - fstring tmp; - fstrcpy(tmp, conn->user); - status = find_forced_user(conn, - (vuser != NULL) && vuser->server_info->guest, - tmp); + char *fuser; + struct auth_serversupplied_info *forced_serverinfo; + + fuser = talloc_string_sub(conn, lp_force_user(snum), "%S", + lp_servicename(snum)); + if (fuser == NULL) { + conn_free(conn); + *pstatus = NT_STATUS_NO_MEMORY; + return NULL; + } + + status = make_serverinfo_from_username( + conn, fuser, conn->server_info->guest, + &forced_serverinfo); if (!NT_STATUS_IS_OK(status)) { conn_free(conn); *pstatus = status; return NULL; } + + TALLOC_FREE(conn->server_info); + conn->server_info = forced_serverinfo; + conn->force_user = True; - DEBUG(3,("Forced user %s\n",tmp)); + DEBUG(3,("Forced user %s\n", fuser)); } + conn->vuid = (vuser != NULL) ? vuser->vuid : UID_FIELD_INVALID; + + conn->uid = conn->server_info->uid; + conn->gid = conn->server_info->gid; + string_set(&conn->user, conn->server_info->unix_name); + /* * If force group is true, then override * any groupid stored for the connecting user. |