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