The Samba-Bugzilla – Attachment 612 Details for
Bug 1386
[patch] pdbedit lost password from stdin feature
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Same patch for 3.0.6.
pdbedit-pw-stdin.diff (text/plain), 4.87 KB, created by
Lars Müller
on 2004-08-24 02:39:31 UTC
(
hide
)
Description:
Same patch for 3.0.6.
Filename:
MIME Type:
Creator:
Lars Müller
Created:
2004-08-24 02:39:31 UTC
Size:
4.87 KB
patch
obsolete
>Author: Carsten Hoeger <choeger at SuSE .de>, Lars Mueller <lmuelle at SuSE dot de> >Bug: bugzilla.Samba.org #1386 >Summary: pdbedit lost password from stdin feature > >Based on Samba 2.2 version made by Carsten Hoeger <choeger at suse dot de>. > >--- samba-3.0.6/source/utils/pdbedit.c >+++ samba-3.0.6/source/utils/pdbedit.c 2004-08-24 11:34:07 >@@ -409,17 +409,60 @@ > return 0; > } > >+/************************************************************* >+ Utility function to prompt for passwords from stdin. Each >+ password entered must end with a newline. >+*************************************************************/ >+static char *stdin_new_passwd(void) >+{ >+ static fstring new_pw; >+ size_t len; >+ >+ ZERO_ARRAY(new_pw); >+ >+ /* >+ * if no error is reported from fgets() and string at least contains >+ * the newline that ends the password, then replace the newline with >+ * a null terminator. >+ */ >+ if ( fgets(new_pw, sizeof(new_pw), stdin) != NULL) { >+ if ((len = strlen(new_pw)) > 0) { >+ if(new_pw[len-1] == '\n') >+ new_pw[len - 1] = 0; >+ } >+ } >+ return(new_pw); >+} >+ >+/************************************************************* >+ Utility function to get passwords via tty or stdin >+ Used if the '-t' option is set to silently get passwords >+ to enable scripting. >+ _copied_ from smbpasswd >+*************************************************************/ >+static char *get_pass( char *prompt, BOOL stdin_get) >+{ >+ char *p; >+ if (stdin_get) { >+ p = stdin_new_passwd(); >+ } else { >+ p = getpass( prompt); >+ } >+ return smb_xstrdup( p); >+} >+ > /********************************************************* > Add New User > **********************************************************/ > static int new_user (struct pdb_context *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; > NTSTATUS nt_status; >- char *password1, *password2, *staticpass; >+ char *password1, *password2; > > get_global_sam_sid(); > >@@ -428,12 +471,8 @@ > return -1; > } > >- staticpass = getpass("new password:"); >- password1 = strdup(staticpass); >- memset(staticpass, 0, strlen(staticpass)); >- staticpass = getpass("retype new password:"); >- password2 = 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)); >@@ -650,6 +679,7 @@ > BOOL account_policy_value_set = False; > static BOOL badpw_reset = False; > static BOOL hours_reset = False; >+ BOOL pw_from_stdin = False; > > struct pdb_context *bin; > struct pdb_context *bout; >@@ -682,6 +722,7 @@ > {"force-initialized-passwords", 0, POPT_ARG_NONE, &force_initialised_password, 0, "Force initialization of corrupt password strings in a passdb backend", NULL}, > {"bad-password-count-reset", 'z', POPT_ARG_NONE, &badpw_reset, 0, "reset bad password count", NULL}, > {"logon-hours-reset", 'Z', POPT_ARG_NONE, &hours_reset, 0, "reset logon hours", NULL}, >+ {"password-from-stdin", 't', POPT_ARG_NONE, &pw_from_stdin, 0, "get password from standard in", NULL}, > POPT_COMMON_SAMBA > POPT_TABLEEND > }; >@@ -872,7 +913,8 @@ > } 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); > } > } > >Nur in samba-3.0.4.new/source/utils: .pdbedit.c.swp. >--- samba-3.0.4/docs/manpages/pdbedit.8 >+++ samba-3.0.4/docs/manpages/pdbedit.8 2004-05-26 20:08:56 >@@ -24,7 +24,7 @@ > .ad l > .hy 0 > .HP 8 >-\fBpdbedit\fR [\-L] [\-v] [\-w] [\-u\ username] [\-f\ fullname] [\-h\ homedir] [\-D\ drive] [\-S\ script] [\-p\ profile] [\-a] [\-m] [\-r] [\-x] [\-i\ passdb\-backend] [\-e\ passdb\-backend] [\-b\ passdb\-backend] [\-g] [\-d\ debuglevel] [\-s\ configfile] [\-P\ account\-policy] [\-C\ value] [\-c\ account\-control] >+\fBpdbedit\fR [\-L] [\-v] [\-w] [\-u\ username] [\-f\ fullname] [\-h\ homedir] [\-D\ drive] [\-S\ script] [\-p\ profile] [\-a] [\-m] [\-r] [\-x] [\-i\ passdb\-backend] [\-t] [\-e\ passdb\-backend] [\-b\ passdb\-backend] [\-g] [\-d\ debuglevel] [\-s\ configfile] [\-P\ account\-policy] [\-C\ value] [\-c\ account\-control] > .ad > .hy > >@@ -309,6 +309,13 @@ > \-l|\-\-logfile=logdirectory > Base directory name for log/debug files\&. The extension \fB"\&.progname"\fR will be appended (e\&.g\&. log\&.smbclient, log\&.smbd, etc\&.\&.\&.)\&. The log file is never removed by the client\&. > >+.TP >+\-t|\-\-password-from-stdin >+This option causes pdbedit to read the password >+from standard input, rather than from /dev/tty. >+ >+Example: echo -e "secret\\nsecret\\n" | pdbedit -a -t -u sorce >+ > .SH "NOTES" > > .PP
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1386
:
526
|
612
|
922