summaryrefslogtreecommitdiff
path: root/source3/utils/pdbedit.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2002-01-23 12:59:24 +0000
committerAndrew Bartlett <abartlet@samba.org>2002-01-23 12:59:24 +0000
commit158efc3aa2060e21f40e231a1e8aa945b6a3ab71 (patch)
tree3d40e855783ac527f14c92ac64dcd96647267fab /source3/utils/pdbedit.c
parent44dd648a646e58ad69f250dcd23fe56d7885efd2 (diff)
downloadsamba-158efc3aa2060e21f40e231a1e8aa945b6a3ab71.tar.gz
samba-158efc3aa2060e21f40e231a1e8aa945b6a3ab71.tar.bz2
samba-158efc3aa2060e21f40e231a1e8aa945b6a3ab71.zip
getpwnam -> getpwnam_alloc.
idra has promised not to revert these this time :-) (This used to be commit f556ad67e82518f5a024ffe9184ff9430ab5c541)
Diffstat (limited to 'source3/utils/pdbedit.c')
-rw-r--r--source3/utils/pdbedit.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c
index 33b62ebd42..08ba54605f 100644
--- a/source3/utils/pdbedit.c
+++ b/source3/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)