From 2b3d03d6f16e4110d0000cbb10a087cef2ce9e44 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 29 Apr 2008 13:23:47 +0200 Subject: Remove unix_homedir from struct user_struct This makes pdb_get_unix_homedir unused. I wonder if that was ever really used... (This used to be commit 36bfd32f1ff878e827db91e9bf233719ecca5b01) --- source3/include/passdb.h | 1 - source3/include/smb.h | 1 - source3/passdb/pdb_get_set.c | 8 ----- source3/smbd/password.c | 72 +++++++++++++++++++++----------------------- 4 files changed, 35 insertions(+), 47 deletions(-) (limited to 'source3') diff --git a/source3/include/passdb.h b/source3/include/passdb.h index 8d5934df52..360a0d0444 100644 --- a/source3/include/passdb.h +++ b/source3/include/passdb.h @@ -59,7 +59,6 @@ enum pdb_elements { PDB_GROUPSID, PDB_ACCTCTRL, PDB_PASSLASTSET, - PDB_UNIXHOMEDIR, PDB_ACCTDESC, PDB_WORKSTATIONS, PDB_COMMENT, diff --git a/source3/include/smb.h b/source3/include/smb.h index cb36b9bebb..2ec432929d 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -1781,7 +1781,6 @@ typedef struct user_struct { gid_t gid; /* gid of a validated user */ userdom_struct user; - const char *unix_homedir; const char *logon_script; bool guest; diff --git a/source3/passdb/pdb_get_set.c b/source3/passdb/pdb_get_set.c index c427d41e23..7a8086c63e 100644 --- a/source3/passdb/pdb_get_set.c +++ b/source3/passdb/pdb_get_set.c @@ -301,14 +301,6 @@ const char *pdb_get_homedir(const struct samu *sampass) return sampass->home_dir; } -const char *pdb_get_unix_homedir(const struct samu *sampass) -{ - if (sampass->unix_pw ) { - return sampass->unix_pw->pw_dir; - } - return NULL; -} - const char *pdb_get_dir_drive(const struct samu *sampass) { return sampass->dir_drive; diff --git a/source3/smbd/password.c b/source3/smbd/password.c index a7e462a0ca..74fa645c13 100644 --- a/source3/smbd/password.c +++ b/source3/smbd/password.c @@ -201,6 +201,37 @@ int register_initial_vuid(void) return vuser->vuid; } +static int register_homes_share(const char *username) +{ + int result; + struct passwd *pwd; + + result = lp_servicenumber(username); + if (result != -1) { + DEBUG(3, ("Using static (or previously created) service for " + "user '%s'; path = '%s'\n", username, + lp_pathname(result))); + return result; + } + + pwd = getpwnam_alloc(talloc_tos(), username); + + if ((pwd == NULL) || (pwd->pw_dir[0] == '\0')) { + DEBUG(3, ("No home directory defined for user '%s'\n", + username)); + TALLOC_FREE(pwd); + return -1; + } + + DEBUG(3, ("Adding homes service for user '%s' using home directory: " + "'%s'\n", username, pwd->pw_dir)); + + result = add_home_service(username, username, pwd->pw_dir); + + TALLOC_FREE(pwd); + return result; +} + /** * register that a valid login has been performed, establish 'session'. * @param server_info The token returned from the authentication process. @@ -271,26 +302,6 @@ int register_existing_vuid(uint16 vuid, const char *logon_script = pdb_get_logon_script(server_info->sam_account); - if (!IS_SAM_DEFAULT(server_info->sam_account, - PDB_UNIXHOMEDIR)) { - const char *unix_homedir = - pdb_get_unix_homedir(server_info->sam_account); - if (unix_homedir) { - vuser->unix_homedir = unix_homedir; - } - } else { - struct passwd *passwd = - getpwnam_alloc(vuser, vuser->user.unix_name); - if (passwd) { - vuser->unix_homedir = passwd->pw_dir; - /* Ensure that the unix_homedir now - * belongs to vuser, so it goes away - * with it, not with passwd below: */ - talloc_steal(vuser, vuser->unix_homedir); - TALLOC_FREE(passwd); - } - } - if (logon_script) { vuser->logon_script = logon_script; } @@ -336,23 +347,10 @@ int register_existing_vuid(uint16 vuid, If a share exists by this name (autoloaded or not) reuse it . */ vuser->homes_snum = -1; - if ( (!vuser->guest) && vuser->unix_homedir && *(vuser->unix_homedir)) { - int servicenumber = lp_servicenumber(vuser->user.unix_name); - if ( servicenumber == -1 ) { - DEBUG(3, ("Adding homes service for user '%s' using " - "home directory: '%s'\n", - vuser->user.unix_name, vuser->unix_homedir)); - vuser->homes_snum = - add_home_service(vuser->user.unix_name, - vuser->user.unix_name, - vuser->unix_homedir); - } else { - DEBUG(3, ("Using static (or previously created) " - "service for user '%s'; path = '%s'\n", - vuser->user.unix_name, - lp_pathname(servicenumber) )); - vuser->homes_snum = servicenumber; - } + + if (!vuser->guest) { + vuser->homes_snum = register_homes_share( + vuser->user.unix_name); } if (srv_is_signing_negotiated() && !vuser->guest && -- cgit