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