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