r4860: fix silly limitation in ldapsam and tdbsam. Expand variables in the profile...
authorGerald Carter <jerry@samba.org>
Wed, 19 Jan 2005 22:50:27 +0000 (22:50 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:54:00 +0000 (10:54 -0500)
(This used to be commit 504ea4ac68f47b71542a88b17cbb6b546e1cb881)

source3/passdb/passdb.c
source3/passdb/pdb_ldap.c

index aeea4316f381b0d942282f639fc8bb12bdd8b55d..1f5e4be6cf60584414621e634fe5ec0bdcfeaba1 100644 (file)
@@ -1777,6 +1777,7 @@ BOOL init_sam_from_buffer_v2(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
        uint32          lm_pw_len, nt_pw_len, nt_pw_hist_len, hourslen;
        uint32 pwHistLen = 0;
        BOOL ret = True;
+       fstring tmpstring;
        
        if(sampass == NULL || buf == NULL) {
                DEBUG(0, ("init_sam_from_buffer_v2: NULL parameters found!\n"));
@@ -1840,7 +1841,9 @@ BOOL init_sam_from_buffer_v2(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
        pdb_set_fullname(sampass, fullname, PDB_SET);
 
        if (homedir) {
-               pdb_set_homedir(sampass, homedir, PDB_SET);
+               fstrcpy( tmpstring, homedir );
+               standard_sub_basic( username, tmpstring, sizeof(tmpstring) );
+               pdb_set_homedir(sampass, tmpstring, PDB_SET);
        }
        else {
                pdb_set_homedir(sampass, 
@@ -1850,14 +1853,14 @@ BOOL init_sam_from_buffer_v2(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
 
        if (dir_drive)  
                pdb_set_dir_drive(sampass, dir_drive, PDB_SET);
-       else {
-               pdb_set_dir_drive(sampass, 
-                       talloc_sub_basic(sampass->mem_ctx,  username, lp_logon_drive()),
-                       PDB_DEFAULT);
-       }
+       else
+               pdb_set_dir_drive(sampass, lp_logon_drive(), PDB_DEFAULT );
 
-       if (logon_script) 
-               pdb_set_logon_script(sampass, logon_script, PDB_SET);
+       if (logon_script) {
+               fstrcpy( tmpstring, logon_script );
+               standard_sub_basic( username, tmpstring, sizeof(tmpstring) );
+               pdb_set_logon_script(sampass, tmpstring, PDB_SET);
+       }
        else {
                pdb_set_logon_script(sampass, 
                        talloc_sub_basic(sampass->mem_ctx, username, lp_logon_script()),
@@ -1865,8 +1868,11 @@ BOOL init_sam_from_buffer_v2(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
        }
        
        if (profile_path) {     
-               pdb_set_profile_path(sampass, profile_path, PDB_SET);
-       } else {
+               fstrcpy( tmpstring, profile_path );
+               standard_sub_basic( username, tmpstring, sizeof(tmpstring) );
+               pdb_set_profile_path(sampass, tmpstring, PDB_SET);
+       } 
+       else {
                pdb_set_profile_path(sampass, 
                        talloc_sub_basic(sampass->mem_ctx, username, lp_logon_path()),
                        PDB_DEFAULT);
index 0c6e59b2fcd15f07d819cc5e24d2bdbdc7d04e0a..8b7661d9a36fb86a3e9e0f4a3c26deaf60f68d2c 100644 (file)
@@ -476,6 +476,7 @@ static BOOL init_sam_from_ldap (struct ldapsam_privates *ldap_state,
        pstring temp;
        LOGIN_CACHE     *cache_entry = NULL;
        int pwHistLen;
+       pstring         tmpstring;
 
        /*
         * do a little initialization
@@ -635,9 +636,7 @@ static BOOL init_sam_from_ldap (struct ldapsam_privates *ldap_state,
        if (!smbldap_get_single_pstring(ldap_state->smbldap_state->ldap_struct, entry, 
                        get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_HOME_DRIVE), dir_drive)) 
        {
-               pdb_set_dir_drive( sampass, 
-                       talloc_sub_basic(sampass->mem_ctx, username, lp_logon_drive()),
-                       PDB_DEFAULT );
+               pdb_set_dir_drive( sampass, lp_logon_drive(), PDB_DEFAULT );
        } else {
                pdb_set_dir_drive(sampass, dir_drive, PDB_SET);
        }
@@ -649,7 +648,9 @@ static BOOL init_sam_from_ldap (struct ldapsam_privates *ldap_state,
                        talloc_sub_basic(sampass->mem_ctx, username, lp_logon_home()),
                        PDB_DEFAULT );
        } else {
-               pdb_set_homedir(sampass, homedir, PDB_SET);
+               pstrcpy( tmpstring, homedir );
+               standard_sub_basic( username, tmpstring, sizeof(tmpstring) );
+               pdb_set_homedir(sampass, tmpstring, PDB_SET);
        }
 
        if (!smbldap_get_single_pstring(ldap_state->smbldap_state->ldap_struct, entry,
@@ -659,7 +660,9 @@ static BOOL init_sam_from_ldap (struct ldapsam_privates *ldap_state,
                        talloc_sub_basic(sampass->mem_ctx, username, lp_logon_script()), 
                        PDB_DEFAULT );
        } else {
-               pdb_set_logon_script(sampass, logon_script, PDB_SET);
+               pstrcpy( tmpstring, logon_script );
+               standard_sub_basic( username, tmpstring, sizeof(tmpstring) );
+               pdb_set_logon_script(sampass, tmpstring, PDB_SET);
        }
 
        if (!smbldap_get_single_pstring(ldap_state->smbldap_state->ldap_struct, entry,
@@ -669,7 +672,9 @@ static BOOL init_sam_from_ldap (struct ldapsam_privates *ldap_state,
                        talloc_sub_basic( sampass->mem_ctx, username, lp_logon_path()),
                        PDB_DEFAULT );
        } else {
-               pdb_set_profile_path(sampass, profile_path, PDB_SET);
+               pstrcpy( tmpstring, profile_path );
+               standard_sub_basic( username, tmpstring, sizeof(tmpstring) );
+               pdb_set_profile_path(sampass, tmpstring, PDB_SET);
        }
 
        if (!smbldap_get_single_pstring(ldap_state->smbldap_state->ldap_struct, entry,