diff options
author | Lars Müller <lmuelle@samba.org> | 2006-02-16 16:22:44 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:10:10 -0500 |
commit | 394d1aeb8e2922a261efa78d65fc21defde63448 (patch) | |
tree | 4ae9cbaea3a9d8e5e9a9c7cb1a503f1577faf8b0 /source3/utils/pdbedit.c | |
parent | ee078e61a6e4d0ae462ff480d89eb83298523ec3 (diff) | |
download | samba-394d1aeb8e2922a261efa78d65fc21defde63448.tar.gz samba-394d1aeb8e2922a261efa78d65fc21defde63448.tar.bz2 samba-394d1aeb8e2922a261efa78d65fc21defde63448.zip |
r13524: Add -t|--password-from-stdin option to pdbedit as we had with Samba 2.2.
This fixes bug #1386.
The initial changes had been made by Carsten Höger <choeger at
open-xhange dot com> 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)
Diffstat (limited to 'source3/utils/pdbedit.c')
-rw-r--r-- | source3/utils/pdbedit.c | 20 |
1 files changed, 10 insertions, 10 deletions
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); } } |