]>
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> |
85330553 | 15 | #include <stdio.h> |
8fd777cf | 16 | #include <string.h> |
20e1c093 | 17 | |
7ac48069 | 18 | #include <krb.h> |
7ac48069 | 19 | |
20 | RCSID("$Header$"); | |
21 | ||
59ec8dae | 22 | /* Authenticate this client with the Moira server. prog is the name of the |
6e20c6e8 | 23 | * client program, and will be recorded in the database. |
24 | */ | |
25 | ||
5eaef520 | 26 | int mr_auth(char *prog) |
e2a67c78 | 27 | { |
44d12d58 | 28 | int status; |
85330553 | 29 | mr_params params, reply; |
5eaef520 | 30 | char *args[2]; |
31 | int argl[2]; | |
32 | char realm[REALM_SZ], host[BUFSIZ], *p; | |
5eaef520 | 33 | KTEXT_ST auth; |
83e80378 | 34 | |
5eaef520 | 35 | CHECK_CONNECTED; |
11cf0ee5 | 36 | |
5eaef520 | 37 | if ((status = mr_host(host, sizeof(host) - 1))) |
38 | return status; | |
39 | ||
7ac48069 | 40 | strcpy(realm, krb_realmofhost(host)); |
5eaef520 | 41 | for (p = host; *p && *p != '.'; p++) |
42 | { | |
713cf9c9 | 43 | if (isupper(*p)) |
44 | *p = tolower(*p); | |
5eaef520 | 45 | } |
46 | *p = '\0'; | |
11cf0ee5 | 47 | |
5eaef520 | 48 | status = krb_mk_req(&auth, MOIRA_SNAME, host, realm, 0); |
49 | if (status != KSUCCESS) | |
50 | { | |
51 | status += ERROR_TABLE_BASE_krb; | |
52 | return status; | |
53 | } | |
85330553 | 54 | params.u.mr_procno = MR_AUTH; |
55 | params.mr_argc = 2; | |
56 | params.mr_argv = args; | |
57 | params.mr_argl = argl; | |
58 | params.mr_argv[0] = (char *)auth.dat; | |
59 | params.mr_argl[0] = auth.length; | |
60 | params.mr_argv[1] = prog; | |
61 | params.mr_argl[1] = strlen(prog) + 1; | |
e2a67c78 | 62 | |
85330553 | 63 | if ((status = mr_do_call(¶ms, &reply)) == MR_SUCCESS) |
64 | status = reply.u.mr_status; | |
83e80378 | 65 | |
5eaef520 | 66 | mr_destroy_reply(reply); |
67 | ||
68 | return status; | |
e2a67c78 | 69 | } |
ea16b46d | 70 | |
71 | int mr_proxy(char *principal, char *orig_authtype) | |
72 | { | |
73 | int status; | |
74 | mr_params params, reply; | |
75 | char *args[2]; | |
76 | ||
77 | params.u.mr_procno = MR_PROXY; | |
78 | params.mr_argc = 2; | |
79 | params.mr_argv = args; | |
80 | params.mr_argv[0] = principal; | |
81 | params.mr_argv[1] = orig_authtype; | |
82 | params.mr_argl = NULL; | |
83 | ||
84 | if ((status = mr_do_call(¶ms, &reply)) == MR_SUCCESS) | |
85 | status = reply.u.mr_status; | |
86 | ||
87 | mr_destroy_reply(reply); | |
88 | ||
89 | return status; | |
90 | } |