diff options
author | Andrew Bartlett <abartlet@samba.org> | 2002-01-23 12:59:24 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2002-01-23 12:59:24 +0000 |
commit | f556ad67e82518f5a024ffe9184ff9430ab5c541 (patch) | |
tree | ce6dc37d3a9f0b97e69494fbed2677beef20278a /source | |
parent | 635942ae21793136814a84b1d344f411a5d6e242 (diff) | |
download | samba-f556ad67e82518f5a024ffe9184ff9430ab5c541.tar.gz samba-f556ad67e82518f5a024ffe9184ff9430ab5c541.tar.xz samba-f556ad67e82518f5a024ffe9184ff9430ab5c541.zip |
getpwnam -> getpwnam_alloc.
idra has promised not to revert these this time :-)
Diffstat (limited to 'source')
-rw-r--r-- | source/lib/genrand.c | 3 | ||||
-rw-r--r-- | source/lib/util.c | 6 | ||||
-rw-r--r-- | source/passdb/pdb_ldap.c | 4 | ||||
-rw-r--r-- | source/passdb/pdb_nisplus.c | 5 | ||||
-rw-r--r-- | source/passdb/pdb_tdb.c | 6 | ||||
-rw-r--r-- | source/utils/pdbedit.c | 16 |
6 files changed, 27 insertions, 13 deletions
diff --git a/source/lib/genrand.c b/source/lib/genrand.c index 39e56db9609..4a56235c3dc 100644 --- a/source/lib/genrand.c +++ b/source/lib/genrand.c @@ -158,13 +158,14 @@ static int do_reseed(BOOL use_fd, int fd) * seriously this will be secret. */ - pw = sys_getpwnam("root"); + pw = getpwnam_alloc("root"); if (pw && pw->pw_passwd) { size_t i; unsigned char md4_tmp[16]; mdfour(md4_tmp, (unsigned char *)pw->pw_passwd, strlen(pw->pw_passwd)); for (i=0;i<16;i++) seed_inbuf[8+i] ^= md4_tmp[i]; + passwd_free(&pw); } /* diff --git a/source/lib/util.c b/source/lib/util.c index f598f0aaa46..97ff4e24a0f 100644 --- a/source/lib/util.c +++ b/source/lib/util.c @@ -1091,9 +1091,11 @@ uid_t nametouid(char *name) if (winbind_nametouid(&u, name)) return u; - pass = sys_getpwnam(name); - if (pass) + pass = getpwnam_alloc(name); + if (pass) { return(pass->pw_uid); + passwd_free(&pass); + } return (uid_t)-1; } diff --git a/source/passdb/pdb_ldap.c b/source/passdb/pdb_ldap.c index 2de02d9b762..b8ec37814d9 100644 --- a/source/passdb/pdb_ldap.c +++ b/source/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/source/passdb/pdb_nisplus.c b/source/passdb/pdb_nisplus.c index 687115733a5..3659f169b83 100644 --- a/source/passdb/pdb_nisplus.c +++ b/source/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/source/passdb/pdb_tdb.c b/source/passdb/pdb_tdb.c index 30fe3dc354e..b1ba01fe980 100644 --- a/source/passdb/pdb_tdb.c +++ b/source/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); diff --git a/source/utils/pdbedit.c b/source/utils/pdbedit.c index 33b62ebd42e..08ba54605fc 100644 --- a/source/utils/pdbedit.c +++ b/source/utils/pdbedit.c @@ -227,12 +227,17 @@ static int new_user (char *username, char *fullname, char *homedir, char *drive, ZERO_STRUCT(sam_pwent); - if (!(pwd = sys_getpwnam(username))) { - fprintf (stderr, "User %s does not exist in system passwd!\n", username); - return -1; - } + if (pwd = getpwnam_alloc(username)) { - pdb_init_sam_pw (&sam_pwent, pwd); + pdb_init_sam_pw (&sam_pwent, pwd); + passwd_free(&pwd); + } else { + fprintf (stderr, "WARNING: user %s does not exist in system passwd\n", username); + pdb_init_sam(&sam_pwent); + if (!pdb_set_username(sam_pwent, username)) { + return False; + } + } password1 = getpass("new password:"); password2 = getpass("retype new password:"); @@ -244,7 +249,6 @@ static int new_user (char *username, char *fullname, char *homedir, char *drive, pdb_set_plaintext_passwd(sam_pwent, password1); - pdb_set_username(sam_pwent, username); if (fullname) pdb_set_fullname(sam_pwent, fullname); if (homedir) |