From d1b3ec98cf4400a98242d26a5bdc83cda03995c3 Mon Sep 17 00:00:00 2001
From: "Steinar H. Gunderson" <sesse@debian.org>
Date: Wed, 19 Jul 2006 14:06:33 +0200
Subject: [PATCH] Imported Debian patch 1.0.9-5

---
 debian/changelog                  |  15 +++
 debian/nfs-kernel-server.default  |   7 +
 debian/nfs-kernel-server.init     |  23 +++-
 debian/nfs-kernel-server.install  |   1 +
 debian/nfs-kernel-server.links    |   1 +
 debian/nfs-kernel-server.manpages |   1 +
 utils/rquotad/rquota.h            | 155 +++++++++++++++++++++
 utils/rquotad/rquota_xdr.c        | 215 ++++++++++++++++++++++++++++++
 8 files changed, 416 insertions(+), 2 deletions(-)
 create mode 100644 utils/rquotad/rquota.h
 create mode 100644 utils/rquotad/rquota_xdr.c

diff --git a/debian/changelog b/debian/changelog
index d04bcaf..d09b237 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,18 @@
+nfs-utils (1:1.0.9-5) unstable; urgency=low
+
+  * Put rpc.svcgssd back into place; removing it was obviously not what
+    upstream intended to do after all. (Closes: #378686)
+    * Add rpc.svcgssd to nfs-kernel-server.install.
+    * Add the svcgssd(8) man page, as well as the rpc.svcgssd(8) symlink.
+    * Add NEED_SVCGSSD and RPCSECGSSDOPTS options to nfs-kernel-server.default.
+    * Start and rpc.svcgssd in the nfs-kernel-server init script. Currently,
+      no autodetection is done; you'll need to enable it manually. (We can't
+      start it regardless, since it bombs out if there is no adequate nfs/*
+      entry in the keytab.)
+  * Remove obsolete RPCGSSDOPTS option from the nfs-kernel-server init script.
+
+ -- Steinar H. Gunderson <sesse@debian.org>  Wed, 19 Jul 2006 14:06:33 +0200
+
 nfs-utils (1:1.0.9-4) unstable; urgency=low
 
   * Remove versioned dependency on coreutils, as we don't use it indirectly,
diff --git a/debian/nfs-kernel-server.default b/debian/nfs-kernel-server.default
index f51f850..365f616 100644
--- a/debian/nfs-kernel-server.default
+++ b/debian/nfs-kernel-server.default
@@ -9,3 +9,10 @@ RPCNFSDPRIORITY=0
 # a fixed port here using the --port option. For more information, 
 # see rpc.mountd(8) or http://wiki.debian.org/?SecuringNFS
 RPCMOUNTDOPTS=
+
+# Do you want to start the svcgssd daemon? It is only required for Kerberos
+# exports. Valid alternatives are "yes" and "no"; the default is "no".
+NEED_SVCGSSD=
+
+# Options for rpc.svcgssd.
+RPCSVCGSSDOPTS=
diff --git a/debian/nfs-kernel-server.init b/debian/nfs-kernel-server.init
index 52913ae..81bd3f2 100644
--- a/debian/nfs-kernel-server.init
+++ b/debian/nfs-kernel-server.init
@@ -26,8 +26,7 @@ DEFAULTFILE=/etc/default/nfs-kernel-server
 RPCNFSDCOUNT=8
 RPCNFSDPRIORITY=0
 RPCMOUNTDOPTS=
-NEED_SVCGSSD=yes
-RPCGSSDOPTS=
+NEED_SVCGSSD=no
 RPCSVCGSSDOPTS=
 PROCNFSD_MOUNTPOINT=/proc/fs/nfsd
 if [ -f $DEFAULTFILE ]; then
@@ -102,6 +101,16 @@ case "$1" in
 		    RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 3"
 
 		[ -z "$ClearAddr" ] || echo "nfsd 127.0.0.1 1" >/proc/net/rpc/auth.unix.ip/channel
+	
+	        if [ "$NEED_SVCGSSD" = "yes" ]; then
+			log_progress_msg "svcgssd"
+			start-stop-daemon --start --oknodo --quiet \
+			    --exec $PREFIX/sbin/rpc.svcgssd -- $RPCSVCGSSDOPTS
+			if [ $? != 0 ]; then
+				log_end_msg $?
+				exit $?
+			fi
+		fi
 
 		log_progress_msg "mountd"
 		start-stop-daemon --start --oknodo --quiet \
@@ -127,6 +136,16 @@ case "$1" in
 		log_end_msg $?
 		exit $?
 	fi
+	        
+	if [ "$NEED_SVCGSSD" = "yes" ]; then
+		log_progress_msg "svcgssd"
+		start-stop-daemon --stop --oknodo --quiet \
+		    --name rpc.svcgssd --user 0
+		if [ $? != 0 ]; then
+			log_end_msg $?
+			exit $?
+		fi
+	fi
 
 	log_progress_msg "nfsd"
 	start-stop-daemon --stop --oknodo --quiet \
diff --git a/debian/nfs-kernel-server.install b/debian/nfs-kernel-server.install
index 341c538..e815651 100644
--- a/debian/nfs-kernel-server.install
+++ b/debian/nfs-kernel-server.install
@@ -1,6 +1,7 @@
 debian/tmp/usr/sbin/exportfs
 debian/tmp/usr/sbin/rpc.mountd
 debian/tmp/usr/sbin/rpc.nfsd
+debian/tmp/usr/sbin/rpc.svcgssd
 debian/nfs-kernel-server.default /usr/share/nfs-kernel-server/conffiles/
 debian/etc.exports /usr/share/nfs-kernel-server/conffiles/
 debian/nfs-kernel-server.default.md5sum /usr/share/nfs-kernel-server/conffiles/
diff --git a/debian/nfs-kernel-server.links b/debian/nfs-kernel-server.links
index 9013f2c..0f4d882 100644
--- a/debian/nfs-kernel-server.links
+++ b/debian/nfs-kernel-server.links
@@ -1,2 +1,3 @@
 /usr/share/man/man8/mountd.8 /usr/share/man/man8/rpc.mountd.8
 /usr/share/man/man8/nfsd.8 /usr/share/man/man8/rpc.nfsd.8
+/usr/share/man/man8/svcgssd.8 /usr/share/man/man8/rpc.svcgssd.8
diff --git a/debian/nfs-kernel-server.manpages b/debian/nfs-kernel-server.manpages
index d7c33aa..f8edbae 100644
--- a/debian/nfs-kernel-server.manpages
+++ b/debian/nfs-kernel-server.manpages
@@ -3,3 +3,4 @@ debian/tmp/usr/share/man/man7/nfsd.7
 debian/tmp/usr/share/man/man8/mountd.8
 debian/tmp/usr/share/man/man8/exportfs.8
 debian/tmp/usr/share/man/man8/nfsd.8
+debian/tmp/usr/share/man/man8/svcgssd.8
diff --git a/utils/rquotad/rquota.h b/utils/rquotad/rquota.h
new file mode 100644
index 0000000..09048f3
--- /dev/null
+++ b/utils/rquotad/rquota.h
@@ -0,0 +1,155 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#ifndef _RQUOTA_H_RPCGEN
+#define _RQUOTA_H_RPCGEN
+
+#include <rpc/rpc.h>
+
+#ifndef IXDR_GET_INT32
+#define IXDR_GET_INT32(buf) IXDR_GET_LONG((buf))
+#endif
+#ifndef IXDR_PUT_INT32
+#define IXDR_PUT_INT32(buf, v) IXDR_PUT_LONG((buf), (v))
+#endif
+#ifndef IXDR_GET_U_INT32
+#define IXDR_GET_U_INT32(buf) IXDR_GET_U_LONG((buf))
+#endif
+#ifndef IXDR_PUT_U_INT32
+#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_U_LONG((buf), (v))
+#endif
+#define RQ_PATHLEN 1024
+
+struct getquota_args {
+	char *gqa_pathp;
+	int gqa_uid;
+};
+typedef struct getquota_args getquota_args;
+#ifdef __cplusplus 
+extern "C" bool_t xdr_getquota_args(XDR *, getquota_args*);
+#elif __STDC__ 
+extern  bool_t xdr_getquota_args(XDR *, getquota_args*);
+#else /* Old Style C */ 
+bool_t xdr_getquota_args();
+#endif /* Old Style C */ 
+
+
+struct ext_getquota_args {
+	char *gqa_pathp;
+	int gqa_type;
+	int gqa_id;
+};
+typedef struct ext_getquota_args ext_getquota_args;
+#ifdef __cplusplus 
+extern "C" bool_t xdr_ext_getquota_args(XDR *, ext_getquota_args*);
+#elif __STDC__ 
+extern  bool_t xdr_ext_getquota_args(XDR *, ext_getquota_args*);
+#else /* Old Style C */ 
+bool_t xdr_ext_getquota_args();
+#endif /* Old Style C */ 
+
+
+struct rquota {
+	int rq_bsize;
+	bool_t rq_active;
+	u_int rq_bhardlimit;
+	u_int rq_bsoftlimit;
+	u_int rq_curblocks;
+	u_int rq_fhardlimit;
+	u_int rq_fsoftlimit;
+	u_int rq_curfiles;
+	u_int rq_btimeleft;
+	u_int rq_ftimeleft;
+};
+typedef struct rquota rquota;
+#ifdef __cplusplus 
+extern "C" bool_t xdr_rquota(XDR *, rquota*);
+#elif __STDC__ 
+extern  bool_t xdr_rquota(XDR *, rquota*);
+#else /* Old Style C */ 
+bool_t xdr_rquota();
+#endif /* Old Style C */ 
+
+
+enum gqr_status {
+	Q_OK = 1,
+	Q_NOQUOTA = 2,
+	Q_EPERM = 3,
+};
+typedef enum gqr_status gqr_status;
+#ifdef __cplusplus 
+extern "C" bool_t xdr_gqr_status(XDR *, gqr_status*);
+#elif __STDC__ 
+extern  bool_t xdr_gqr_status(XDR *, gqr_status*);
+#else /* Old Style C */ 
+bool_t xdr_gqr_status();
+#endif /* Old Style C */ 
+
+
+struct getquota_rslt {
+	gqr_status status;
+	union {
+		rquota gqr_rquota;
+	} getquota_rslt_u;
+};
+typedef struct getquota_rslt getquota_rslt;
+#ifdef __cplusplus 
+extern "C" bool_t xdr_getquota_rslt(XDR *, getquota_rslt*);
+#elif __STDC__ 
+extern  bool_t xdr_getquota_rslt(XDR *, getquota_rslt*);
+#else /* Old Style C */ 
+bool_t xdr_getquota_rslt();
+#endif /* Old Style C */ 
+
+
+#define RQUOTAPROG ((u_int32_t)100011)
+#define RQUOTAVERS ((u_int32_t)1)
+
+#ifdef __cplusplus
+#define RQUOTAPROC_GETQUOTA ((u_int32_t)1)
+extern "C" getquota_rslt * rquotaproc_getquota_1(getquota_args *, CLIENT *);
+extern "C" getquota_rslt * rquotaproc_getquota_1_svc(getquota_args *, struct svc_req *);
+#define RQUOTAPROC_GETACTIVEQUOTA ((u_int32_t)2)
+extern "C" getquota_rslt * rquotaproc_getactivequota_1(getquota_args *, CLIENT *);
+extern "C" getquota_rslt * rquotaproc_getactivequota_1_svc(getquota_args *, struct svc_req *);
+
+#elif __STDC__
+#define RQUOTAPROC_GETQUOTA ((u_int32_t)1)
+extern  getquota_rslt * rquotaproc_getquota_1(getquota_args *, CLIENT *);
+extern  getquota_rslt * rquotaproc_getquota_1_svc(getquota_args *, struct svc_req *);
+#define RQUOTAPROC_GETACTIVEQUOTA ((u_int32_t)2)
+extern  getquota_rslt * rquotaproc_getactivequota_1(getquota_args *, CLIENT *);
+extern  getquota_rslt * rquotaproc_getactivequota_1_svc(getquota_args *, struct svc_req *);
+
+#else /* Old Style C */ 
+#define RQUOTAPROC_GETQUOTA ((u_int32_t)1)
+extern  getquota_rslt * rquotaproc_getquota_1();
+extern  getquota_rslt * rquotaproc_getquota_1_svc();
+#define RQUOTAPROC_GETACTIVEQUOTA ((u_int32_t)2)
+extern  getquota_rslt * rquotaproc_getactivequota_1();
+extern  getquota_rslt * rquotaproc_getactivequota_1_svc();
+#endif /* Old Style C */ 
+#define EXT_RQUOTAVERS ((u_int32_t)2)
+
+#ifdef __cplusplus
+extern "C" getquota_rslt * rquotaproc_getquota_2(ext_getquota_args *, CLIENT *);
+extern "C" getquota_rslt * rquotaproc_getquota_2_svc(ext_getquota_args *, struct svc_req *);
+extern "C" getquota_rslt * rquotaproc_getactivequota_2(ext_getquota_args *, CLIENT *);
+extern "C" getquota_rslt * rquotaproc_getactivequota_2_svc(ext_getquota_args *, struct svc_req *);
+
+#elif __STDC__
+extern  getquota_rslt * rquotaproc_getquota_2(ext_getquota_args *, CLIENT *);
+extern  getquota_rslt * rquotaproc_getquota_2_svc(ext_getquota_args *, struct svc_req *);
+extern  getquota_rslt * rquotaproc_getactivequota_2(ext_getquota_args *, CLIENT *);
+extern  getquota_rslt * rquotaproc_getactivequota_2_svc(ext_getquota_args *, struct svc_req *);
+
+#else /* Old Style C */ 
+extern  getquota_rslt * rquotaproc_getquota_2();
+extern  getquota_rslt * rquotaproc_getquota_2_svc();
+extern  getquota_rslt * rquotaproc_getactivequota_2();
+extern  getquota_rslt * rquotaproc_getactivequota_2_svc();
+#endif /* Old Style C */ 
+
+#endif /* !_RQUOTA_H_RPCGEN */
diff --git a/utils/rquotad/rquota_xdr.c b/utils/rquotad/rquota_xdr.c
new file mode 100644
index 0000000..f5a28a2
--- /dev/null
+++ b/utils/rquotad/rquota_xdr.c
@@ -0,0 +1,215 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#include "rquota.h"
+
+bool_t
+xdr_getquota_args(xdrs, objp)
+	XDR *xdrs;
+	getquota_args *objp;
+{
+
+	 if (!xdr_string(xdrs, &objp->gqa_pathp, RQ_PATHLEN)) {
+		 return (FALSE);
+	 }
+	 if (!xdr_int(xdrs, &objp->gqa_uid)) {
+		 return (FALSE);
+	 }
+	return (TRUE);
+}
+
+bool_t
+xdr_ext_getquota_args(xdrs, objp)
+	XDR *xdrs;
+	ext_getquota_args *objp;
+{
+
+	 if (!xdr_string(xdrs, &objp->gqa_pathp, RQ_PATHLEN)) {
+		 return (FALSE);
+	 }
+	 if (!xdr_int(xdrs, &objp->gqa_type)) {
+		 return (FALSE);
+	 }
+	 if (!xdr_int(xdrs, &objp->gqa_id)) {
+		 return (FALSE);
+	 }
+	return (TRUE);
+}
+
+bool_t
+xdr_rquota(xdrs, objp)
+	XDR *xdrs;
+	rquota *objp;
+{
+
+
+	 if (xdrs->x_op == XDR_ENCODE) {
+		int32_t *buf = XDR_INLINE(xdrs,10 * BYTES_PER_XDR_UNIT);
+		if (buf == NULL) {
+		 if (!xdr_int(xdrs, &objp->rq_bsize)) {
+			 return (FALSE);
+		 }
+		 if (!xdr_bool(xdrs, &objp->rq_active)) {
+			 return (FALSE);
+		 }
+		 if (!xdr_u_int(xdrs, &objp->rq_bhardlimit)) {
+			 return (FALSE);
+		 }
+		 if (!xdr_u_int(xdrs, &objp->rq_bsoftlimit)) {
+			 return (FALSE);
+		 }
+		 if (!xdr_u_int(xdrs, &objp->rq_curblocks)) {
+			 return (FALSE);
+		 }
+		 if (!xdr_u_int(xdrs, &objp->rq_fhardlimit)) {
+			 return (FALSE);
+		 }
+		 if (!xdr_u_int(xdrs, &objp->rq_fsoftlimit)) {
+			 return (FALSE);
+		 }
+		 if (!xdr_u_int(xdrs, &objp->rq_curfiles)) {
+			 return (FALSE);
+		 }
+		 if (!xdr_u_int(xdrs, &objp->rq_btimeleft)) {
+			 return (FALSE);
+		 }
+		 if (!xdr_u_int(xdrs, &objp->rq_ftimeleft)) {
+			 return (FALSE);
+		 }
+
+	  }
+	  else {
+		 (void) IXDR_PUT_INT32(buf,objp->rq_bsize);
+		 (void) IXDR_PUT_BOOL(buf,objp->rq_active);
+		 (void) IXDR_PUT_U_INT32(buf,objp->rq_bhardlimit);
+		 (void) IXDR_PUT_U_INT32(buf,objp->rq_bsoftlimit);
+		 (void) IXDR_PUT_U_INT32(buf,objp->rq_curblocks);
+		 (void) IXDR_PUT_U_INT32(buf,objp->rq_fhardlimit);
+		 (void) IXDR_PUT_U_INT32(buf,objp->rq_fsoftlimit);
+		 (void) IXDR_PUT_U_INT32(buf,objp->rq_curfiles);
+		 (void) IXDR_PUT_U_INT32(buf,objp->rq_btimeleft);
+		 (void) IXDR_PUT_U_INT32(buf,objp->rq_ftimeleft);
+	  }
+
+ 	 return (TRUE);
+	} else if (xdrs->x_op == XDR_DECODE) {
+		int32_t *buf = XDR_INLINE(xdrs,10 * BYTES_PER_XDR_UNIT);
+		if (buf == NULL) {
+		 if (!xdr_int(xdrs, &objp->rq_bsize)) {
+			 return (FALSE);
+		 }
+		 if (!xdr_bool(xdrs, &objp->rq_active)) {
+			 return (FALSE);
+		 }
+		 if (!xdr_u_int(xdrs, &objp->rq_bhardlimit)) {
+			 return (FALSE);
+		 }
+		 if (!xdr_u_int(xdrs, &objp->rq_bsoftlimit)) {
+			 return (FALSE);
+		 }
+		 if (!xdr_u_int(xdrs, &objp->rq_curblocks)) {
+			 return (FALSE);
+		 }
+		 if (!xdr_u_int(xdrs, &objp->rq_fhardlimit)) {
+			 return (FALSE);
+		 }
+		 if (!xdr_u_int(xdrs, &objp->rq_fsoftlimit)) {
+			 return (FALSE);
+		 }
+		 if (!xdr_u_int(xdrs, &objp->rq_curfiles)) {
+			 return (FALSE);
+		 }
+		 if (!xdr_u_int(xdrs, &objp->rq_btimeleft)) {
+			 return (FALSE);
+		 }
+		 if (!xdr_u_int(xdrs, &objp->rq_ftimeleft)) {
+			 return (FALSE);
+		 }
+
+	  }
+	  else {
+		 objp->rq_bsize = IXDR_GET_INT32(buf);
+		 objp->rq_active = IXDR_GET_BOOL(buf);
+		 objp->rq_bhardlimit = IXDR_GET_U_INT32(buf);
+		 objp->rq_bsoftlimit = IXDR_GET_U_INT32(buf);
+		 objp->rq_curblocks = IXDR_GET_U_INT32(buf);
+		 objp->rq_fhardlimit = IXDR_GET_U_INT32(buf);
+		 objp->rq_fsoftlimit = IXDR_GET_U_INT32(buf);
+		 objp->rq_curfiles = IXDR_GET_U_INT32(buf);
+		 objp->rq_btimeleft = IXDR_GET_U_INT32(buf);
+		 objp->rq_ftimeleft = IXDR_GET_U_INT32(buf);
+	  }
+	 return(TRUE);
+	}
+
+	 if (!xdr_int(xdrs, &objp->rq_bsize)) {
+		 return (FALSE);
+	 }
+	 if (!xdr_bool(xdrs, &objp->rq_active)) {
+		 return (FALSE);
+	 }
+	 if (!xdr_u_int(xdrs, &objp->rq_bhardlimit)) {
+		 return (FALSE);
+	 }
+	 if (!xdr_u_int(xdrs, &objp->rq_bsoftlimit)) {
+		 return (FALSE);
+	 }
+	 if (!xdr_u_int(xdrs, &objp->rq_curblocks)) {
+		 return (FALSE);
+	 }
+	 if (!xdr_u_int(xdrs, &objp->rq_fhardlimit)) {
+		 return (FALSE);
+	 }
+	 if (!xdr_u_int(xdrs, &objp->rq_fsoftlimit)) {
+		 return (FALSE);
+	 }
+	 if (!xdr_u_int(xdrs, &objp->rq_curfiles)) {
+		 return (FALSE);
+	 }
+	 if (!xdr_u_int(xdrs, &objp->rq_btimeleft)) {
+		 return (FALSE);
+	 }
+	 if (!xdr_u_int(xdrs, &objp->rq_ftimeleft)) {
+		 return (FALSE);
+	 }
+	return (TRUE);
+}
+
+bool_t
+xdr_gqr_status(xdrs, objp)
+	XDR *xdrs;
+	gqr_status *objp;
+{
+
+	 if (!xdr_enum(xdrs, (enum_t *)objp)) {
+		 return (FALSE);
+	 }
+	return (TRUE);
+}
+
+bool_t
+xdr_getquota_rslt(xdrs, objp)
+	XDR *xdrs;
+	getquota_rslt *objp;
+{
+
+	 if (!xdr_gqr_status(xdrs, &objp->status)) {
+		 return (FALSE);
+	 }
+	switch (objp->status) {
+	case Q_OK:
+		 if (!xdr_rquota(xdrs, &objp->getquota_rslt_u.gqr_rquota)) {
+			 return (FALSE);
+		 }
+		break;
+	case Q_NOQUOTA:
+		break;
+	case Q_EPERM:
+		break;
+	default:
+		return (FALSE);
+	}
+	return (TRUE);
+}
-- 
2.39.5