]>
Commit | Line | Data |
---|---|---|
1 | /* $Id$ | |
2 | * | |
3 | * Handles the client side of the sending of authenticators to the moira server | |
4 | * | |
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>. | |
8 | */ | |
9 | ||
10 | #include <mit-copyright.h> | |
11 | #include <moira.h> | |
12 | #include "mr_private.h" | |
13 | ||
14 | #include <ctype.h> | |
15 | #include <stdio.h> | |
16 | #include <string.h> | |
17 | ||
18 | #include <krb.h> | |
19 | ||
20 | RCSID("$Header$"); | |
21 | ||
22 | /* Authenticate this client with the Moira server. prog is the name of the | |
23 | * client program, and will be recorded in the database. | |
24 | */ | |
25 | ||
26 | int mr_auth(char *prog) | |
27 | { | |
28 | int status; | |
29 | mr_params params, reply; | |
30 | char *args[2]; | |
31 | int argl[2]; | |
32 | char realm[REALM_SZ], host[BUFSIZ], *p; | |
33 | KTEXT_ST auth; | |
34 | ||
35 | CHECK_CONNECTED; | |
36 | ||
37 | if ((status = mr_host(host, sizeof(host) - 1))) | |
38 | return status; | |
39 | ||
40 | strcpy(realm, krb_realmofhost(host)); | |
41 | for (p = host; *p && *p != '.'; p++) | |
42 | { | |
43 | if (isupper(*p)) | |
44 | *p = tolower(*p); | |
45 | } | |
46 | *p = '\0'; | |
47 | ||
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 | } | |
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; | |
62 | ||
63 | if ((status = mr_do_call(¶ms, &reply)) == MR_SUCCESS) | |
64 | status = reply.u.mr_status; | |
65 | ||
66 | mr_destroy_reply(reply); | |
67 | ||
68 | return status; | |
69 | } |