Skip to content

Commit 874c2b2

Browse files
committed
Use a simple string compare on systems without crypt(3).
This is only used on systems without PAM, BSD authentication or AIX authentication. Bug #940.
1 parent 44a1058 commit 874c2b2

4 files changed

Lines changed: 39 additions & 15 deletions

File tree

config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@
100100
/* Define to 1 if you have the `closefrom' function. */
101101
#undef HAVE_CLOSEFROM
102102

103+
/* Define to 1 if you have the `crypt' function. */
104+
#undef HAVE_CRYPT
105+
103106
/* Define to 1 if you use OSF DCE. */
104107
#undef HAVE_DCE
105108

configure

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15941,8 +15941,7 @@ else
1594115941

1594215942
fi
1594315943

15944-
LIB_CRYPT=1
15945-
SUDOERS_LIBS="${SUDOERS_LIBS} -lcrypt"
15944+
ac_cv_search_crypt="-lcrypt"
1594615945

1594715946
shadow_funcs="getspnam"
1594815947
shadow_libs="-lsec"
@@ -25476,9 +25475,8 @@ fi
2547625475
fi
2547725476

2547825477
if test ${with_passwd-'no'} != "no"; then
25479-
if test -z "$LIB_CRYPT"; then
25480-
_LIBS="$LIBS"
25481-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing crypt" >&5
25478+
_LIBS="$LIBS"
25479+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing crypt" >&5
2548225480
$as_echo_n "checking for library containing crypt... " >&6; }
2548325481
if ${ac_cv_search_crypt+:} false; then :
2548425482
$as_echo_n "(cached) " >&6
@@ -25532,11 +25530,16 @@ ac_res=$ac_cv_search_crypt
2553225530
if test "$ac_res" != no; then :
2553325531
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
2553425532

25535-
test "${ac_cv_search_crypt}" != "none required" && shadow_libs="${shadow_libs} ${ac_cv_search_crypt}"
25533+
test "${ac_cv_search_crypt}" != "none required" && shadow_libs="${shadow_libs} ${ac_cv_search_crypt}"
25534+
$as_echo "#define HAVE_CRYPT 1" >>confdefs.h
25535+
2553625536

2553725537
fi
2553825538

25539-
LIBS="$_LIBS"
25539+
LIBS="$_LIBS"
25540+
if test test "${ac_cv_search_crypt}" = "no"; then
25541+
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: No crypt function found, assuming plaintext passwords" >&5
25542+
$as_echo "$as_me: WARNING: No crypt function found, assuming plaintext passwords" >&2;}
2554025543
fi
2554125544

2554225545
if test "$CHECKSHADOW" = "true" -a -n "$shadow_funcs"; then
@@ -30413,5 +30416,6 @@ fi
3041330416

3041430417

3041530418

30419+
3041630420

3041730421

configure.ac

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,8 +2134,7 @@ case "$host" in
21342134
;;
21352135
*-*-isc*)
21362136
AX_APPEND_FLAG([-D_ISC], [CPPFLAGS])
2137-
LIB_CRYPT=1
2138-
SUDOERS_LIBS="${SUDOERS_LIBS} -lcrypt"
2137+
ac_cv_search_crypt="-lcrypt"
21392138

21402139
shadow_funcs="getspnam"
21412140
shadow_libs="-lsec"
@@ -4009,12 +4008,14 @@ if test ${with_passwd-'no'} != "no"; then
40094008
dnl
40104009
dnl if crypt(3) not in libc, look elsewhere
40114010
dnl
4012-
if test -z "$LIB_CRYPT"; then
4013-
_LIBS="$LIBS"
4014-
AC_SEARCH_LIBS([crypt], [crypt crypt_d ufc], [
4015-
test "${ac_cv_search_crypt}" != "none required" && shadow_libs="${shadow_libs} ${ac_cv_search_crypt}"
4016-
])
4017-
LIBS="$_LIBS"
4011+
_LIBS="$LIBS"
4012+
AC_SEARCH_LIBS([crypt], [crypt crypt_d ufc], [
4013+
test "${ac_cv_search_crypt}" != "none required" && shadow_libs="${shadow_libs} ${ac_cv_search_crypt}"
4014+
AC_DEFINE(HAVE_CRYPT)
4015+
])
4016+
LIBS="$_LIBS"
4017+
if test test "${ac_cv_search_crypt}" = "no"; then
4018+
AC_MSG_WARN([No crypt function found, assuming plaintext passwords])
40184019
fi
40194020

40204021
if test "$CHECKSHADOW" = "true" -a -n "$shadow_funcs"; then
@@ -4858,6 +4859,7 @@ AH_TEMPLATE(HAVE_AFS, [Define to 1 if you use AFS.])
48584859
AH_TEMPLATE(HAVE_AIXAUTH, [Define to 1 if you use AIX general authentication.])
48594860
AH_TEMPLATE(HAVE_BSD_AUTH_H, [Define to 1 if you use BSD authentication.])
48604861
AH_TEMPLATE(HAVE_BSM_AUDIT, [Define to 1 to enable BSM audit support.])
4862+
AH_TEMPLATE(HAVE_CRYPT, [Define to 1 if you have the `crypt' function.])
48614863
AH_TEMPLATE(HAVE_DCE, [Define to 1 if you use OSF DCE.])
48624864
AH_TEMPLATE(HAVE_DD_FD, [Define to 1 if your `DIR' contains dd_fd.])
48634865
AH_TEMPLATE(HAVE_DIRFD, [Define to 1 if you have the `dirfd' function or macro.])

plugins/sudoers/auth/passwd.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ sudo_passwd_init(struct passwd *pw, sudo_auth *auth)
5555
debug_return_int(auth->data ? AUTH_SUCCESS : AUTH_FATAL);
5656
}
5757

58+
#ifdef HAVE_CRYPT
5859
int
5960
sudo_passwd_verify(struct passwd *pw, char *pass, sudo_auth *auth, struct sudo_conv_callback *callback)
6061
{
@@ -93,6 +94,20 @@ sudo_passwd_verify(struct passwd *pw, char *pass, sudo_auth *auth, struct sudo_c
9394

9495
debug_return_int(matched ? AUTH_SUCCESS : AUTH_FAILURE);
9596
}
97+
#else
98+
int
99+
sudo_passwd_verify(struct passwd *pw, char *pass, sudo_auth *auth, struct sudo_conv_callback *callback)
100+
{
101+
char *pw_passwd = auth->data;
102+
int matched;
103+
debug_decl(sudo_passwd_verify, SUDOERS_DEBUG_AUTH);
104+
105+
/* Dummy version for systems without crypt(). */
106+
matched = !strcmp(pass, pw_passwd);
107+
108+
debug_return_int(matched ? AUTH_SUCCESS : AUTH_FAILURE);
109+
}
110+
#endif
96111

97112
int
98113
sudo_passwd_cleanup(struct passwd *pw, sudo_auth *auth, bool force)

0 commit comments

Comments
 (0)