Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / platform / IRIX / 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
14 #if defined(AFS_SGI_ENV)
15
16 #include <limits.h>
17 #include <unistd.h>
18 #include <errno.h>
19 #include <sys/types.h>
20 #include <sys/param.h>
21 #include <afs/kauth.h>
22 #include <afs/kautils.h>
23
24 extern char *ktc_tkt_string();
25
26 /*
27 * authenticate with AFS
28 * returns:
29 * 1 if read password but couldn't authenticate correctly via AFS
30 * 0 if authenticated via AFS correctly
31 */
32 int
33 afs_verify(char *uname, /* user name trying to log in */
34 char *pword, /* password */
35 afs_int32 * exp, /* expiration time */
36 int quite)
37 { /* no printing */
38 auto char *reason;
39
40 ka_Init(0);
41 /*
42 * The basic model for logging in now, is that *if* there
43 * is a kerberos record for this individual user we will
44 * trust kerberos (provided the user really has an account
45 * locally.) If there is no kerberos record (or the password
46 * were typed incorrectly.) we would attempt to authenticate
47 * against the local password file entry. Naturally, if
48 * both fail we use existing failure code.
49 */
50 if (ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION + KA_USERAUTH_DOSETPAG, uname, /* kerberos name */
51 NULL, /* instance */
52 NULL, /* realm */
53 pword, /* password */
54 0, /* default lifetime */
55 exp, /* spare 1/expiration */
56 0, /* spare 2 */
57 &reason /* error string */
58 )) {
59 if (!quite) {
60 printf("Unable to authenticate to AFS because %s\n", reason);
61 printf("proceeding with local authentication...\n");
62 }
63 return 1;
64 }
65 /* authenticated successfully */
66 return 0;
67 }
68
69 char *
70 afs_gettktstring(void)
71 {
72 return ktc_tkt_string();
73 }
74
75 #endif