include-afsconfig-before-param-h-20010712
[openafs.git] / src / sgistuff / sgi_auth.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #include <afsconfig.h>
11 #include <afs/param.h>
12
13 RCSID("$Header$");
14
15 #if defined(AFS_SGI_ENV)
16
17 #include <limits.h>
18 #include <unistd.h>
19 #include <errno.h>
20 #include <sys/types.h>
21 #include <sys/param.h>
22 #include <afs/kauth.h>
23 #include <afs/kautils.h>
24
25 extern char *ktc_tkt_string();
26
27 /*
28  * authenticate with AFS
29  * returns:
30  *      1 if read password but couldn't authenticate correctly via AFS
31  *      0 if authenticated via AFS correctly
32  */
33 int
34 afs_verify(
35         char *uname,    /* user name trying to log in */
36         char *pword,    /* password */
37         afs_int32 *exp, /* expiration time */
38         int quite)      /* no printing */
39 {
40         auto char *reason;
41
42         ka_Init(0);
43         /*
44          * The basic model for logging in now, is that *if* there
45          * is a kerberos record for this individual user we will
46          * trust kerberos (provided the user really has an account
47          * locally.)  If there is no kerberos record (or the password
48          * were typed incorrectly.) we would attempt to authenticate
49          * against the local password file entry.  Naturally, if
50          * both fail we use existing failure code.
51          */
52         if (ka_UserAuthenticateGeneral(
53                         KA_USERAUTH_VERSION + KA_USERAUTH_DOSETPAG,
54                         uname, /* kerberos name */
55                         (char *)0, /* instance */
56                         (char *)0, /* realm */
57                         pword, /* password */
58                         0, /* default lifetime */
59                         exp, /* spare 1/expiration */
60                         0, /* spare 2 */
61                         &reason /* error string */
62                         )) {
63                 if (!quite) {
64                         printf("Unable to authenticate to AFS because %s\n",
65                                reason);
66                         printf("proceeding with local authentication...\n");
67                 }
68                 return 1;
69         }
70         /* authenticated successfully */
71         return 0;
72 }
73
74 char *
75 afs_gettktstring(void)
76 {
77         return ktc_tkt_string();
78 }
79
80 #endif