]> andersk Git - moira.git/blob - lib/mr_auth.c
make auth do the right thing for version 2 of the protocol
[moira.git] / lib / mr_auth.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.6  1988-06-01 15:31:53  mar
10  *      make auth do the right thing for version 2 of the protocol
11  *
12  * Revision 1.5  88/04/19  12:40:29  mar
13  * pass version number on queries
14  * 
15  * Revision 1.4  87/10/20  15:09:22  mar
16  * replace hardcoded ATHENA realm with call to get_krbrlm();
17  * 
18  * Revision 1.3  87/06/16  17:47:20  wesommer
19  * Clean up memory allocation, indenting.
20  * 
21  * Revision 1.2  87/05/31  22:03:23  wesommer
22  * It's working better.
23  * 
24  * Revision 1.1  87/05/20  03:11:18  wesommer
25  * Initial revision
26  * 
27  *
28  *      Handles the client side of the sending of authenticators to
29  * the sms server.      
30  */
31
32 #ifndef lint
33 static char *rcsid_sms_auth_c = "$Header$";
34 #endif lint
35
36 #include "sms_private.h"
37 #include <krb.h>
38
39 extern int krb_err_base;
40
41 /* Authenticate this client with the SMS server.  prog is the name of the
42  * client program, and will be recorded in the database.
43  */
44
45 int sms_auth(prog)
46 char *prog;
47 {
48     register int status;
49     sms_params params_st;
50     char *args[2];
51     int argl[2];
52     char realm[REALM_SZ];
53
54     register sms_params *params = &params_st;
55     sms_params *reply = NULL;
56     KTEXT_ST auth;
57
58     CHECK_CONNECTED;
59         
60     /*
61      * Build a Kerberos authenticator.
62      * The "service" and "instance" should not be hardcoded here.
63      */
64         
65     if ((status = get_krbrlm(realm, 1)) != KSUCCESS) {
66         return status;
67     }
68     status = mk_ap_req(&auth, "sms", "sms", realm, 0);
69     if (status != KSUCCESS) {
70         status += krb_err_base;
71         return status;
72     } 
73     params->sms_version_no = sending_version_no;
74     params->sms_procno = SMS_AUTH;
75     params->sms_argc = 2;
76     params->sms_argv = args;
77     params->sms_argl = argl;
78     params->sms_argv[0] = (char *)auth.dat;
79     params->sms_argl[0] = auth.length;
80     params->sms_argv[1] = prog;
81     params->sms_argl[1] = strlen(prog) + 1;
82         
83     if (sending_version_no == SMS_VERSION_1)
84         params->sms_argc = 1;
85
86     if ((status = sms_do_call(params, &reply)) == 0)
87         status = reply->sms_status;
88
89     sms_destroy_reply(reply);
90
91     return status;
92 }
93
94 /*
95  * Local Variables:
96  * mode: c
97  * c-indent-level: 4
98  * c-continued-statement-offset: 4
99  * c-brace-offset: -4
100  * c-argdecl-indent: 4
101  * c-label-offset: -4
102  * End:
103  */
This page took 0.054643 seconds and 5 git commands to generate.