.B [\-g|\-s secret|\-T file]
.B [\-h hash]
.B [\-c salt-format]
+.B [\-n]
.B
.LP
.SH DESCRIPTION
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
" -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"
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 */
}
break;
+ case 'n':
+ newline = "";
+ break;
+
case 's': /* new password (secret) */
if ( pwfile != NULL ) {
fprintf( stderr, "Option -s incompatible with -T\n" );
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 );
return EXIT_FAILURE;
}
- printf( "%s\n" , hash.bv_val );
+print_pw:;
+ printf( "%s%s" , hash.bv_val, newline );
return EXIT_SUCCESS;
}