]> andersk Git - moira.git/blob - lib/mr_auth.c
added the function lowercase()
[moira.git] / lib / mr_auth.c
1 /*
2  *      $Source$
3  *      $Author$
4  *      $Header$
5  *
6  *      Copyright (C) 1987, 1990 by the Massachusetts Institute of Technology
7  *      For copying and distribution information, please see the file
8  *      <mit-copyright.h>.
9  *
10  *      Handles the client side of the sending of authenticators to
11  * the mr server.       
12  */
13
14 #ifndef lint
15 static char *rcsid_sms_auth_c = "$Header$";
16 #endif lint
17
18 #include <mit-copyright.h>
19 #include "mr_private.h"
20 #include <ctype.h>
21 #include <krb.h>
22 #include <krb_et.h>
23
24 /* Authenticate this client with the MR server.  prog is the name of the
25  * client program, and will be recorded in the database.
26  */
27
28 int mr_auth(prog)
29 char *prog;
30 {
31     register int status;
32     mr_params params_st;
33     char *args[2];
34     int argl[2];
35     char realm[REALM_SZ], host[BUFSIZ], *p;
36
37     register mr_params *params = &params_st;
38     mr_params *reply = NULL;
39     KTEXT_ST auth;
40
41     CHECK_CONNECTED;
42         
43     /* Build a Kerberos authenticator. */
44         
45     bzero(host, sizeof(host));
46     if (status = mr_host(host, sizeof(host) - 1))
47         return status;
48
49     strcpy(realm, krb_realmofhost(host));
50     for (p = host; *p && *p != '.'; p++)
51       if (isupper(*p))
52         *p = tolower(*p);
53     *p = 0;
54
55     status = krb_mk_req(&auth, MOIRA_SNAME, host, realm, 0);
56     if (status != KSUCCESS) {
57         status += ERROR_TABLE_BASE_krb;
58         return status;
59     } 
60     params->mr_version_no = sending_version_no;
61     params->mr_procno = MR_AUTH;
62     params->mr_argc = 2;
63     params->mr_argv = args;
64     params->mr_argl = argl;
65     params->mr_argv[0] = (char *)auth.dat;
66     params->mr_argl[0] = auth.length;
67     params->mr_argv[1] = prog;
68     params->mr_argl[1] = strlen(prog) + 1;
69         
70     if (sending_version_no == MR_VERSION_1)
71         params->mr_argc = 1;
72
73     if ((status = mr_do_call(params, &reply)) == 0)
74         status = reply->mr_status;
75
76     mr_destroy_reply(reply);
77
78     return status;
79 }
This page took 0.089699 seconds and 5 git commands to generate.