Imported Upstream version 1.6.6
[debian/sudo] / auth / secureware.c
1 /*
2  * Copyright (c) 1998, 1999, 2001 Todd C. Miller <Todd.Miller@courtesan.com>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * 3. The name of the author may not be used to endorse or promote products
17  *    derived from this software without specific prior written permission.
18  *
19  * 4. Products derived from this software may not be called "Sudo" nor
20  *    may "Sudo" appear in their names without specific prior written
21  *    permission from the author.
22  *
23  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
26  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34
35 #include "config.h"
36
37 #include <sys/types.h>
38 #include <sys/param.h>
39 #include <stdio.h>
40 #ifdef STDC_HEADERS
41 # include <stdlib.h>
42 # include <stddef.h>
43 #else
44 # ifdef HAVE_STDLIB_H
45 #  include <stdlib.h>
46 # endif
47 #endif /* STDC_HEADERS */
48 #ifdef HAVE_STRING_H
49 # include <string.h>
50 #else
51 # ifdef HAVE_STRINGS_H
52 #  include <strings.h>
53 # endif
54 #endif /* HAVE_STRING_H */
55 #ifdef HAVE_UNISTD_H
56 # include <unistd.h>
57 #endif /* HAVE_UNISTD_H */
58 #include <pwd.h>
59 #ifdef __hpux
60 #  undef MAXINT
61 #  include <hpsecurity.h>
62 #else
63 #  include <sys/security.h>
64 #endif /* __hpux */
65 #include <prot.h>
66
67 #include "sudo.h"
68 #include "sudo_auth.h"
69
70 #ifndef lint
71 static const char rcsid[] = "$Sudo: secureware.c,v 1.8 2001/12/14 19:52:53 millert Exp $";
72 #endif /* lint */
73
74 int
75 secureware_init(pw, promptp, auth)
76     struct passwd *pw;
77     char **promptp;
78     sudo_auth *auth;
79 {
80 #ifdef __alpha
81     extern int crypt_type;
82
83     if (crypt_type == INT_MAX)
84         return(AUTH_FAILURE);                   /* no shadow */
85 #endif
86     return(AUTH_SUCCESS);
87 }
88
89 int
90 secureware_verify(pw, pass, auth)
91     struct passwd *pw;
92     char *pass;
93     sudo_auth *auth;
94 {
95 #ifdef __alpha
96     extern int crypt_type;
97
98 #  ifdef HAVE_DISPCRYPT
99     if (strcmp(user_passwd, dispcrypt(pass, user_passwd, crypt_type)) == 0)
100         return(AUTH_SUCCESS);
101 #  else
102     if (crypt_type == AUTH_CRYPT_BIGCRYPT) {
103         if (strcmp(user_passwd, bigcrypt(pass, user_passwd)) == 0)
104             return(AUTH_SUCCESS);
105     } else if (crypt_type == AUTH_CRYPT_CRYPT16) {
106         if (strcmp(user_passwd, crypt(pass, user_passwd)) == 0)
107             return(AUTH_SUCCESS);
108     }
109 #  endif /* HAVE_DISPCRYPT */
110 #elif defined(HAVE_BIGCRYPT)
111     if (strcmp(user_passwd, bigcrypt(pass, user_passwd)) == 0)
112         return(AUTH_SUCCESS);
113 #endif /* __alpha */
114
115         return(AUTH_FAILURE);
116 }