Remove unix_homedir from struct user_struct
authorVolker Lendecke <vl@samba.org>
Tue, 29 Apr 2008 11:23:47 +0000 (13:23 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 5 May 2008 16:28:58 +0000 (18:28 +0200)
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
source3/include/smb.h
source3/passdb/pdb_get_set.c
source3/smbd/password.c

index 8d5934df5217be588eb10bdfc51d8e096673dee2..360a0d04443abaf6beb38b26cb98b006d9f7ec38 100644 (file)
@@ -59,7 +59,6 @@ enum pdb_elements {
        PDB_GROUPSID,
        PDB_ACCTCTRL,
        PDB_PASSLASTSET,
-       PDB_UNIXHOMEDIR,
        PDB_ACCTDESC,
        PDB_WORKSTATIONS,
        PDB_COMMENT,
index cb36b9bebbdd8dcbcb3a17cdd1cdbc62444a8590..2ec432929d511e9c994a15a745ad2b9aab2b987a 100644 (file)
@@ -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;
index c427d41e239d5a93a7fd8f8bfd9820c6b7c84991..7a8086c63e97134b32cce2ea76c21f3afabf936a 100644 (file)
@@ -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;
index a7e462a0cafa87f805cf2fc68325503e34183abe..74fa645c1343ff087dcc96aec0b76e4ac6549034 100644 (file)
@@ -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 &&