Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review 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
Christopher Ng
OpenLDAP
Commits
b973e61d
Commit
b973e61d
authored
25 years ago
by
Kurt Zeilenga
Browse files
Options
Downloads
Patches
Plain Diff
Fix {CRYPT} and {UNIX} passwords
parent
5e12c84a
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
libraries/liblutil/passwd.c
+53
-8
53 additions, 8 deletions
libraries/liblutil/passwd.c
with
53 additions
and
8 deletions
libraries/liblutil/passwd.c
+
53
−
8
View file @
b973e61d
...
...
@@ -493,7 +493,29 @@ static int chk_crypt(
const
struct
berval
*
passwd
,
const
struct
berval
*
cred
)
{
return
strcmp
(
passwd
,
crypt
(
cred
,
passwd
));
int
i
;
for
(
i
=
0
;
i
<
cred
->
bv_len
;
i
++
)
{
if
(
cred
->
bv_val
[
i
]
==
'\0'
)
{
return
1
;
/* NUL character in password */
}
}
if
(
cred
->
bv_val
[
i
]
!=
'\0'
)
{
return
1
;
/* cred must behave like a string */
}
for
(
i
=
0
;
i
<
passwd
->
bv_len
;
i
++
)
{
if
(
passwd
->
bv_val
[
i
]
==
'\0'
)
{
return
1
;
/* NUL character in password */
}
}
if
(
passwd
->
bv_val
[
i
]
!=
'\0'
)
{
return
1
;
/* passwd must behave like a string */
}
return
strcmp
(
passwd
->
bv_val
,
crypt
(
cred
->
bv_val
,
passwd
->
bv_val
));
}
# if defined( HAVE_GETSPNAM ) \
...
...
@@ -515,9 +537,19 @@ static int chk_unix(
return
1
;
/* cred must behave like a string */
}
for
(
i
=
0
;
i
<
passwd
->
bv_len
;
i
++
)
{
if
(
passwd
->
bv_val
[
i
]
==
'\0'
)
{
return
1
;
/* NUL character in password */
}
}
if
(
passwd
->
bv_val
[
i
]
!=
'\0'
)
{
return
1
;
/* passwd must behave like a string */
}
# ifdef HAVE_GETSPNAM
{
struct
spwd
*
spwd
=
getspnam
(
p
);
struct
spwd
*
spwd
=
getspnam
(
p
asswd
->
bv_val
);
if
(
spwd
==
NULL
)
{
return
1
;
/* not found */
...
...
@@ -528,7 +560,7 @@ static int chk_unix(
# else
{
struct
passwd
*
pwd
=
getpwnam
(
p
);
struct
passwd
*
pwd
=
getpwnam
(
p
asswd
->
bv_val
);
if
(
pwd
==
NULL
)
{
return
1
;
/* not found */
...
...
@@ -652,8 +684,19 @@ static struct berval *gen_crypt(
static
const
unsigned
char
crypt64
[]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890./"
;
char
*
hash
=
NULL
;
unsigned
char
salt
[
2
];
struct
berval
hash
;
unsigned
char
salt
[
3
];
int
i
;
for
(
i
=
0
;
i
<
passwd
->
bv_len
;
i
++
)
{
if
(
passwd
->
bv_val
[
i
]
==
'\0'
)
{
return
NULL
;
/* NUL character in password */
}
}
if
(
passwd
->
bv_val
[
i
]
!=
'\0'
)
{
return
NULL
;
/* passwd must behave like a string */
}
if
(
lutil_entropy
(
salt
,
sizeof
(
salt
))
<
0
)
{
return
NULL
;
...
...
@@ -661,11 +704,13 @@ static struct berval *gen_crypt(
salt
[
0
]
=
crypt64
[
salt
[
0
]
%
(
sizeof
(
crypt64
)
-
1
)
];
salt
[
1
]
=
crypt64
[
salt
[
1
]
%
(
sizeof
(
crypt64
)
-
1
)
];
salt
[
2
]
=
'\0'
;
hash
=
crypt
(
passwd
,
salt
);
hash
.
bv_val
=
crypt
(
passwd
->
bv_val
,
salt
);
if
(
hash
=
NULL
)
return
NULL
;
if
(
hash
.
bv_val
=
NULL
)
return
NULL
;
hash
.
bv_len
=
strlen
(
hash
.
bv_val
);
return
pw_string
(
scheme
,
hash
);
return
pw_string
(
scheme
,
&
hash
);
}
#endif
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