From 158efc3aa2060e21f40e231a1e8aa945b6a3ab71 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 23 Jan 2002 12:59:24 +0000 Subject: getpwnam -> getpwnam_alloc. idra has promised not to revert these this time :-) (This used to be commit f556ad67e82518f5a024ffe9184ff9430ab5c541) --- source3/utils/pdbedit.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'source3/utils') 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) -- cgit