]> andersk Git - moira.git/blame - server/mr_sauth.c
fixed canonicalization of hostnames, and print warning if changing
[moira.git] / server / mr_sauth.c
CommitLineData
a3cf6921 1/*
2 * $Source$
3 * $Author$
4 * $Header$
5 *
6 * Copyright (C) 1987 by the Massachusetts Institute of Technology
c801de4c 7 * For copying and distribution information, please see the file
8 * <mit-copyright.h>.
a3cf6921 9 *
a3cf6921 10 */
11
12#ifndef lint
13static char *rcsid_sms_sauth_c = "$Header$";
14#endif lint
15
16extern int krb_err_base;
c801de4c 17#include <mit-copyright.h>
a3cf6921 18#include <strings.h>
a3cf6921 19#include "sms_server.h"
20
21extern char buf1[];
22extern char *whoami;
23extern char *malloc();
24
25/*
26 * Handle a SMS_AUTH RPC request.
27 *
28 * argv[0] is a kerberos authenticator. Decompose it, and if
29 * successful, store the name the user authenticated to in
30 * cl->cl_name.
31 */
32
33void
34do_auth(cl)
35 client *cl;
36{
37 KTEXT_ST auth;
38 AUTH_DAT ad;
39 int status;
40 char buf[REALM_SZ+INST_SZ+ANAME_SZ];
41 extern int krb_err_base;
90021a6f 42 static char *unknown = "???";
a3cf6921 43
23e476e8 44 if (cl->clname) {
45 free(cl->clname);
46 cl->clname = 0;
90021a6f 47 cl->users_id = 0;
23e476e8 48 bzero(&cl->kname, sizeof(cl->kname));
49 }
90021a6f 50 if (cl->entity && cl->entity != unknown) {
51 free(cl->entity);
52 cl->entity = 0;
53 }
23e476e8 54
a3cf6921 55 auth.length = cl->args->sms_argl[0];
56 bcopy(cl->args->sms_argv[0], (char *)auth.dat, auth.length);
57 auth.mbz = 0;
58
90021a6f 59 if ((status = krb_rd_req (&auth, "sms", "sms", cl->haddr.sin_addr,
a3cf6921 60 &ad, "")) != KSUCCESS) {
61 status += krb_err_base;
62 cl->reply.sms_status = status;
060e9c63 63 if (log_flags & LOG_RES)
64 com_err(whoami, status, "(authentication failed)");
a3cf6921 65 return;
66 }
8a36ddfe 67 bcopy(ad.pname, cl->kname.name, ANAME_SZ);
68 bcopy(ad.pinst, cl->kname.inst, INST_SZ);
69 bcopy(ad.prealm, cl->kname.realm, REALM_SZ);
70
a3cf6921 71 (void) strcpy(buf, ad.pname);
72 if(ad.pinst[0]) {
73 (void) strcat(buf, ".");
74 (void) strcat(buf, ad.pinst);
75 }
76 (void) strcat(buf, "@");
77 (void) strcat(buf, ad.prealm);
78 if (cl->clname) free((char *)cl->clname);
79
80 cl->clname = (char *)malloc((unsigned)(strlen(buf)+1));
81 (void) strcpy(cl->clname, buf);
23e476e8 82 bzero(&ad, sizeof(ad)); /* Clean up session key, etc. */
90021a6f 83
84 cl->users_id = get_users_id(cl->kname.name);
85
86 if (cl->args->sms_version_no == SMS_VERSION_2) {
87 unsigned len = strlen(cl->args->sms_argv[1]) + 1;
88
89 cl->entity = (char *)malloc(len);
90 bcopy(cl->args->sms_argv[1], cl->entity, len+1);
91 } else {
92 cl->entity = unknown;
060e9c63 93 }
90021a6f 94
95 if (log_flags & LOG_RES)
96 com_err(whoami, 0, "Authenticated to %s using %s, id %d",
97 cl->clname, cl->entity, cl->users_id);
054523f7 98 if (cl->users_id == 0)
99 cl->reply.sms_status = SMS_USER_AUTH;
a3cf6921 100}
This page took 0.067263 seconds and 5 git commands to generate.