]> andersk Git - moira.git/blame - server/mr_sauth.c
bump max_row_count to 4096 (since the number of public lists is > 2048 now)
[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
c801de4c 16#include <mit-copyright.h>
03c05291 17#include <string.h>
d548a4e7 18#include "mr_server.h"
713cf9c9 19#include <ctype.h>
40165bd0 20#include <krb_et.h>
03c05291 21#include <moira.h>
a3cf6921 22
23extern char buf1[];
24extern char *whoami;
a3cf6921 25
03c05291 26/* from libmoira */
27char *kname_unparse(char *, char *, char *);
c1665e6d 28
a3cf6921 29/*
d548a4e7 30 * Handle a MOIRA_AUTH RPC request.
a3cf6921 31 *
32 * argv[0] is a kerberos authenticator. Decompose it, and if
33 * successful, store the name the user authenticated to in
34 * cl->cl_name.
35 */
36
37void
38do_auth(cl)
39 client *cl;
40{
41 KTEXT_ST auth;
42 AUTH_DAT ad;
c1665e6d 43 int status, ok;
03c05291 44 char hostbuf[BUFSIZ], *host, *p;
a53c9c79 45 extern int errno;
713cf9c9 46
d548a4e7 47 auth.length = cl->args->mr_argl[0];
03c05291 48 memcpy((char *)auth.dat, cl->args->mr_argv[0], auth.length);
a3cf6921 49 auth.mbz = 0;
713cf9c9 50 if (gethostname(hostbuf, sizeof(hostbuf)) < 0)
51 com_err(whoami, errno, "Unable to get local hostname");
52 host = canonicalize_hostname(strsave(hostbuf));
53 for (p = host; *p && *p != '.'; p++)
54 if (isupper(*p))
55 *p = tolower(*p);
56 *p = 0;
57
03c05291 58 if ((status = krb_rd_req (&auth, MOIRA_SNAME, host,
59 cl->haddr.sin_addr.s_addr, &ad, "")) != 0) {
40165bd0 60 status += ERROR_TABLE_BASE_krb;
d548a4e7 61 cl->reply.mr_status = status;
060e9c63 62 if (log_flags & LOG_RES)
63 com_err(whoami, status, "(authentication failed)");
a3cf6921 64 return;
65 }
713cf9c9 66 free(host);
c1665e6d 67
03c05291 68 memcpy(cl->kname.name, ad.pname, ANAME_SZ);
69 memcpy(cl->kname.inst, ad.pinst, INST_SZ);
70 memcpy(cl->kname.realm, ad.prealm, REALM_SZ);
c1665e6d 71 strcpy(cl->clname, kname_unparse(ad.pname, ad.pinst, ad.prealm));
90021a6f 72
c1665e6d 73 if (ad.pinst[0] == 0 && !strcmp(ad.prealm, krb_realm))
74 ok = 1;
75 else
76 ok = 0;
77 /* this is in a separate function because it accesses the database */
aa3c5c98 78 status = set_krb_mapping(cl->clname, ad.pname, ok,
79 &cl->client_id, &cl->users_id);
90021a6f 80
d548a4e7 81 if (cl->args->mr_version_no == MR_VERSION_2) {
dda4020f 82 strncpy(cl->entity, cl->args->mr_argv[1], 8);
c1665e6d 83 cl->entity[8] = 0;
90021a6f 84 } else {
c1665e6d 85 strcpy(cl->entity, "???");
060e9c63 86 }
03c05291 87 memset(&ad, 0, sizeof(ad)); /* Clean up session key, etc. */
90021a6f 88
89 if (log_flags & LOG_RES)
c1665e6d 90 com_err(whoami, 0, "Auth to %s using %s, uid %d cid %d",
91 cl->clname, cl->entity, cl->users_id, cl->client_id);
aa3c5c98 92 if (status != MR_SUCCESS)
93 cl->reply.mr_status = status;
94 else if (cl->users_id == 0)
d548a4e7 95 cl->reply.mr_status = MR_USER_AUTH;
a3cf6921 96}
This page took 0.094723 seconds and 5 git commands to generate.