5 /* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
6 /* For copying and distribution information, please see the file */
7 /* <mit-copyright.h>. */
10 static char *rcsid_auth_001_c = "$Header$";
13 #include <mit-copyright.h>
19 #include <netinet/in.h>
22 extern char buf[BUFSIZ];
23 extern int have_authorization;
24 extern struct sockaddr_in *client_address();
25 extern CONNECTION conn;
27 extern char *PrincipalHostname();
28 static char service[] = "rcmd";
29 static char master[] = "sms";
30 static char qmark[] = "???";
33 * authentication request auth_001:
35 * >>> (STRING) "auth_001"
53 lose("sending okay for authorization (auth_001)");
54 code = receive_object(conn, (char *)&data, STRING_T);
56 code = connection_errno(conn);
57 lose("awaiting Kerberos authenticators");
59 gethostname(host, BUFSIZ);
61 ticket_st.length = MAX_STRING_SIZE(data);
62 bcopy(STRING_DATA(data), ticket_st.dat, MAX_STRING_SIZE(data));
63 code = krb_rd_req(&ticket_st, service,
64 PrincipalHostname(host), 0,
67 code += ERROR_TABLE_BASE_krb;
68 strcpy(ad.pname, qmark);
69 strcpy(ad.pinst, qmark);
70 strcpy(ad.prealm, qmark);
73 if (krb_get_lrealm(realm,1))
74 strcpy(realm, KRB_REALM);
76 if (strcmp(master, ad.pname))
78 if (ad.pinst[0] != '\0')
80 if (strcmp(realm, ad.prealm))
83 lose("sending approval of authorization");
84 have_authorization = 1;
87 sprintf(buf, "auth for %s.%s@%s failed: %s",
88 ad.pname, ad.pinst, ad.prealm, error_message(code));
91 rc = send_object(conn, (char *)&code, INTEGER_T);
95 lose("sending rejection of authenticator");