not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / kcheckpass / checkpass_etcpasswd.c
blob1dbe06f709d14bcfbac11ae5c7cd420bdca59305
1 /*
2 * Copyright (c) 1998 Christian Esken <esken@kde.org>
3 * Copyright (c) 2003 Oswald Buddenhagen <ossi@kde.org>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the Free
17 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * Copyright (C) 1998, Christian Esken <esken@kde.org>
22 #include "kcheckpass.h"
24 #ifdef HAVE_ETCPASSWD
26 /*******************************************************************
27 * This is the authentication code for /etc/passwd passwords
28 *******************************************************************/
30 #include <string.h>
31 #include <stdlib.h>
33 AuthReturn Authenticate(const char *method,
34 const char *login, char *(*conv) (ConvRequest, const char *))
36 struct passwd *pw;
37 char *passwd;
39 if (strcmp(method, "classic"))
40 return AuthError;
42 /* Get the password entry for the user we want */
43 if (!(pw = getpwnam(login)))
44 return AuthBad;
46 if (!*pw->pw_passwd)
47 return AuthOk;
49 if (!(passwd = conv(ConvGetHidden, 0)))
50 return AuthAbort;
52 if (!strcmp(pw->pw_passwd, crypt(passwd, pw->pw_passwd))) {
53 dispose(passwd);
54 return AuthOk; /* Success */
56 dispose(passwd);
57 return AuthBad; /* Password wrong or account locked */
60 #endif