]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * $Source$ | |
3 | * $Author$ | |
4 | * $Header$ | |
5 | * | |
6 | * Copyright (C) 1987 by the Massachusetts Institute of Technology | |
7 | * | |
8 | * $Log$ | |
9 | * Revision 1.6 1987-08-04 02:40:47 wesommer | |
10 | * Clean up messages. | |
11 | * | |
12 | * Revision 1.5 87/07/14 00:40:18 wesommer | |
13 | * Rearranged logging. | |
14 | * | |
15 | * Revision 1.4 87/06/30 20:03:46 wesommer | |
16 | * Put parsed kerberos principal name into the per-client structure. | |
17 | * | |
18 | * Revision 1.3 87/06/21 16:40:10 wesommer | |
19 | * Performance work, rearrangement of include files. | |
20 | * | |
21 | * Revision 1.2 87/06/04 01:34:35 wesommer | |
22 | * Added logging of arguments for some perverse reason. | |
23 | * | |
24 | * Revision 1.1 87/06/02 20:06:57 wesommer | |
25 | * Initial revision | |
26 | * | |
27 | */ | |
28 | ||
29 | #ifndef lint | |
30 | static char *rcsid_sms_sauth_c = "$Header$"; | |
31 | #endif lint | |
32 | ||
33 | extern int krb_err_base; | |
34 | #include <strings.h> | |
35 | #include "sms_server.h" | |
36 | ||
37 | extern char buf1[]; | |
38 | extern char *whoami; | |
39 | extern char *malloc(); | |
40 | ||
41 | /* | |
42 | * Handle a SMS_AUTH RPC request. | |
43 | * | |
44 | * argv[0] is a kerberos authenticator. Decompose it, and if | |
45 | * successful, store the name the user authenticated to in | |
46 | * cl->cl_name. | |
47 | */ | |
48 | ||
49 | void | |
50 | do_auth(cl) | |
51 | client *cl; | |
52 | { | |
53 | KTEXT_ST auth; | |
54 | AUTH_DAT ad; | |
55 | int status; | |
56 | char buf[REALM_SZ+INST_SZ+ANAME_SZ]; | |
57 | extern int krb_err_base; | |
58 | ||
59 | auth.length = cl->args->sms_argl[0]; | |
60 | ||
61 | bcopy(cl->args->sms_argv[0], (char *)auth.dat, auth.length); | |
62 | auth.mbz = 0; | |
63 | ||
64 | if ((status = rd_ap_req (&auth, "sms", "sms", cl->haddr.sin_addr, | |
65 | &ad, "")) != KSUCCESS) { | |
66 | status += krb_err_base; | |
67 | cl->reply.sms_status = status; | |
68 | if (log_flags & LOG_RES) | |
69 | com_err(whoami, status, "(authentication failed)"); | |
70 | return; | |
71 | } | |
72 | bcopy(ad.pname, cl->kname.name, ANAME_SZ); | |
73 | bcopy(ad.pinst, cl->kname.inst, INST_SZ); | |
74 | bcopy(ad.prealm, cl->kname.realm, REALM_SZ); | |
75 | ||
76 | (void) strcpy(buf, ad.pname); | |
77 | if(ad.pinst[0]) { | |
78 | (void) strcat(buf, "."); | |
79 | (void) strcat(buf, ad.pinst); | |
80 | } | |
81 | (void) strcat(buf, "@"); | |
82 | (void) strcat(buf, ad.prealm); | |
83 | if (cl->clname) free((char *)cl->clname); | |
84 | ||
85 | cl->clname = (char *)malloc((unsigned)(strlen(buf)+1)); | |
86 | (void) strcpy(cl->clname, buf); | |
87 | if (log_flags & LOG_RES) { | |
88 | com_err(whoami, 0, "Authenticated to %s", cl->clname); | |
89 | } | |
90 | } |