Cross Reference: passdb-passwd.c
xref
: /
dovecot
/
src
/
auth
/
passdb-passwd.c
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
passdb-passwd.c revision 0373a24e97602b4c394e93a70b75f45e5869fa51
742
N/A
/* Copyright (C) 2002-2003 Timo Sirainen */
742
N/A
742
N/A
#
include
"
config.h
"
742
N/A
#
undef
HAVE_CONFIG_H
742
N/A
742
N/A
#
ifdef
PASSDB_PASSWD
742
N/A
742
N/A
#
include
"
common.h
"
742
N/A
#
include
"
safe-memset.h
"
742
N/A
#
include
"
passdb.h
"
742
N/A
#
include
"
mycrypt.h
"
742
N/A
742
N/A
#
include
<
pwd.h
>
742
N/A
742
N/A
static
void
742
N/A
passwd_verify_plain
(
struct
auth_request
*
request
,
const
char
*
password
,
742
N/A
verify_plain_callback_t
*
callback
)
742
N/A
{
742
N/A
struct
passwd
*
pw
;
742
N/A
int
result
;
742
N/A
2603
N/A
pw
=
getpwnam
(
request
->
user
);
742
N/A
if
(
pw
==
NULL
) {
742
N/A
if
(
verbose
) {
742
N/A
i_info
(
"passwd(%s): unknown user"
,
1116
N/A
get_log_prefix
(
request
));
1116
N/A
}
1116
N/A
callback
(
PASSDB_RESULT_USER_UNKNOWN
,
request
);
742
N/A
return
;
742
N/A
}
742
N/A
1117
N/A
if
(!
IS_VALID_PASSWD
(
pw
->
pw_passwd
)) {
1117
N/A
if
(
verbose
) {
1117
N/A
i_info
(
"passwd(%s): invalid password field '%s'"
,
1117
N/A
get_log_prefix
(
request
),
pw
->
pw_passwd
);
758
N/A
}
758
N/A
callback
(
PASSDB_RESULT_USER_DISABLED
,
request
);
758
N/A
return
;
758
N/A
}
758
N/A
758
N/A
/* check if the password is valid */
758
N/A
result
=
strcmp
(
mycrypt
(
password
,
pw
->
pw_passwd
),
pw
->
pw_passwd
) == 0;
758
N/A
758
N/A
/* clear the passwords from memory */
758
N/A
safe_memset
(
pw
->
pw_passwd
, 0,
strlen
(
pw
->
pw_passwd
));
742
N/A
742
N/A
if
(!
result
) {
742
N/A
if
(
verbose
) {
742
N/A
i_info
(
"passwd(%s): password mismatch"
,
742
N/A
get_log_prefix
(
request
));
758
N/A
}
742
N/A
callback
(
PASSDB_RESULT_PASSWORD_MISMATCH
,
request
);
742
N/A
return
;
742
N/A
}
758
N/A
742
N/A
callback
(
PASSDB_RESULT_OK
,
request
);
742
N/A
}
758
N/A
742
N/A
static
void
passwd_deinit
(
void
)
742
N/A
{
742
N/A
endpwent
();
742
N/A
}
742
N/A
742
N/A
struct
passdb_module
passdb_passwd
= {
742
N/A
NULL
,
742
N/A
passwd_deinit
,
742
N/A
742
N/A
passwd_verify_plain
,
742
N/A
NULL
742
N/A
};
742
N/A
742
N/A
#
endif
742
N/A