]>
Commit | Line | Data |
---|---|---|
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 | |
15 | static 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> |
8fd777cf | 23 | #include <string.h> |
20e1c093 | 24 | |
8defc06b | 25 | /* Authenticate this client with the MR server. prog is the name of the |
6e20c6e8 | 26 | * client program, and will be recorded in the database. |
27 | */ | |
28 | ||
8defc06b | 29 | int mr_auth(prog) |
6e20c6e8 | 30 | char *prog; |
e2a67c78 | 31 | { |
83e80378 | 32 | register int status; |
8defc06b | 33 | mr_params params_st; |
6e20c6e8 | 34 | char *args[2]; |
35 | int argl[2]; | |
713cf9c9 | 36 | char realm[REALM_SZ], host[BUFSIZ], *p; |
a29db7d1 | 37 | |
8defc06b | 38 | register mr_params *params = ¶ms_st; |
39 | mr_params *reply = NULL; | |
83e80378 | 40 | KTEXT_ST auth; |
41 | ||
42 | CHECK_CONNECTED; | |
e2a67c78 | 43 | |
713cf9c9 | 44 | /* Build a Kerberos authenticator. */ |
e2a67c78 | 45 | |
8fd777cf | 46 | memset(host, 0, sizeof(host)); |
8defc06b | 47 | if (status = mr_host(host, sizeof(host) - 1)) |
a29db7d1 | 48 | return status; |
11cf0ee5 | 49 | |
8fd777cf | 50 | strcpy(realm, (char *)krb_realmofhost(host)); |
713cf9c9 | 51 | for (p = host; *p && *p != '.'; p++) |
52 | if (isupper(*p)) | |
53 | *p = tolower(*p); | |
54 | *p = 0; | |
11cf0ee5 | 55 | |
713cf9c9 | 56 | status = krb_mk_req(&auth, MOIRA_SNAME, host, realm, 0); |
83e80378 | 57 | if (status != KSUCCESS) { |
3ebfd545 | 58 | status += ERROR_TABLE_BASE_krb; |
83e80378 | 59 | return status; |
89371417 | 60 | } |
8defc06b | 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; | |
e2a67c78 | 70 | |
8defc06b | 71 | if (sending_version_no == MR_VERSION_1) |
72 | params->mr_argc = 1; | |
6e20c6e8 | 73 | |
8defc06b | 74 | if ((status = mr_do_call(params, &reply)) == 0) |
75 | status = reply->mr_status; | |
e2a67c78 | 76 | |
8defc06b | 77 | mr_destroy_reply(reply); |
83e80378 | 78 | |
79 | return status; | |
e2a67c78 | 80 | } |