GSS_S_PROMPTING_NEEDED is a bit
[cyrus-sasl.git] / pwcheck / pwcheck_getpwnam.c
1 /* pwcheck_getpwnam.c -- check passwords using getpwname()
2    $Id: pwcheck_getpwnam.c,v 1.1 1999/08/26 16:22:43 leg Exp $
3
4 Copyright 1998, 1999 Carnegie Mellon University
5
6                       All Rights Reserved
7
8 Permission to use, copy, modify, and distribute this software and its
9 documentation for any purpose and without fee is hereby granted,
10 provided that the above copyright notice appear in all copies and that
11 both that copyright notice and this permission notice appear in
12 supporting documentation, and that the name of Carnegie Mellon
13 University not be used in advertising or publicity pertaining to
14 distribution of the software without specific, written prior
15 permission.
16
17 CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
18 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE FOR
20 ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
21 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
22 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
23 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 ******************************************************************/
25
26 #include <pwd.h>
27
28 extern char *crypt();
29
30 char *pwcheck(userid, password)
31 char *userid;
32 char *password;
33 {
34     char* r;
35     struct passwd *pwd;
36
37     pwd = getpwnam(userid);
38     if (!pwd) {
39         r = "Userid not found";
40     }
41     else if (pwd->pw_passwd[0] == '*') {
42         r = "Account disabled";
43     }
44     else if (strcmp(pwd->pw_passwd, crypt(password, pwd->pw_passwd)) != 0) {
45         r = "Incorrect password";
46     }
47     else {
48         r = "OK";
49     }
50
51     endpwent();
52     
53     return r;
54 }