]> andersk Git - moira.git/blame_incremental - lib/mr_auth.c
Diane Delgado's changes for a fixed table-locking order
[moira.git] / lib / mr_auth.c
... / ...
CommitLineData
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
15static 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#include <string.h>
24
25/* Authenticate this client with the MR server. prog is the name of the
26 * client program, and will be recorded in the database.
27 */
28
29int mr_auth(prog)
30char *prog;
31{
32 register int status;
33 mr_params params_st;
34 char *args[2];
35 int argl[2];
36 char realm[REALM_SZ], host[BUFSIZ], *p;
37
38 register mr_params *params = &params_st;
39 mr_params *reply = NULL;
40 KTEXT_ST auth;
41
42 CHECK_CONNECTED;
43
44 /* Build a Kerberos authenticator. */
45
46 memset(host, 0, sizeof(host));
47 if (status = mr_host(host, sizeof(host) - 1))
48 return status;
49
50 strcpy(realm, (char *)krb_realmofhost(host));
51 for (p = host; *p && *p != '.'; p++)
52 if (isupper(*p))
53 *p = tolower(*p);
54 *p = 0;
55
56 status = krb_mk_req(&auth, MOIRA_SNAME, host, realm, 0);
57 if (status != KSUCCESS) {
58 status += ERROR_TABLE_BASE_krb;
59 return status;
60 }
61 params->mr_version_no = sending_version_no;
62 params->mr_procno = MR_AUTH;
63 params->mr_argc = 2;
64 params->mr_argv = args;
65 params->mr_argl = argl;
66 params->mr_argv[0] = (char *)auth.dat;
67 params->mr_argl[0] = auth.length;
68 params->mr_argv[1] = prog;
69 params->mr_argl[1] = strlen(prog) + 1;
70
71 if (sending_version_no == MR_VERSION_1)
72 params->mr_argc = 1;
73
74 if ((status = mr_do_call(params, &reply)) == 0)
75 status = reply->mr_status;
76
77 mr_destroy_reply(reply);
78
79 return status;
80}
This page took 0.036407 seconds and 5 git commands to generate.