summaryrefslogtreecommitdiff
path: root/source3/passdb
diff options
context:
space:
mode:
Diffstat (limited to 'source3/passdb')
-rw-r--r--source3/passdb/pdb_get_set.c64
-rw-r--r--source3/passdb/pdb_tdb.c35
2 files changed, 60 insertions, 39 deletions
diff --git a/source3/passdb/pdb_get_set.c b/source3/passdb/pdb_get_set.c
index 181364ab6b..cf77efd38f 100644
--- a/source3/passdb/pdb_get_set.c
+++ b/source3/passdb/pdb_get_set.c
@@ -493,11 +493,11 @@ BOOL pdb_set_username(SAM_ACCOUNT *sampass, const char *username)
{
if (!sampass)
return False;
-
- DEBUG(10, ("pdb_set_username: setting username %s, was %s\n",
- username, sampass->private.username));
if (username) {
+ DEBUG(10, ("pdb_set_username: setting username %s, was %s\n", username,
+ (sampass->private.username)?(sampass->private.username):"NULL"));
+
sampass->private.username = talloc_strdup(sampass->mem_ctx, username);
if (!sampass->private.username) {
@@ -521,10 +521,10 @@ BOOL pdb_set_domain(SAM_ACCOUNT *sampass, const char *domain)
if (!sampass)
return False;
- DEBUG(10, ("pdb_set_domain: setting domain %s, was %s\n",
- domain, sampass->private.domain));
-
if (domain) {
+ DEBUG(10, ("pdb_set_domain: setting domain %s, was %s\n", domain,
+ (sampass->private.domain)?(sampass->private.domain):"NULL"));
+
sampass->private.domain = talloc_strdup(sampass->mem_ctx, domain);
if (!sampass->private.domain) {
@@ -548,10 +548,10 @@ BOOL pdb_set_nt_username(SAM_ACCOUNT *sampass, const char *nt_username)
if (!sampass)
return False;
- DEBUG(10, ("pdb_set_nt_username: setting nt username %s, was %s\n",
- nt_username, sampass->private.nt_username));
-
if (nt_username) {
+ DEBUG(10, ("pdb_set_nt_username: setting nt username %s, was %s\n", nt_username,
+ (sampass->private.nt_username)?(sampass->private.nt_username):"NULL"));
+
sampass->private.nt_username = talloc_strdup(sampass->mem_ctx, nt_username);
if (!sampass->private.nt_username) {
@@ -575,10 +575,10 @@ BOOL pdb_set_fullname(SAM_ACCOUNT *sampass, const char *full_name)
if (!sampass)
return False;
- DEBUG(10, ("pdb_set_full_name: setting full name %s, was %s\n",
- full_name, sampass->private.full_name));
-
if (full_name) {
+ DEBUG(10, ("pdb_set_full_name: setting full name %s, was %s\n", full_name,
+ (sampass->private.full_name)?(sampass->private.full_name):"NULL"));
+
sampass->private.full_name = talloc_strdup(sampass->mem_ctx, full_name);
if (!sampass->private.full_name) {
@@ -602,10 +602,10 @@ BOOL pdb_set_logon_script(SAM_ACCOUNT *sampass, const char *logon_script, BOOL s
if (!sampass)
return False;
- DEBUG(10, ("pdb_set_logon_script: setting logon script (store:%d) %s, was %s\n",
- store, logon_script, sampass->private.logon_script));
-
if (logon_script) {
+ DEBUG(10, ("pdb_set_logon_script: setting logon script %s, was %s\n", logon_script,
+ (sampass->private.logon_script)?(sampass->private.logon_script):"NULL"));
+
sampass->private.logon_script = talloc_strdup(sampass->mem_ctx, logon_script);
if (!sampass->private.logon_script) {
@@ -617,8 +617,10 @@ BOOL pdb_set_logon_script(SAM_ACCOUNT *sampass, const char *logon_script, BOOL s
sampass->private.logon_script = PDB_NOT_QUITE_NULL;
}
- if (store)
- pdb_set_init_flag(sampass, FLAG_SAM_LOGONSCRIPT);
+ if (store) {
+ DEBUG(10, ("pdb_set_logon_script: setting logon script sam flag!"));
+ pdb_set_init_flag(sampass, FLAG_SAM_LOGONSCRIPT);
+ }
return True;
}
@@ -632,10 +634,10 @@ BOOL pdb_set_profile_path (SAM_ACCOUNT *sampass, const char *profile_path, BOOL
if (!sampass)
return False;
- DEBUG(10, ("pdb_set_profile_path: setting profile path (store:%d) %s, was %s\n",
- store, profile_path, sampass->private.profile_path));
-
if (profile_path) {
+ DEBUG(10, ("pdb_set_profile_path: setting profile path %s, was %s\n", profile_path,
+ (sampass->private.profile_path)?(sampass->private.profile_path):"NULL"));
+
sampass->private.profile_path = talloc_strdup(sampass->mem_ctx, profile_path);
if (!sampass->private.profile_path) {
@@ -647,8 +649,10 @@ BOOL pdb_set_profile_path (SAM_ACCOUNT *sampass, const char *profile_path, BOOL
sampass->private.profile_path = PDB_NOT_QUITE_NULL;
}
- if (store)
+ if (store) {
+ DEBUG(10, ("pdb_set_profile_path: setting profile path sam flag!"));
pdb_set_init_flag(sampass, FLAG_SAM_PROFILE);
+ }
return True;
}
@@ -663,6 +667,9 @@ BOOL pdb_set_dir_drive (SAM_ACCOUNT *sampass, const char *dir_drive, BOOL store)
return False;
if (dir_drive) {
+ DEBUG(10, ("pdb_set_dir_drive: setting dir drive %s, was %s\n", dir_drive,
+ (sampass->private.dir_drive)?(sampass->private.dir_drive):"NULL"));
+
sampass->private.dir_drive = talloc_strdup(sampass->mem_ctx, dir_drive);
if (!sampass->private.dir_drive) {
@@ -674,8 +681,10 @@ BOOL pdb_set_dir_drive (SAM_ACCOUNT *sampass, const char *dir_drive, BOOL store)
sampass->private.dir_drive = PDB_NOT_QUITE_NULL;
}
- if (store)
+ if (store) {
+ DEBUG(10, ("pdb_set_dir_drive: setting dir drive sam flag!"));
pdb_set_init_flag(sampass, FLAG_SAM_DRIVE);
+ }
return True;
}
@@ -690,6 +699,9 @@ BOOL pdb_set_homedir (SAM_ACCOUNT *sampass, const char *home_dir, BOOL store)
return False;
if (home_dir) {
+ DEBUG(10, ("pdb_set_homedir: setting home dir %s, was %s\n", home_dir,
+ (sampass->private.home_dir)?(sampass->private.home_dir):"NULL"));
+
sampass->private.home_dir = talloc_strdup(sampass->mem_ctx, home_dir);
if (!sampass->private.home_dir) {
@@ -701,8 +713,10 @@ BOOL pdb_set_homedir (SAM_ACCOUNT *sampass, const char *home_dir, BOOL store)
sampass->private.home_dir = PDB_NOT_QUITE_NULL;
}
- if (store)
+ if (store) {
+ DEBUG(10, ("pdb_set_homedir: setting home dir sam flag!"));
pdb_set_init_flag(sampass, FLAG_SAM_SMBHOME);
+ }
return True;
}
@@ -741,6 +755,9 @@ BOOL pdb_set_workstations (SAM_ACCOUNT *sampass, const char *workstations)
return False;
if (workstations) {
+ DEBUG(10, ("pdb_set_workstations: setting workstations %s, was %s\n", workstations,
+ (sampass->private.workstations)?(sampass->private.workstations):"NULL"));
+
sampass->private.workstations = talloc_strdup(sampass->mem_ctx, workstations);
if (!sampass->private.workstations) {
@@ -787,6 +804,7 @@ BOOL pdb_set_munged_dial (SAM_ACCOUNT *sampass, const char *munged_dial)
{
if (!sampass)
return False;
+
if (munged_dial) {
sampass->private.munged_dial = talloc_strdup(sampass->mem_ctx, munged_dial);
diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c
index 86089cfd69..b55a74d290 100644
--- a/source3/passdb/pdb_tdb.c
+++ b/source3/passdb/pdb_tdb.c
@@ -90,6 +90,7 @@ static BOOL init_sam_from_buffer (struct tdbsam_privates *tdb_state,
BOOL ret = True;
BOOL setflag;
gid_t gid = -1; /* This is what standard sub advanced expects if no gid is known */
+ pstring sub_buffer;
if(sampass == NULL || buf == NULL) {
DEBUG(0, ("init_sam_from_buffer: NULL parameters found!\n"));
@@ -144,9 +145,8 @@ static BOOL init_sam_from_buffer (struct tdbsam_privates *tdb_state,
* getpwnam() is used instead of Get_Pwnam() as we do not need
* to try case permutations
*/
- if (!username || !(pw=getpwnam_alloc(username))) {
- DEBUG(0,("tdbsam: getpwnam_alloc(%s) return NULL. User does not exist!\n",
- username?username:"NULL"));
+ if (!username || !(pw = getpwnam_alloc(username))) {
+ DEBUG(0,("tdbsam: getpwnam_alloc(%s) return NULL. User does not exist!\n", username?username:"NULL"));
ret = False;
goto done;
}
@@ -174,9 +174,11 @@ static BOOL init_sam_from_buffer (struct tdbsam_privates *tdb_state,
if (homedir) setflag = True;
else {
setflag = False;
- homedir = strdup(lp_logon_home());
+ pstrcpy(sub_buffer, lp_logon_home());
+ /* standard_sub_advanced() assumes pstring is passed!! */
+ standard_sub_advanced(-1, username, "", gid, username, sub_buffer);
+ homedir = strdup(sub_buffer);
if(!homedir) { ret = False; goto done; }
- standard_sub_advanced(-1, username, "", gid, username, homedir);
DEBUG(5,("Home directory set back to %s\n", homedir));
}
pdb_set_homedir(sampass, homedir, setflag);
@@ -184,30 +186,33 @@ static BOOL init_sam_from_buffer (struct tdbsam_privates *tdb_state,
if (dir_drive) setflag = True;
else {
setflag = False;
- dir_drive = strdup(lp_logon_drive());
+ pstrcpy(sub_buffer, lp_logon_drive());
+ standard_sub_advanced(-1, username, "", gid, username, sub_buffer);
+ dir_drive = strdup(sub_buffer);
if(!dir_drive) { ret = False; goto done; }
- standard_sub_advanced(-1, username, "", gid, username, dir_drive);
- DEBUG(5,("Home directory set back to %s\n", dir_drive));
+ DEBUG(5,("Drive set back to %s\n", dir_drive));
}
pdb_set_dir_drive(sampass, dir_drive, setflag);
if (logon_script) setflag = True;
else {
setflag = False;
- logon_script = strdup(lp_logon_script());
+ pstrcpy(sub_buffer, lp_logon_script());
+ standard_sub_advanced(-1, username, "", gid, username, sub_buffer);
+ logon_script = strdup(sub_buffer);
if(!logon_script) { ret = False; goto done; }
- standard_sub_advanced(-1, username, "", gid, username, logon_script);
- DEBUG(5,("Home directory set back to %s\n", logon_script));
+ DEBUG(5,("Logon script set back to %s\n", logon_script));
}
pdb_set_logon_script(sampass, logon_script, setflag);
if (profile_path) setflag = True;
else {
setflag = False;
- profile_path = strdup(lp_logon_path());
+ pstrcpy(sub_buffer, lp_logon_path());
+ standard_sub_advanced(-1, username, "", gid, username, sub_buffer);
+ profile_path = strdup(sub_buffer);
if(!profile_path) { ret = False; goto done; }
- standard_sub_advanced(-1, username, "", gid, username, profile_path);
- DEBUG(5,("Home directory set back to %s\n", profile_path));
+ DEBUG(5,("Profile path set back to %s\n", profile_path));
}
pdb_set_profile_path(sampass, profile_path, setflag);
@@ -223,8 +228,6 @@ static BOOL init_sam_from_buffer (struct tdbsam_privates *tdb_state,
goto done;
}
- /*pdb_set_uid(sampass, uid);
- pdb_set_gid(sampass, gid);*/
pdb_set_user_rid(sampass, user_rid);
pdb_set_group_rid(sampass, group_rid);
pdb_set_unknown_3(sampass, unknown_3);