]>
Commit | Line | Data |
---|---|---|
fa59b86f | 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> |
7ac48069 | 18 | |
19 | RCSID("$Header$"); | |
20 | ||
59ec8dae | 21 | /* Authenticate this client with the Moira server. prog is the name of the |
6e20c6e8 | 22 | * client program, and will be recorded in the database. |
23 | */ | |
24 | ||
5eaef520 | 25 | int mr_auth(char *prog) |
e2a67c78 | 26 | { |
44d12d58 | 27 | int status; |
5eaef520 | 28 | mr_params params_st; |
29 | char *args[2]; | |
30 | int argl[2]; | |
31 | char realm[REALM_SZ], host[BUFSIZ], *p; | |
44d12d58 | 32 | mr_params *params = ¶ms_st; |
5eaef520 | 33 | mr_params *reply = NULL; |
34 | KTEXT_ST auth; | |
83e80378 | 35 | |
5eaef520 | 36 | CHECK_CONNECTED; |
11cf0ee5 | 37 | |
5eaef520 | 38 | /* Build a Kerberos authenticator. */ |
39 | ||
40 | memset(host, 0, sizeof(host)); | |
41 | if ((status = mr_host(host, sizeof(host) - 1))) | |
42 | return status; | |
43 | ||
7ac48069 | 44 | strcpy(realm, krb_realmofhost(host)); |
5eaef520 | 45 | for (p = host; *p && *p != '.'; p++) |
46 | { | |
713cf9c9 | 47 | if (isupper(*p)) |
48 | *p = tolower(*p); | |
5eaef520 | 49 | } |
50 | *p = '\0'; | |
11cf0ee5 | 51 | |
5eaef520 | 52 | status = krb_mk_req(&auth, MOIRA_SNAME, host, realm, 0); |
53 | if (status != KSUCCESS) | |
54 | { | |
55 | status += ERROR_TABLE_BASE_krb; | |
56 | return status; | |
57 | } | |
58 | params->mr_version_no = sending_version_no; | |
59 | params->mr_procno = MR_AUTH; | |
60 | params->mr_argc = 2; | |
61 | params->mr_argv = args; | |
62 | params->mr_argl = argl; | |
63 | params->mr_argv[0] = (char *)auth.dat; | |
64 | params->mr_argl[0] = auth.length; | |
65 | params->mr_argv[1] = prog; | |
66 | params->mr_argl[1] = strlen(prog) + 1; | |
6e20c6e8 | 67 | |
5eaef520 | 68 | if (sending_version_no == MR_VERSION_1) |
69 | params->mr_argc = 1; | |
e2a67c78 | 70 | |
5eaef520 | 71 | if ((status = mr_do_call(params, &reply)) == 0) |
72 | status = reply->mr_status; | |
83e80378 | 73 | |
5eaef520 | 74 | mr_destroy_reply(reply); |
75 | ||
76 | return status; | |
e2a67c78 | 77 | } |