summaryrefslogtreecommitdiffstats
path: root/kcheckpass
diff options
context:
space:
mode:
Diffstat (limited to 'kcheckpass')
-rw-r--r--kcheckpass/CMakeLists.txt2
-rw-r--r--kcheckpass/ConfigureChecks.cmake4
-rw-r--r--kcheckpass/checkpass_etcpasswd.c60
-rw-r--r--kcheckpass/checkpass_shadow.c20
-rw-r--r--kcheckpass/kcheckpass.h8
5 files changed, 17 insertions, 77 deletions
diff --git a/kcheckpass/CMakeLists.txt b/kcheckpass/CMakeLists.txt
index 5e83ee41e..b2091e0ce 100644
--- a/kcheckpass/CMakeLists.txt
+++ b/kcheckpass/CMakeLists.txt
@@ -24,7 +24,7 @@ include_directories(
tde_add_executable( kcheckpass AUTOMOC
SOURCES
- kcheckpass.c checkpass_etcpasswd.c checkpass_pam.c
+ kcheckpass.c checkpass_pam.c
checkpass_shadow.c checkpass_osfc2passwd.c checkpass_aix.c
LINK tdefakes-shared ${CRYPT_LIBRARY} ${PAM_LIBRARY}
DESTINATION ${BIN_INSTALL_DIR}
diff --git a/kcheckpass/ConfigureChecks.cmake b/kcheckpass/ConfigureChecks.cmake
index d6d62f55b..902e6628d 100644
--- a/kcheckpass/ConfigureChecks.cmake
+++ b/kcheckpass/ConfigureChecks.cmake
@@ -12,3 +12,7 @@
if( WITH_PAM AND (NOT DEFINED KCHECKPASS_PAM_SERVICE) )
set( KCHECKPASS_PAM_SERVICE "kde" CACHE INTERNAL "" )
endif( )
+
+if( NOT WITH_PAM AND WITH_SHADOW )
+ check_function_exists( pw_encrypt HAVE_PW_ENCRYPT )
+endif( )
diff --git a/kcheckpass/checkpass_etcpasswd.c b/kcheckpass/checkpass_etcpasswd.c
deleted file mode 100644
index 1dbe06f70..000000000
--- a/kcheckpass/checkpass_etcpasswd.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 1998 Christian Esken <esken@kde.org>
- * Copyright (c) 2003 Oswald Buddenhagen <ossi@kde.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Copyright (C) 1998, Christian Esken <esken@kde.org>
- */
-
-#include "kcheckpass.h"
-
-#ifdef HAVE_ETCPASSWD
-
-/*******************************************************************
- * This is the authentication code for /etc/passwd passwords
- *******************************************************************/
-
-#include <string.h>
-#include <stdlib.h>
-
-AuthReturn Authenticate(const char *method,
- const char *login, char *(*conv) (ConvRequest, const char *))
-{
- struct passwd *pw;
- char *passwd;
-
- if (strcmp(method, "classic"))
- return AuthError;
-
- /* Get the password entry for the user we want */
- if (!(pw = getpwnam(login)))
- return AuthBad;
-
- if (!*pw->pw_passwd)
- return AuthOk;
-
- if (!(passwd = conv(ConvGetHidden, 0)))
- return AuthAbort;
-
- if (!strcmp(pw->pw_passwd, crypt(passwd, pw->pw_passwd))) {
- dispose(passwd);
- return AuthOk; /* Success */
- }
- dispose(passwd);
- return AuthBad; /* Password wrong or account locked */
-}
-
-#endif
diff --git a/kcheckpass/checkpass_shadow.c b/kcheckpass/checkpass_shadow.c
index ec3a4e02a..e721582d5 100644
--- a/kcheckpass/checkpass_shadow.c
+++ b/kcheckpass/checkpass_shadow.c
@@ -27,13 +27,14 @@
#include "kcheckpass.h"
/*******************************************************************
- * This is the authentication code for Shadow-Passwords
+ * This is the authentication code for /etc/passwd and Shadow-Passwords
*******************************************************************/
-#ifdef HAVE_SHADOW
+#if defined(HAVE_SHADOW) || defined(HAVE_ETCPASSWD)
#include <string.h>
#include <stdlib.h>
#include <pwd.h>
+#include <crypt.h>
#ifndef __hpux
#include <shadow.h>
@@ -46,7 +47,6 @@ AuthReturn Authenticate(const char *method,
char *crpt_passwd;
char *password;
struct passwd *pw;
- struct spwd *spw;
if (strcmp(method, "classic"))
return AuthError;
@@ -54,8 +54,12 @@ AuthReturn Authenticate(const char *method,
if (!(pw = getpwnam(login)))
return AuthAbort;
- spw = getspnam(login);
+#ifdef HAVE_SHADOW
+ struct spwd *spw = getspnam(login);
password = spw ? spw->sp_pwdp : pw->pw_passwd;
+#else
+ password = pw->pw_passwd;
+#endif
if (!*password)
return AuthOk;
@@ -69,11 +73,11 @@ AuthReturn Authenticate(const char *method,
crpt_passwd = crypt(typed_in_password, password);
#endif
- if (!strcmp(password, crpt_passwd )) {
- dispose(typed_in_password);
- return AuthOk; /* Success */
- }
dispose(typed_in_password);
+
+ if (crpt_passwd && !strcmp(password, crpt_passwd))
+ return AuthOk; /* Success */
+
return AuthBad; /* Password wrong or account locked */
}
diff --git a/kcheckpass/kcheckpass.h b/kcheckpass/kcheckpass.h
index e1351375a..66a242856 100644
--- a/kcheckpass/kcheckpass.h
+++ b/kcheckpass/kcheckpass.h
@@ -43,17 +43,9 @@
#include <crypt.h>
#endif
-#ifdef HAVE_PATHS_H
-#include <paths.h>
-#endif
-
#include <pwd.h>
#include <sys/types.h>
-#ifndef _PATH_TMP
-#define _PATH_TMP "/tmp/"
-#endif
-
#ifdef ultrix
#include <auth.h>