Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Barchiesi
OpenLDAP
Commits
ad7d6444
Commit
ad7d6444
authored
18 years ago
by
Howard Chu
Browse files
Options
Downloads
Patches
Plain Diff
Omit trailing newline from generated password, so it may be directed
to a file and used by commandline tools
parent
b8b8ca18
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
servers/slapd/slappasswd.c
+11
-23
11 additions, 23 deletions
servers/slapd/slappasswd.c
with
11 additions
and
23 deletions
servers/slapd/slappasswd.c
+
11
−
23
View file @
ad7d6444
...
...
@@ -46,7 +46,7 @@ usage(const char *s)
fprintf
(
stderr
,
"Usage: %s [options]
\n
"
" -c format
\t
crypt(3) salt format
\n
"
" -g
\n
"
" -g
\
t\t
generate random password
\
n
"
" -h hash
\t
password scheme
\n
"
" -s secret
\t
new password
\n
"
" -u
\t\t
generate RFC2307 values (default)
\n
"
...
...
@@ -60,7 +60,6 @@ usage(const char *s)
int
slappasswd
(
int
argc
,
char
*
argv
[]
)
{
char
*
cleartext_scheme
=
"{CLEARTEXT}"
;
#ifdef LUTIL_SHA1_BYTES
char
*
default_scheme
=
"{SSHA}"
;
#else
...
...
@@ -74,7 +73,7 @@ slappasswd( int argc, char *argv[] )
const
char
*
progname
=
"slappasswd"
;
int
i
;
struct
berval
passwd
;
struct
berval
passwd
=
BER_BVNULL
;
struct
berval
hash
;
while
(
(
i
=
getopt
(
argc
,
argv
,
...
...
@@ -88,36 +87,21 @@ slappasswd( int argc, char *argv[] )
case
'g'
:
/* new password (generate) */
if
(
pwfile
!=
NULL
)
{
fprintf
(
stderr
,
"Option -
s
incompatible with -T
\n
"
);
fprintf
(
stderr
,
"Option -
g
incompatible with -T
\n
"
);
return
EXIT_FAILURE
;
}
else
if
(
newpw
!=
NULL
)
{
fprintf
(
stderr
,
"New password already provided
\n
"
);
return
EXIT_FAILURE
;
}
else
if
(
scheme
!=
default_scheme
&&
strcmp
(
scheme
,
cleartext_scheme
)
!=
0
)
{
fprintf
(
stderr
,
"
Option -g incompatible with scheme
\"
%s
\"\n
"
,
scheme
);
}
else
if
(
lutil_passwd_generate
(
&
passwd
,
8
)
)
{
fprintf
(
stderr
,
"
Password generation failed
\n
"
);
return
EXIT_FAILURE
;
}
else
{
struct
berval
p
=
BER_BVNULL
;
lutil_passwd_generate
(
&
p
,
8
);
newpw
=
p
.
bv_val
;
scheme
=
cleartext_scheme
;
}
break
;
case
'h'
:
/* scheme */
if
(
scheme
==
cleartext_scheme
)
{
if
(
strcmp
(
optarg
,
cleartext_scheme
)
!=
0
)
{
fprintf
(
stderr
,
"Option -h incompatible with -g
\n
"
);
return
EXIT_FAILURE
;
}
}
else
if
(
scheme
!=
default_scheme
)
{
if
(
scheme
!=
default_scheme
)
{
fprintf
(
stderr
,
"Scheme already provided
\n
"
);
return
EXIT_FAILURE
;
...
...
@@ -178,7 +162,7 @@ slappasswd( int argc, char *argv[] )
if
(
lutil_get_filed_password
(
pwfile
,
&
passwd
))
{
return
EXIT_FAILURE
;
}
}
else
{
}
else
if
(
BER_BVISEMPTY
(
&
passwd
))
{
if
(
newpw
==
NULL
)
{
/* prompt for new password */
char
*
cknewpw
;
...
...
@@ -193,6 +177,10 @@ 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
;
}
lutil_passwd_hash
(
&
passwd
,
scheme
,
&
hash
,
&
text
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment