]> andersk Git - moira.git/blame - update/auth_001.c
no longer use special execute_comd.c
[moira.git] / update / auth_001.c
CommitLineData
de56407f 1/*
2 * $Source$
3 * $Header$
4 */
5
6#ifndef lint
7static char *rcsid_auth_001_c = "$Header$";
8#endif lint
9
10#include <stdio.h>
11#include <strings.h>
1e8fd4c0 12#include <gdb.h>
de56407f 13#include "kludge.h"
14#include <krb.h>
15#include <netinet/in.h>
16#include <errno.h>
17
18extern char buf[BUFSIZ];
19extern int have_authorization;
20extern struct sockaddr_in *client_address();
21extern CONNECTION conn;
22int code;
23extern char *PrincipalHostname();
1c6164bb 24static char service[] = "rcmd";
25static char master[] = "sms";
de56407f 26static char qmark[] = "???";
27
28/*
29 * authentication request auth_001:
30 *
31 * >>> (STRING) "auth_001"
32 * <<< (int) 0
33 * >>> (STRING) ticket
34 * <<< (int) code
35 *
36 */
37
38int
39auth_001(str)
40 char *str;
41{
42 STRING data;
43 char host[BUFSIZ];
44 AUTH_DAT ad;
45 char realm[REALM_SZ];
46 KTEXT_ST ticket_st;
47
48 if (send_ok())
49 lose("sending okay for authorization (auth_001)");
50 code = receive_object(conn, (char *)&data, STRING_T);
51 if (code) {
52 code = connection_errno(conn);
53 lose("awaiting Kerberos authenticators");
54 }
55 gethostname(host, BUFSIZ);
56 ticket_st.mbz = 0;
57 ticket_st.length = MAX_STRING_SIZE(data);
58 bcopy(STRING_DATA(data), ticket_st.dat, MAX_STRING_SIZE(data));
1e8fd4c0 59 code = krb_rd_req(&ticket_st, service,
de56407f 60 PrincipalHostname(host), 0,
61 &ad, "/etc/srvtab");
62 if (code) {
63 code = krb_err_frob(code);
64 strcpy(ad.pname, qmark);
65 strcpy(ad.pinst, qmark);
66 strcpy(ad.prealm, qmark);
67 goto auth_failed;
68 }
69 if (get_krbrlm(realm,0))
70 realm[0] = '\0';
71 code = EPERM;
1c6164bb 72 if (strcmp(master, ad.pname))
de56407f 73 goto auth_failed;
74 if (ad.pinst[0] != '\0')
75 goto auth_failed;
76 if (strcmp(realm, ad.prealm))
77 goto auth_failed;
78 if (send_ok())
79 lose("sending approval of authorization");
80 have_authorization = 1;
81 return(0);
82auth_failed:
83 sprintf(buf, "auth for %s.%s@%s failed: %s",
84 ad.pname, ad.pinst, ad.prealm, error_message(code));
85 {
86 register int rc;
87 rc = send_object(conn, (char *)&code, INTEGER_T);
88 code = rc;
89 }
90 if (code)
91 lose("sending rejection of authenticator");
92 return(EPERM);
93}
This page took 0.059739 seconds and 5 git commands to generate.