From 394d1aeb8e2922a261efa78d65fc21defde63448 Mon Sep 17 00:00:00 2001 From: Lars Müller Date: Thu, 16 Feb 2006 16:22:44 +0000 Subject: r13524: Add -t|--password-from-stdin option to pdbedit as we had with Samba 2.2. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes bug #1386. The initial changes had been made by Carsten Höger for Samba 2.2 while being at SuSE. *sigh* To not duplicate code from smbpasswd in pdbedit stdin_new_passwd() and get_pass() are moved from smbpasswd to utils/passwd_util.c. (This used to be commit dbdc5ba497c6010dbad47c9d77fc8bec5557a328) --- source3/utils/pdbedit.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source3/utils/pdbedit.c') diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index f4d558f07d..1423d9486d 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -394,12 +394,13 @@ static int set_user_info (struct pdb_methods *in, const char *username, static int new_user (struct pdb_methods *in, const char *username, const char *fullname, const char *homedir, const char *drive, const char *script, - const char *profile, char *user_sid, char *group_sid) + const char *profile, char *user_sid, char *group_sid, + BOOL stdin_get) { SAM_ACCOUNT *sam_pwent=NULL; - char *password1, *password2, *staticpass; - + char *password1, *password2; + get_global_sam_sid(); if (!NT_STATUS_IS_OK(pdb_init_sam_new(&sam_pwent, username))) { @@ -407,12 +408,8 @@ static int new_user (struct pdb_methods *in, const char *username, return -1; } - staticpass = getpass("new password:"); - password1 = SMB_STRDUP(staticpass); - memset(staticpass, 0, strlen(staticpass)); - staticpass = getpass("retype new password:"); - password2 = SMB_STRDUP(staticpass); - memset(staticpass, 0, strlen(staticpass)); + password1 = get_pass( "new password:", stdin_get); + password2 = get_pass( "retype new password:", stdin_get); if (strcmp (password1, password2)) { fprintf (stderr, "Passwords does not match!\n"); memset(password1, 0, strlen(password1)); @@ -636,6 +633,7 @@ int main (int argc, char **argv) static char *pwd_can_change_time = NULL; static char *pwd_must_change_time = NULL; static char *pwd_time_format = NULL; + BOOL pw_from_stdin = False; struct pdb_methods *bdef = NULL; poptContext pc; @@ -673,6 +671,7 @@ int main (int argc, char **argv) {"pwd-can-change-time", 0, POPT_ARG_STRING, &pwd_can_change_time, 0, "Set password can change time (unix time in seconds since 1970 if time format not provided)", NULL }, {"pwd-must-change-time", 0, POPT_ARG_STRING, &pwd_must_change_time, 0, "Set password must change time (unix time in seconds since 1970 if time format not provided)", NULL }, {"time-format", 0, POPT_ARG_STRING, &pwd_time_format, 0, "The time format for time parameters", NULL }, + {"password-from-stdin", 't', POPT_ARG_NONE, &pw_from_stdin, 0, "get password from standard in", NULL}, POPT_COMMON_SAMBA POPT_TABLEEND }; @@ -848,7 +847,8 @@ int main (int argc, char **argv) } else { return new_user (bdef, user_name, full_name, home_dir, home_drive, logon_script, - profile_path, user_sid, group_sid); + profile_path, user_sid, group_sid, + pw_from_stdin); } } -- cgit