r13601: * Remove unused code from pdb_ldap.c
authorGerald Carter <jerry@samba.org>
Tue, 21 Feb 2006 19:22:49 +0000 (19:22 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:10:18 +0000 (11:10 -0500)
* Add a 'struct passwd *' to the struct samu for later reference
  (I know this may be controversial but its easily reverted which is
  is why I'm checking this is as a seaparate patch before I get
  too deep).
* Remove unix_homedir from struct samu {} and update the pdb wrapper
  functions associated with it.

source/include/passdb.h
source/lib/util_pw.c
source/passdb/passdb.c
source/passdb/pdb_get_set.c
source/passdb/pdb_ldap.c

index 68165ca3d579d47202918ca452f354841bd55f27..3c1e9bb5b74c93ea978359f4a2c6cfa851d1f74d 100644 (file)
@@ -154,7 +154,6 @@ struct samu {
        const char *domain;       /* Windows Domain name */
        const char *nt_username;  /* Windows username string */
        const char *full_name;    /* user's full name string */
-       const char *unix_home_dir;     /* UNIX home directory string */
        const char *home_dir;     /* home directory string */
        const char *dir_drive;    /* home directory drive string */
        const char *logon_script; /* logon script string */
@@ -189,7 +188,10 @@ struct samu {
        const struct pdb_methods *backend_private_methods;
        void *backend_private_data; 
        void (*backend_private_data_free_fn)(void **);
+       
+       /* maintain a copy of the user's struct passwd */
 
+       struct passwd *unix_pw;
 };
 
 struct acct_info {
index e6328463123a02a7c527171d4a30801f88805750..e1bea1a6465ae08411672bbd11e96472c9dcd773 100644 (file)
@@ -22,8 +22,7 @@
 
 #include "includes.h"
 
-static struct passwd *talloc_copy_passwd(TALLOC_CTX *mem_ctx,
-                                        const struct passwd *from) 
+struct passwd *tcopy_passwd(TALLOC_CTX *mem_ctx, const struct passwd *from) 
 {
        struct passwd *ret = TALLOC_P(mem_ctx, struct passwd);
        ret->pw_name = talloc_strdup(ret, from->pw_name);
@@ -99,13 +98,13 @@ struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name)
                TALLOC_FREE(pwnam_cache[i]);
        }
 
-       pwnam_cache[i] = talloc_copy_passwd(pwnam_cache, temp);
+       pwnam_cache[i] = tcopy_passwd(pwnam_cache, temp);
 
        if (mem_ctx != NULL) {
                return talloc_reference(mem_ctx, pwnam_cache[i]);
        }
 
-       return talloc_copy_passwd(NULL, pwnam_cache[i]);
+       return tcopy_passwd(NULL, pwnam_cache[i]);
 }
 
 struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid) 
@@ -123,5 +122,5 @@ struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid)
                return NULL;
        }
 
-       return talloc_copy_passwd(mem_ctx, temp);
+       return tcopy_passwd(mem_ctx, temp);
 }
index 6c84cccf79d9b40b6018fd1cf80a5c8a9f02d95b..6c84303947d8040823080b1d0a0b310282aea360 100644 (file)
@@ -152,11 +152,16 @@ NTSTATUS samu_set_unix(struct samu *user, const struct passwd *pwd)
                return NT_STATUS_NO_SUCH_USER;
        }
 
+       /* Basic properties based upon the Unix account information */
+
        pdb_set_username(user, pwd->pw_name, PDB_SET);
        pdb_set_fullname(user, pwd->pw_gecos, PDB_SET);
-       pdb_set_unix_homedir(user, pwd->pw_dir, PDB_SET);
        pdb_set_domain (user, get_global_sam_name(), PDB_DEFAULT);
 
