]>
Commit | Line | Data |
---|---|---|
7ac48069 | 1 | /* $Id $ |
e2a67c78 | 2 | * |
7ac48069 | 3 | * Handles the client side of the sending of authenticators to the moira server |
e2a67c78 | 4 | * |
7ac48069 | 5 | * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology |
6 | * For copying and distribution information, please see the file | |
7 | * <mit-copyright.h>. | |
e2a67c78 | 8 | */ |
9 | ||
babbc197 | 10 | #include <mit-copyright.h> |
7ac48069 | 11 | #include <moira.h> |
8defc06b | 12 | #include "mr_private.h" |
7ac48069 | 13 | |
713cf9c9 | 14 | #include <ctype.h> |
8fd777cf | 15 | #include <string.h> |
20e1c093 | 16 | |
7ac48069 | 17 | #include <krb.h> |
18 | extern char *krb_realmofhost(char *); | |
19 | extern int krb_mk_req(KTEXT, char *, char *, char *, int); | |
20 | ||
21 | RCSID("$Header$"); | |
22 | ||
59ec8dae | 23 | /* Authenticate this client with the Moira server. prog is the name of the |
6e20c6e8 | 24 | * client program, and will be recorded in the database. |
25 | */ | |
26 | ||
5eaef520 | 27 | int mr_auth(char *prog) |
e2a67c78 | 28 | { |
44d12d58 | 29 | int status; |
5eaef520 | 30 | mr_params params_st; |
31 | char *args[2]; | |
32 | int argl[2]; | |
33 | char realm[REALM_SZ], host[BUFSIZ], *p; | |
44d12d58 | 34 | mr_params *params = ¶ms_st; |
5eaef520 | 35 | mr_params *reply = NULL; |
36 | KTEXT_ST auth; | |
83e80378 | 37 | |
5eaef520 | 38 | CHECK_CONNECTED; |
11cf0ee5 | 39 | |
5eaef520 | 40 | /* Build a Kerberos authenticator. */ |
41 | ||
42 | memset(host, 0, sizeof(host)); | |
43 | if ((status = mr_host(host, sizeof(host) - 1))) | |
44 | return status; | |
45 | ||
7ac48069 | 46 | strcpy(realm, krb_realmofhost(host)); |
5eaef520 | 47 | for (p = host; *p && *p != '.'; p++) |
48 | { | |
713cf9c9 | 49 | if (isupper(*p)) |
50 | *p = tolower(*p); | |
5eaef520 | 51 | } |
52 | *p = '\0'; | |
11cf0ee5 | 53 | |
5eaef520 | 54 | status = krb_mk_req(&auth, MOIRA_SNAME, host, realm, 0); |
55 | if (status != KSUCCESS) | |
56 | { | |
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; | |
6e20c6e8 | 69 | |
5eaef520 | 70 | if (sending_version_no == MR_VERSION_1) |
71 | params->mr_argc = 1; | |
e2a67c78 | 72 | |
5eaef520 | 73 | if ((status = mr_do_call(params, &reply)) == 0) |
74 | status = reply->mr_status; | |
83e80378 | 75 | |
5eaef520 | 76 | mr_destroy_reply(reply); |
77 | ||
78 | return status; | |
e2a67c78 | 79 | } |