Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
LSH
lsh
Commits
9ea79128
Commit
9ea79128
authored
Nov 15, 1998
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved functions format_cstring and make_cstring to format.c.
Rev: src/server_password.c:1.6
parent
21d91f19
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
39 deletions
+10
-39
src/server_password.c
src/server_password.c
+10
-39
No files found.
src/server_password.c
View file @
9ea79128
...
...
@@ -36,40 +36,6 @@
#include <pwd.h>
#include <grp.h>
/* These functions add an extra NUL-character at the end of the string
* (not included in the length), to make it possible to pass the
* string directly to C library functions. */
static
struct
lsh_string
*
format_cstring
(
char
*
s
)
{
if
(
s
)
{
struct
lsh_string
*
res
=
ssh_format
(
"%lz%c"
,
s
,
0
);
res
->
length
--
;
return
res
;
}
return
NULL
;
}
static
struct
lsh_string
*
make_cstring
(
struct
lsh_string
*
s
,
int
free
)
{
struct
lsh_string
*
res
;
if
(
memchr
(
s
->
data
,
'\0'
,
s
->
length
))
{
if
(
free
)
lsh_string_free
(
s
);
return
0
;
}
res
=
ssh_format
(
"%lS%c"
,
s
,
0
);
res
->
length
--
;
if
(
free
)
lsh_string_free
(
s
);
return
res
;
}
/* NOTE: Calls functions using the *disgusting* convention of returning
* pointers to static buffers. */
...
...
@@ -84,8 +50,10 @@ struct unix_user *lookup_user(struct lsh_string *name, int free)
return
0
;
if
(
!
(
passwd
=
getpwnam
(
name
->
data
)))
return
0
;
{
lsh_string_free
(
name
);
return
0
;
}
NEW
(
res
);
res
->
uid
=
passwd
->
pw_uid
;
res
->
gid
=
passwd
->
pw_gid
;
...
...
@@ -104,9 +72,6 @@ int verify_password(struct unix_user *user,
{
char
*
salt
;
/* Convert password to a NULL-terminated string */
password
=
make_cstring
(
password
,
free
);
if
(
!
user
->
passwd
||
(
user
->
passwd
->
length
<
2
)
)
{
/* FIXME: How are accounts without passwords handled? */
...
...
@@ -114,6 +79,12 @@ int verify_password(struct unix_user *user,
return
0
;
}
/* Convert password to a NULL-terminated string */
password
=
make_cstring
(
password
,
free
);
if
(
!
password
)
return
0
;
salt
=
user
->
passwd
->
data
;
if
(
strcmp
(
crypt
(
password
->
data
,
salt
),
user
->
passwd
->
data
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment