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