utils/passwd_util.c

説明を見る。
00001 /* 
00002    Unix SMB/CIFS implementation.
00003    passdb editing frontend
00004 
00005    Copyright (C) Jeremy Allison  1998
00006    Copyright (C) Andrew Tridgell 1998
00007    Copyright (C) Tim Potter      2000
00008    Copyright (C) Simo Sorce      2000
00009    Copyright (C) Martin Pool     2001
00010    Copyright (C) Gerald Carter   2002
00011    Copyright (C) Andrew Bartlett 2003
00012 
00013    This program is free software; you can redistribute it and/or modify
00014    it under the terms of the GNU General Public License as published by
00015    the Free Software Foundation; either version 2 of the License, or
00016    (at your option) any later version.
00017    
00018    This program is distributed in the hope that it will be useful,
00019    but WITHOUT ANY WARRANTY; without even the implied warranty of
00020    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021    GNU General Public License for more details.
00022    
00023    You should have received a copy of the GNU General Public License
00024    along with this program; if not, write to the Free Software
00025    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00026 */
00027 
00028 #include "includes.h"
00029 
00030 /*************************************************************
00031  Utility function to prompt for passwords from stdin. Each
00032  password entered must end with a newline.
00033 *************************************************************/
00034 char *stdin_new_passwd( void)
00035 {
00036         static fstring new_pw;
00037         size_t len;
00038 
00039         ZERO_ARRAY(new_pw);
00040 
00041         /*
00042          * if no error is reported from fgets() and string at least contains
00043          * the newline that ends the password, then replace the newline with
00044          * a null terminator.
00045          */
00046         if ( fgets(new_pw, sizeof(new_pw), stdin) != NULL) {
00047                 if ((len = strlen(new_pw)) > 0) {
00048                         if(new_pw[len-1] == '\n')
00049                                 new_pw[len - 1] = 0;
00050                 }
00051         }
00052         return(new_pw);
00053 }
00054 
00055 /*************************************************************
00056  Utility function to get passwords via tty or stdin
00057  Used if the '-s' (smbpasswd) or '-t' (pdbedit) option is set
00058  to silently get passwords to enable scripting.
00059 *************************************************************/
00060 char *get_pass( const char *prompt, BOOL stdin_get)
00061 {
00062         char *p;
00063         if (stdin_get) {
00064                 p = stdin_new_passwd();
00065         } else {
00066                 p = getpass( prompt);
00067         }
00068         return smb_xstrdup( p);
00069 }

Sambaに対してSat Aug 29 21:23:30 2009に生成されました。  doxygen 1.4.7