From: neilbrown Date: Fri, 26 Aug 2005 01:20:12 +0000 (+0000) Subject: 2005-08-26 Kevin Coffman X-Git-Tag: nfs-utils-1-0-7-post1^0 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=c5ea2fbc9ab9d142aa867da594a66f4097df03d1;p=nfs-utils.git 2005-08-26 Kevin Coffman * configure.in etc Consolidate some of the Kerberos checking instead of repeating the same things for MIT and Heimdal. Also adds more checks to distinguish 32-bit from 64-bit (mainly for gssapi.h) Fix svcgssd Makefile so make TOP=../../ works correctly there. Enable running a modern autoheader. * utils/gssd/gss_oids.c: Use correct OID value for SPKM-3 * utils/gssd/gss_util.c: Fix build with older MIT releases that do not define GSS_C_NT_HOSTBASED_SERVICE * utils/gssd/write_bytes.h, support/include/gssapi/gssapi.h: Length of gss_buffer_desc is a size_t which is 64-bits on a 64-bit machine. Kernel code expects 32-bit integer for length. Coerce length value into a 32-bit value when reading from or writing to the kernel. Change gssapi.h to use datatype size values obtained from configure rather than hard-coded values. * utils/idmapd/idmapd.c: The EV_INIT check here was wrong, and was causing idmapd to become unresponsive to server requests after receiving a sighup. * utils/idmapd/idmapd.c: Idmapd should flush the server id<->name caches when its started. --- diff --git a/ChangeLog b/ChangeLog index 5876522..c7068a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,20 @@ (mainly for gssapi.h) Fix svcgssd Makefile so make TOP=../../ works correctly there. Enable running a modern autoheader. + * utils/gssd/gss_oids.c: Use correct OID value for SPKM-3 + * utils/gssd/gss_util.c: Fix build with older MIT releases that do not define GSS_C_NT_HOSTBASED_SERVICE + * utils/gssd/write_bytes.h, support/include/gssapi/gssapi.h: + Length of gss_buffer_desc is a size_t which is 64-bits on a + 64-bit machine. Kernel code expects 32-bit integer for length. + Coerce length value into a 32-bit value when reading from or + writing to the kernel. + Change gssapi.h to use datatype size values obtained from + configure rather than hard-coded values. + * utils/idmapd/idmapd.c: The EV_INIT check here was wrong, and was + causing idmapd to become unresponsive to server requests after + receiving a sighup. + * utils/idmapd/idmapd.c: Idmapd should flush the server id<->name + caches when its started. 2005-04-12 G. Allen Morris III diff --git a/support/include/gssapi/gssapi.h b/support/include/gssapi/gssapi.h index 18d62db..22cd329 100644 --- a/support/include/gssapi/gssapi.h +++ b/support/include/gssapi/gssapi.h @@ -1,25 +1,3 @@ -/* This is the gssapi.h prologue. */ -/* It contains some choice pieces of autoconf.h */ -#define SIZEOF_INT 4 -#define SIZEOF_LONG 4 -#define SIZEOF_SHORT 2 -#define HAVE_STDARG_H 1 -/* #undef HAVE_VARARGS_H */ -/* #undef HAVE_MACSOCK_H */ -#define HAVE_NETINET_IN_H 1 -#define HAVE_STDDEF_H 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STRING_H 1 -#define HAVE_SYS_FILE_H 1 -#define HAVE_SYS_PARAM_H 1 -#define HAVE_SYS_SOCKET_H 1 -#define HAVE_SYS_STAT_H 1 -#define HAVE_SYS_TIME_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_UNISTD_H 1 -/* #undef HAVE_XOM_H */ -#define USE_DIRENT_H 1 -/* End of gssapi.h prologue. */ /* * Copyright 1993 by OpenVision Technologies, Inc. * @@ -45,6 +23,8 @@ #ifndef _GSSAPI_H_ #define _GSSAPI_H_ +#include "config.h" + /* * Determine platform-dependent configuration. */ @@ -127,7 +107,7 @@ extern "C" { #endif /* HAVE_XOM_H */ /* - * $Id: gssapi.h,v 1.1 2004/10/19 00:22:57 neilbrown Exp $ + * $Id: gssapi.h,v 1.2 2005/08/26 01:20:12 neilbrown Exp $ */ /* diff --git a/utils/gssd/gss_oids.c b/utils/gssd/gss_oids.c index e800115..c569b0c 100644 --- a/utils/gssd/gss_oids.c +++ b/utils/gssd/gss_oids.c @@ -36,4 +36,4 @@ gss_OID_desc krb5oid = {9, "\052\206\110\206\367\022\001\002\002"}; gss_OID_desc spkm3oid = - {7, "\052\006\001\005\005\001\003"}; + {7, "\053\006\001\005\005\001\003"}; diff --git a/utils/gssd/gss_util.c b/utils/gssd/gss_util.c index 3493280..cf240ac 100644 --- a/utils/gssd/gss_util.c +++ b/utils/gssd/gss_util.c @@ -73,6 +73,10 @@ #include #include #include +#if defined(HAVE_KRB5) && !defined(GSS_C_NT_HOSTBASED_SERVICE) +#include +#define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name +#endif #include "gss_util.h" #include "err_util.h" #include "gssd.h" diff --git a/utils/gssd/write_bytes.h b/utils/gssd/write_bytes.h index ba00598..f166148 100644 --- a/utils/gssd/write_bytes.h +++ b/utils/gssd/write_bytes.h @@ -53,12 +53,13 @@ write_bytes(char **ptr, const char *end, const void *arg, int arg_len) inline static int write_buffer(char **p, char *end, gss_buffer_desc *arg) { - if (WRITE_BYTES(p, end, arg->length)) + int len = (int)arg->length; /* make an int out of size_t */ + if (WRITE_BYTES(p, end, len)) return -1; if (*p + arg->length > end) return -1; - memcpy(*p, arg->value, arg->length); - *p += arg->length; + memcpy(*p, arg->value, len); + *p += len; return 0; } @@ -80,8 +81,10 @@ get_buffer(char **ptr, const char *end, gss_buffer_desc *res) { char *p, *q; p = *ptr; - if (get_bytes(&p, end, &res->length, sizeof(res->length))) + int len; + if (get_bytes(&p, end, &len, sizeof(len))) return -1; + res->length = len; /* promote to size_t if necessary */ q = p + res->length; if (q > end || q < p) return -1; @@ -105,9 +108,11 @@ static inline int xdr_get_buffer(u_int32_t **ptr, const u_int32_t *end, gss_buffer_desc *res) { u_int32_t *p, *q; + u_int32_t len; p = *ptr; - if (xdr_get_u32(&p, end, &res->length)) + if (xdr_get_u32(&p, end, &len)) return -1; + res->length = len; q = p + ((res->length + 3) >> 2); if (q > end || q < p) return -1; @@ -130,7 +135,8 @@ xdr_write_u32(u_int32_t **ptr, const u_int32_t *end, u_int32_t arg) static inline int xdr_write_buffer(u_int32_t **ptr, const u_int32_t *end, gss_buffer_desc *arg) { - if (xdr_write_u32(ptr, end, arg->length)) + int len = arg->length; + if (xdr_write_u32(ptr, end, len)) return -1; return write_bytes((char **)ptr, (char *)end, arg->value, (arg->length + 3) & ~3); diff --git a/utils/idmapd/idmapd.c b/utils/idmapd/idmapd.c index 02604df..b1da786 100644 --- a/utils/idmapd/idmapd.c +++ b/utils/idmapd/idmapd.c @@ -141,6 +141,34 @@ static struct idmap_client nfsd_ic[2]; /* Used by cfg.c */ char *conf_path; +static int +flush_nfsd_cache(char *path, time_t now) +{ + int fd; + char stime[20]; + + sprintf(stime, "%ld\n", now); + fd = open(path, O_RDWR); + if (fd == -1) + return -1; + write(fd, stime, strlen(stime)); + close(fd); + return 0; +} + +static int +flush_nfsd_idmap_cache(void) +{ + time_t now = time(NULL); + int ret; + + ret = flush_nfsd_cache("/proc/net/rpc/nfs4.idtoname/flush", now); + if (ret) + return ret; + ret = flush_nfsd_cache("/proc/net/rpc/nfs4.nametoid/flush", now); + return ret; +} + int main(int argc, char **argv) { @@ -153,6 +181,7 @@ main(int argc, char **argv) struct stat sb; char *xpipefsdir = NULL; int serverstart = 1, clientstart = 1; + int ret; conf_path = _PATH_IDMAPDCONF; nobodyuser = NFS4NOBODY_USER; @@ -230,8 +259,14 @@ main(int argc, char **argv) event_init(); - if (serverstart) + if (serverstart) { nfsdret = nfsdopen(NFSD_DIR); + if (nfsdret == 0) { + ret = flush_nfsd_idmap_cache(); + if (ret) + errx(1, "Failed to flush nfsd idmap cache\n"); + } + } if (clientstart) { struct timeval now = { @@ -565,10 +600,8 @@ nfsdreopen_one(struct idmap_client *ic) if (ic->ic_fd != -1) close(ic->ic_fd); ic->ic_event.ev_fd = ic->ic_fd = fd; - if ((ic->ic_event.ev_flags & EVLIST_INIT) == 0) { - event_set(&ic->ic_event, ic->ic_fd, EV_READ, nfsdcb, ic); - event_add(&ic->ic_event, NULL); - } + event_set(&ic->ic_event, ic->ic_fd, EV_READ, nfsdcb, ic); + event_add(&ic->ic_event, NULL); } else { warnx("nfsdreopen: Opening '%s' failed: errno %d (%s)", ic->ic_path, errno, strerror(errno));