]> andersk Git - moira.git/blob - server/mr_sauth.c
Initial revision
[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.1  1987-06-02 20:06:57  wesommer
10  *      Initial revision
11  *
12  */
13
14 #ifndef lint
15 static char *rcsid_sms_sauth_c = "$Header$";
16 #endif lint
17
18 extern int krb_err_base;
19 #include <krb.h>
20 #include <strings.h>
21 #include "sms_private.h"
22 #include "sms_server.h"
23
24 extern char buf1[];
25 extern char *whoami;
26 extern char *malloc();
27
28 /*
29  * Handle a SMS_AUTH RPC request.
30  *
31  * argv[0] is a kerberos authenticator.  Decompose it, and if
32  * successful, store the name the user authenticated to in 
33  * cl->cl_name.
34  */
35
36 void
37 do_auth(cl)
38         client *cl;
39 {
40         KTEXT_ST auth;
41         AUTH_DAT ad;
42         int status;
43         char buf[REALM_SZ+INST_SZ+ANAME_SZ];
44         extern int krb_err_base;
45         
46         auth.length = cl->args->sms_argl[0];
47         bcopy(cl->args->sms_argv[0], (char *)auth.dat, auth.length);
48         auth.mbz = 0;
49         
50         if ((status = rd_ap_req (&auth, "sms", "sms", cl->haddr.sin_addr,
51                                  &ad, "")) != KSUCCESS) {
52                 status += krb_err_base;
53                 cl->reply.sms_status = status;
54                 com_err(whoami, status, "(authentication failed)");
55                 return;
56         }
57         (void) strcpy(buf, ad.pname);
58         if(ad.pinst[0]) {
59                 (void) strcat(buf, ".");
60                 (void) strcat(buf, ad.pinst);
61         }
62         (void) strcat(buf, "@");
63         (void) strcat(buf, ad.prealm);
64         if (cl->clname) free((char *)cl->clname);
65         
66         cl->clname = (char *)malloc((unsigned)(strlen(buf)+1));
67         (void) strcpy(cl->clname, buf);
68         (void) sprintf(buf1, "Authenticated to %s", cl->clname);
69         com_err(whoami, 0, buf1);
70 }
This page took 0.037259 seconds and 5 git commands to generate.