summaryrefslogtreecommitdiff
path: root/source3/passdb
diff options
context:
space:
mode:
Diffstat (limited to 'source3/passdb')
-rw-r--r--source3/passdb/pdb_ldap.c4
-rw-r--r--source3/passdb/pdb_nisplus.c5
-rw-r--r--source3/passdb/pdb_tdb.c6
3 files changed, 11 insertions, 4 deletions
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index 2de02d9b76..b8ec37814d 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -500,7 +500,7 @@ static BOOL init_sam_from_ldap (SAM_ACCOUNT * sampass,
/* These values MAY be in LDAP, but they can also be retrieved through
* sys_getpw*() which is how we're doing it
*/
- pw = getpwnam(username);
+ pw = getpwnam_alloc(username);
if (pw == NULL) {
DEBUG (2,("init_sam_from_ldap: User [%s] does not ave a uid!\n", username));
return False;
@@ -508,6 +508,8 @@ static BOOL init_sam_from_ldap (SAM_ACCOUNT * sampass,
uid = pw->pw_uid;
gid = pw->pw_gid;
+ passwd_free(&pw);
+
/* FIXME: hours stuff should be cleaner */
logon_divs = 168;
diff --git a/source3/passdb/pdb_nisplus.c b/source3/passdb/pdb_nisplus.c
index 687115733a..3659f169b8 100644
--- a/source3/passdb/pdb_nisplus.c
+++ b/source3/passdb/pdb_nisplus.c
@@ -1192,14 +1192,17 @@ BOOL pdb_add_sam_account(SAM_ACCOUNT * newpwd)
if (result->status != NIS_SUCCESS || NIS_RES_NUMOBJ(result) <= 0)
{
+ struct passwd *passwd;
DEBUG(3, ("nis_list failure: %s: %s\n",
nisname, nis_sperrno(result->status)));
nis_freeresult(result);
- if (!sys_getpwnam(pdb_get_username(newpwd))) {
+ if (!passwd = getpwnam_alloc(pdb_get_username(newpwd))) {
/* no such user in system! */
return False;
}
+ passwd_free(&passwd);
+
/*
* user is defined, but not in passwd.org_dir.
*/
diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c
index 30fe3dc354..b1ba01fe98 100644
--- a/source3/passdb/pdb_tdb.c
+++ b/source3/passdb/pdb_tdb.c
@@ -141,14 +141,16 @@ 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(username))) {
- DEBUG(0,("tdb_sam: getpwnam(%s) return NULL. User does not exist!\n",
+ if (!username || !(pw=getpwnam_alloc(username))) {
+ DEBUG(0,("tdb_sam: getpwnam_alloc(%s) return NULL. User does not exist!\n",
username?username:"NULL"));
ret = False;
goto done;
}
uid = pw->pw_uid;
gid = pw->pw_gid;
+
+ passwd_free(&pw);
pdb_set_uid(sampass, uid);
pdb_set_gid(sampass, gid);