mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
add "-n" to omit trailing newline
This commit is contained in:
parent
a0ee28698c
commit
914bf9926f
@ -11,6 +11,7 @@ slappasswd \- OpenLDAP password utility
|
||||
.B [\-g|\-s secret|\-T file]
|
||||
.B [\-h hash]
|
||||
.B [\-c salt-format]
|
||||
.B [\-n]
|
||||
.B
|
||||
.LP
|
||||
.SH DESCRIPTION
|
||||
@ -131,6 +132,10 @@ provides a two character salt and '$1$%.8s' tells some
|
||||
versions of crypt(3) to use an MD5 algorithm and provides
|
||||
8 random characters of salt. The default is '%s', which
|
||||
provides 31 characters of salt.
|
||||
.TP
|
||||
.BI \-n
|
||||
Omit the trailing newline; useful to pipe the credentials
|
||||
into a command.
|
||||
.SH LIMITATIONS
|
||||
The practice storing hashed passwords in userPassword violates
|
||||
Standard Track (RFC 2256) schema specifications and may hinder
|
||||
|
@ -48,6 +48,7 @@ usage(const char *s)
|
||||
" -c format\tcrypt(3) salt format\n"
|
||||
" -g\t\tgenerate random password\n"
|
||||
" -h hash\tpassword scheme\n"
|
||||
" -n\t\tomit trailing newline\n"
|
||||
" -s secret\tnew password\n"
|
||||
" -u\t\tgenerate RFC2307 values (default)\n"
|
||||
" -v\t\tincrease verbosity\n"
|
||||
@ -73,11 +74,12 @@ slappasswd( int argc, char *argv[] )
|
||||
const char *progname = "slappasswd";
|
||||
|
||||
int i;
|
||||
char *newline = "\n";
|
||||
struct berval passwd = BER_BVNULL;
|
||||
struct berval hash;
|
||||
|
||||
while( (i = getopt( argc, argv,
|
||||
"c:d:gh:s:T:vu" )) != EOF )
|
||||
"c:d:gh:ns:T:vu" )) != EOF )
|
||||
{
|
||||
switch (i) {
|
||||
case 'c': /* crypt salt format */
|
||||
@ -110,6 +112,10 @@ slappasswd( int argc, char *argv[] )
|
||||
}
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
newline = "";
|
||||
break;
|
||||
|
||||
case 's': /* new password (secret) */
|
||||
if ( pwfile != NULL ) {
|
||||
fprintf( stderr, "Option -s incompatible with -T\n" );
|
||||
@ -178,9 +184,8 @@ slappasswd( int argc, char *argv[] )
|
||||
passwd.bv_val = newpw;
|
||||
passwd.bv_len = strlen(passwd.bv_val);
|
||||
} else {
|
||||
/* Omit trailing newline so it may be directed to a pwfile */
|
||||
printf( "%s", passwd.bv_val );
|
||||
return EXIT_SUCCESS;
|
||||
hash = passwd;
|
||||
goto print_pw;
|
||||
}
|
||||
|
||||
lutil_passwd_hash( &passwd, scheme, &hash, &text );
|
||||
@ -197,6 +202,7 @@ slappasswd( int argc, char *argv[] )
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
printf( "%s\n" , hash.bv_val );
|
||||
print_pw:;
|
||||
printf( "%s%s" , hash.bv_val, newline );
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user