+       /* save the password structure for later use */
+
+       user->unix_pw = tcopy_passwd( user, pwd );
+
        /* Special case for the guest account which must have a RID of 501.
           By default the guest account is a member of of the domain users 
           group as well as the domain guests group.  Verified against 
index c39eb7116280a964a765ce8234f9a4b3e314144a..92bc228e01289e371fc03aab2646eff7cd0dac26 100644 (file)
@@ -265,10 +265,10 @@ const char* pdb_get_homedir (const struct samu *sampass)
 
 const char* pdb_get_unix_homedir (const struct samu *sampass)
 {
-       if (sampass)
-               return (sampass->unix_home_dir);
-       else
-               return (NULL);
+       if ( sampass && sampass->unix_pw )
+               return ( sampass->unix_pw->pw_dir );
+
+       return (NULL);
 }
 
 const char* pdb_get_dir_drive (const struct samu *sampass)
@@ -829,34 +829,6 @@ BOOL pdb_set_homedir (struct samu *sampass, const char *home_dir, enum pdb_value
        return pdb_set_init_flags(sampass, PDB_SMBHOME, flag);
 }
 
-/*********************************************************************
- Set the user's unix home directory.
- ********************************************************************/
-
-BOOL pdb_set_unix_homedir (struct samu *sampass, const char *unix_home_dir, enum pdb_value_state flag)
-{
-       if (!sampass)
-               return False;
-
-       if (unix_home_dir) { 
-               DEBUG(10, ("pdb_set_unix_homedir: setting home dir %s, was %s\n", unix_home_dir,
-                       (sampass->unix_home_dir)?(sampass->unix_home_dir):"NULL"));
-               sampass->unix_home_dir = talloc_strdup(sampass, 
-                                                         unix_home_dir);
-               
-               if (!sampass->unix_home_dir) {
-                       DEBUG(0, ("pdb_set_unix_home_dir: talloc_strdup() failed!\n"));
-                       return False;
-               }
-
-       } else {
-               sampass->unix_home_dir = PDB_NOT_QUITE_NULL;
-       }
-
-       return pdb_set_init_flags(sampass, PDB_UNIXHOMEDIR, flag);
-}
-
 /*********************************************************************
  Set the user's account description.
  ********************************************************************/
index 3344b17888701fa8d19a157059531f0d1421a9b8..89b958e915f6ba5fae5df35d37df6f0a4200c20f 100644 (file)
@@ -441,67 +441,7 @@ static int ldapsam_delete_entry(struct ldapsam_privates *priv,
        return smbldap_modify(priv->smbldap_state, dn, mods);
 }
                  
-/* New Interface is being implemented here */
-
-#if 0  /* JERRY - not uesed anymore */
-
-/**********************************************************************
-Initialize struct samu from an LDAP query (unix attributes only)
-*********************************************************************/
-static BOOL get_unix_attributes (struct ldapsam_privates *ldap_state, 
-                               struct samu * sampass,
-                               LDAPMessage * entry,
-                               gid_t *gid)
-{
-       pstring  homedir;
-       pstring  temp;
-       char **ldap_values;
-       char **values;
-
-       if ((ldap_values = ldap_get_values (ldap_state->smbldap_state->ldap_struct, entry, "objectClass")) == NULL) {
-               DEBUG (1, ("get_unix_attributes: no objectClass! \n"));
-               return False;
-       }
-
-       for (values=ldap_values;*values;values++) {
-               if (strequal(*values, LDAP_OBJ_POSIXACCOUNT )) {
-                       break;
-               }
-       }
-       
-       if (!*values) { /*end of array, no posixAccount */
-               DEBUG(10, ("user does not have %s attributes\n", LDAP_OBJ_POSIXACCOUNT));
-               ldap_value_free(ldap_values);
-               return False;
-       }
-       ldap_value_free(ldap_values);
-
-       if ( !smbldap_get_single_pstring(ldap_state->smbldap_state->ldap_struct, entry, 
-               get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_UNIX_HOME), homedir) ) 
-       {
-               return False;
-       }
-       
-       if ( !smbldap_get_single_pstring(ldap_state->smbldap_state->ldap_struct, entry, 
-               get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_GIDNUMBER), temp) )
-       {
-               return False;
-       }
-       
-       *gid = (gid_t)atol(temp);
-
-       pdb_set_unix_homedir(sampass, homedir, PDB_SET);
-       
-       DEBUG(10, ("user has %s attributes\n", LDAP_OBJ_POSIXACCOUNT));
-       
-       return True;
-}
-
-#endif
-
-static time_t ldapsam_get_entry_timestamp(
-       struct ldapsam_privates *ldap_state,
-       LDAPMessage * entry)
+static time_t ldapsam_get_entry_timestamp( struct ldapsam_privates *ldap_state, LDAPMessage * entry)
 {
        pstring temp;   
        struct tm tm;