~ubuntu-branches/ubuntu/gutsy/cyrus-sasl2/gutsy-201105300151

« back to all changes in this revision

Viewing changes to pwcheck/pwcheck_getpwnam.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2006-11-27 12:59:40 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20061127125940-na3q3g3tkydvyvgl
Tags: 2.1.22.dfsg1-4ubuntu1
* Merge from debian unstable, remaining changes:
  - remove stop links from rc0 and rc6
  - build against db4.3 instead of 4.2
  - build against heimdal-dev instead of libkrb5-dev
  - depend on, don't recommend, modules

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}