add heimdal files

This commit is contained in:
Mario Fetka
2013-04-19 08:04:33 +02:00
parent dff9ccf8a6
commit 1c4c3cc09f
44 changed files with 6840 additions and 0 deletions

View File

@@ -0,0 +1 @@
# /etc/exports: NFS file systems being exported. See exports(5).

View File

@@ -0,0 +1,39 @@
ripped from Debian
--- nfs-utils-1.1.4/utils/mount/fstab.c
+++ nfs-utils-1.1.4/utils/mount/fstab.c
@@ -57,7 +57,7 @@ mtab_does_not_exist(void) {
return var_mtab_does_not_exist;
}
-static int
+int
mtab_is_a_symlink(void) {
get_mtab_info();
return var_mtab_is_a_symlink;
--- nfs-utils-1.1.4/utils/mount/fstab.h
+++ nfs-utils-1.1.4/utils/mount/fstab.h
@@ -7,6 +7,7 @@
#define _PATH_FSTAB "/etc/fstab"
#endif
+int mtab_is_a_symlink(void);
int mtab_is_writable(void);
int mtab_does_not_exist(void);
void reset_mtab_info(void);
--- nfs-utils-1.1.4/utils/mount/mount.c
+++ nfs-utils-1.1.4/utils/mount/mount.c
@@ -230,6 +230,13 @@ create_mtab (void) {
int flags;
mntFILE *mfp;
+ /* Avoid writing if the mtab is a symlink to /proc/mounts, since
+ that would create a file /proc/mounts in case the proc filesystem
+ is not mounted, and the fchmod below would also fail. */
+ if (mtab_is_a_symlink()) {
+ return EX_SUCCESS;
+ }
+
lock_mtab();
mfp = nfs_setmntent (MOUNTED, "a+");

View File

@@ -0,0 +1,69 @@
this is kind of hacky, but automake doesn't make this easy
for us atm, so hack away :(
(recent autotools will always add $(CFLAGS)/etc... to the compile)
--- a/tools/locktest/Makefile.am
+++ b/tools/locktest/Makefile.am
@@ -1,12 +1,11 @@
## Process this file with automake to produce Makefile.in
CC=$(CC_FOR_BUILD)
-LIBTOOL = @LIBTOOL@ --tag=CC
+CFLAGS=$(CFLAGS_FOR_BUILD)
+CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
+LDFLAGS=$(LDFLAGS_FOR_BUILD)
noinst_PROGRAMS = testlk
testlk_SOURCES = testlk.c
-testlk_CFLAGS=$(CFLAGS_FOR_BUILD)
-testlk_CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
-testlk_LDFLAGS=$(LDFLAGS_FOR_BUILD)
MAINTAINERCLEANFILES = Makefile.in
--- a/tools/rpcdebug/Makefile.am
+++ b/tools/rpcdebug/Makefile.am
@@ -1,15 +1,14 @@
## Process this file with automake to produce Makefile.in
CC=$(CC_FOR_BUILD)
-LIBTOOL = @LIBTOOL@ --tag=CC
+CFLAGS=$(CFLAGS_FOR_BUILD)
+CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
+LDFLAGS=$(LDFLAGS_FOR_BUILD)
man8_MANS = rpcdebug.man
EXTRA_DIST = $(man8_MANS)
sbin_PROGRAMS = rpcdebug
rpcdebug_SOURCES = rpcdebug.c
-rpcdebug_CFLAGS=$(CFLAGS_FOR_BUILD)
-rpcdebug_CPPFLAGS=$(CPPFLAGS_FOR_BUILD) -I$(top_srcdir)/support/include
-rpcdebug_LDFLAGS=$(LDFLAGS_FOR_BUILD)
MAINTAINERCLEANFILES = Makefile.in
--- a/tools/rpcgen/Makefile.am
+++ b/tools/rpcgen/Makefile.am
@@ -1,7 +1,9 @@
## Process this file with automake to produce Makefile.in
CC=$(CC_FOR_BUILD)
-LIBTOOL = @LIBTOOL@ --tag=CC
+CFLAGS=$(CFLAGS_FOR_BUILD)
+CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
+LDFLAGS=$(LDFLAGS_FOR_BUILD)
noinst_PROGRAMS = rpcgen
rpcgen_SOURCES = rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c \
@@ -9,10 +11,6 @@
rpc_util.c rpc_sample.c rpc_output.h rpc_parse.h \
rpc_scan.h rpc_util.h
-rpcgen_CFLAGS=$(CFLAGS_FOR_BUILD)
-rpcgen_CPPLAGS=$(CPPFLAGS_FOR_BUILD)
-rpcgen_LDFLAGS=$(LDFLAGS_FOR_BUILD)
-rpcgen_LDADD=$(LIBTIRPC)
MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = rpcgen.new.1

View File

@@ -0,0 +1,180 @@
--- nfs-utils-1.2.3.dist/aclocal/rpcsec_vers.m4.orig 2010-09-28 14:24:16.000000000 +0200
+++ nfs-utils-1.2.3.dist/aclocal/rpcsec_vers.m4 2010-10-03 14:53:06.379424854 +0200
@@ -1,7 +1,10 @@
dnl Checks librpcsec version
AC_DEFUN([AC_RPCSEC_VERSION], [
- PKG_CHECK_MODULES([GSSGLUE], [libgssglue >= 0.3])
+ dnl libgssglue is needed only for MIT Kerberos
+ if test "$gssapi_lib" = gssapi_krb5; then
+ PKG_CHECK_MODULES([GSSGLUE], [libgssglue >= 0.3])
+ fi
dnl TI-RPC replaces librpcsecgss
if test "$enable_tirpc" = no; then
--- nfs-utils-1.2.3.dist/aclocal/kerberos5.m4~ 2010-09-28 14:24:16.000000000 +0200
+++ nfs-utils-1.2.3.dist/aclocal/kerberos5.m4 2010-10-03 14:13:17.274424855 +0200
@@ -32,14 +32,14 @@
fi
if test "$K5CONFIG" != ""; then
KRBCFLAGS=`$K5CONFIG --cflags`
- KRBLIBS=`$K5CONFIG --libs`
- K5VERS=`$K5CONFIG --version | head -n 1 | awk '{split($(4),v,"."); if (v@<:@"3"@:>@ == "") v@<:@"3"@:>@ = "0"; print v@<:@"1"@:>@v@<:@"2"@:>@v@<:@"3"@:>@ }'`
+ KRBLIBS=`$K5CONFIG --libs gssapi`
AC_DEFINE_UNQUOTED(KRB5_VERSION, $K5VERS, [Define this as the Kerberos version number])
if test -f $dir/include/gssapi/gssapi_krb5.h -a \
\( -f $dir/lib/libgssapi_krb5.a -o \
-f $dir/lib64/libgssapi_krb5.a -o \
-f $dir/lib64/libgssapi_krb5.so -o \
-f $dir/lib/libgssapi_krb5.so \) ; then
+ K5VERS=`$K5CONFIG --version | head -n 1 | awk '{split($(4),v,"."); if (v@<:@"3"@:>@ == "") v@<:@"3"@:>@ = "0"; print v@<:@"1"@:>@v@<:@"2"@:>@v@<:@"3"@:>@ }'`
AC_DEFINE(HAVE_KRB5, 1, [Define this if you have MIT Kerberos libraries])
KRBDIR="$dir"
dnl If we are using MIT K5 1.3.1 and before, we *MUST* use the
@@ -56,7 +56,11 @@
dnl of Heimdal Kerberos on SuSe
elif test \( -f $dir/include/heim_err.h -o\
-f $dir/include/heimdal/heim_err.h \) -a \
- -f $dir/lib/libroken.a; then
+ \( -f $dir/lib/libroken.a -o \
+ -f $dir/lib64/libroken.a -o \
+ -f $dir/lib64/libroken.so -o \
+ -f $dir/lib/libroken.so \) ; then
+ K5VERS=`$K5CONFIG --version | head -n 1 | awk '{split($(2),v,"."); if (v@<:@"3"@:>@ == "") v@<:@"3"@:>@ = "0"; print v@<:@"1"@:>@v@<:@"2"@:>@v@<:@"3"@:>@ }'`
AC_DEFINE(HAVE_HEIMDAL, 1, [Define this if you have Heimdal Kerberos libraries])
KRBDIR="$dir"
gssapi_lib=gssapi
--- nfs-utils-1.2.3.dist/utils/gssd/context_lucid.c.orig 2010-09-28 14:24:16.000000000 +0200
+++ nfs-utils-1.2.3.dist/utils/gssd/context_lucid.c 2010-10-03 14:31:31.150424854 +0200
@@ -267,8 +267,13 @@
int retcode = 0;
printerr(2, "DEBUG: %s: lucid version!\n", __FUNCTION__);
+#ifdef HAVE_HEIMDAL
+ maj_stat = gss_krb5_export_lucid_sec_context(&min_stat, &ctx,
+ 1, &return_ctx);
+#else
maj_stat = gss_export_lucid_sec_context(&min_stat, &ctx,
1, &return_ctx);
+#endif
if (maj_stat != GSS_S_COMPLETE) {
pgsserr("gss_export_lucid_sec_context",
maj_stat, min_stat, &krb5oid);
@@ -303,7 +308,11 @@
else
retcode = prepare_krb5_rfc4121_buffer(lctx, buf, endtime);
+#ifdef HAVE_HEIMDAL
+ maj_stat = gss_krb5_free_lucid_sec_context(&min_stat, return_ctx);
+#else
maj_stat = gss_free_lucid_sec_context(&min_stat, ctx, return_ctx);
+#endif
if (maj_stat != GSS_S_COMPLETE) {
pgsserr("gss_export_lucid_sec_context",
maj_stat, min_stat, &krb5oid);
--- nfs-utils-1.2.3.dist/utils/gssd/krb5_util.c.orig 2010-09-28 14:24:16.000000000 +0200
+++ nfs-utils-1.2.3.dist/utils/gssd/krb5_util.c 2010-10-03 14:33:07.992424854 +0200
@@ -115,7 +115,7 @@
#include <errno.h>
#include <time.h>
#include <gssapi/gssapi.h>
-#ifdef USE_PRIVATE_KRB5_FUNCTIONS
+#ifdef HAVE_HEIMDAL
#include <gssapi/gssapi_krb5.h>
#endif
#include <krb5.h>
@@ -927,9 +927,37 @@
{
krb5_error_code ret;
krb5_creds creds;
- krb5_cc_cursor cur;
int found = 0;
+#ifdef HAVE_HEIMDAL
+ krb5_creds pattern;
+ krb5_const_realm client_realm;
+
+ krb5_cc_clear_mcred(&pattern);
+
+ client_realm = krb5_principal_get_realm (context, principal);
+
+ ret = krb5_make_principal (context, &pattern.server,
+ client_realm, KRB5_TGS_NAME, client_realm,
+ NULL);
+ if (ret)
+ krb5_err (context, 1, ret, "krb5_make_principal");
+ pattern.client = principal;
+
+ ret = krb5_cc_retrieve_cred (context, ccache, 0, &pattern, &creds);
+ krb5_free_principal (context, pattern.server);
+ if (ret) {
+ if (ret == KRB5_CC_END)
+ return 1;
+ krb5_err (context, 1, ret, "krb5_cc_retrieve_cred");
+ }
+
+ found = creds.times.endtime > time(NULL);
+
+ krb5_free_cred_contents (context, &creds);
+#else
+ krb5_cc_cursor cur;
+
ret = krb5_cc_start_seq_get(context, ccache, &cur);
if (ret)
return 0;
@@ -949,6 +977,7 @@
krb5_free_cred_contents(context, &creds);
}
krb5_cc_end_seq_get(context, ccache, &cur);
+#endif
return found;
}
@@ -995,6 +1024,9 @@
}
krb5_free_principal(context, principal);
err_princ:
+#ifdef HAVE_HEIMDAL
+#define KRB5_TC_OPENCLOSE 0x00000001
+#endif
krb5_cc_set_flags(context, ccache, KRB5_TC_OPENCLOSE);
krb5_cc_close(context, ccache);
err_cache:
@@ -1316,12 +1316,21 @@
* If we failed for any reason to produce global
* list of supported enctypes, use local default here.
*/
+#ifdef HAVE_HEIMDAL
+ if (krb5_enctypes == NULL || limit_to_legacy_enctypes)
+ maj_stat = gss_krb5_set_allowable_enctypes(&min_stat, credh,
+ num_enctypes, enctypes);
+ else
+ maj_stat = gss_krb5_set_allowable_enctypes(&min_stat, credh,
+ num_krb5_enctypes, krb5_enctypes);
+#else
if (krb5_enctypes == NULL || limit_to_legacy_enctypes)
maj_stat = gss_set_allowable_enctypes(&min_stat, credh,
&krb5oid, num_enctypes, enctypes);
else
maj_stat = gss_set_allowable_enctypes(&min_stat, credh,
&krb5oid, num_krb5_enctypes, krb5_enctypes);
+#endif
if (maj_stat != GSS_S_COMPLETE) {
pgsserr("gss_set_allowable_enctypes",
--- nfs-utils-1.2.4/utils/gssd/svcgssd_krb5.c~ 2011-06-30 15:00:42.000000000 +0200
+++ nfs-utils-1.2.4/utils/gssd/svcgssd_krb5.c 2011-08-03 12:40:53.865782009 +0200
@@ -186,8 +186,13 @@
num_enctypes = default_num_enctypes;
}
+#ifdef HAVE_HEIMDAL
+ maj_stat = gss_krb5_set_allowable_enctypes(&min_stat, gssd_creds,
+ num_enctypes, enctypes);
+#else
maj_stat = gss_set_allowable_enctypes(&min_stat, gssd_creds,
&krb5oid, num_enctypes, enctypes);
+#endif
if (maj_stat != GSS_S_COMPLETE) {
printerr(1, "WARNING: gss_set_allowable_enctypes failed\n");
pgsserr("svcgssd_limit_krb5_enctypes: gss_set_allowable_enctypes",

View File

@@ -0,0 +1,50 @@
https://bugs.gentoo.org/459200
From 2d9fb08c588970b842ce2a609088079181e6aafb Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Sun, 24 Mar 2013 17:41:19 -0400
Subject: [PATCH [nfs-utils]] check for libio.h availability
On some systems (like uClibc), there isn't a libio.h header. But it
isn't also needed on them. So check for the header first.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
configure.ac | 2 +-
support/include/sockaddr.h | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index f461219..cc7f3b4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -358,7 +358,7 @@ AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h \
stdlib.h string.h sys/file.h sys/ioctl.h sys/mount.h \
sys/param.h sys/socket.h sys/time.h sys/vfs.h \
syslog.h unistd.h com_err.h et/com_err.h \
- ifaddrs.h nfs-plugin.h])
+ ifaddrs.h nfs-plugin.h libio.h])
dnl *************************************************************
dnl Checks for typedefs, structures, and compiler characteristics
diff --git a/support/include/sockaddr.h b/support/include/sockaddr.h
index 72766db..a1c30f9 100644
--- a/support/include/sockaddr.h
+++ b/support/include/sockaddr.h
@@ -20,7 +20,13 @@
#ifndef NFS_UTILS_SOCKADDR_H
#define NFS_UTILS_SOCKADDR_H
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_LIBIO_H
#include <libio.h>
+#endif
#include <stdbool.h>
#include <sys/socket.h>
#include <netinet/in.h>
--
1.8.1.2

View File

@@ -0,0 +1,287 @@
From b0e3dc0c1332884a82f509f98434abd78358c7ed Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Sun, 24 Mar 2013 15:59:12 -0400
Subject: [PATCH] nfsiostat: make it work w/python3
Simple fixes here to work with python 2 & 3:
- use print() everywhere
- dict.iteritems() -> dict.items()
- file() -> open()
- sys.maxint -> sys.maxsize
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
tools/nfs-iostat/nfs-iostat.py | 130 +++++++++++++++++++++--------------------
1 file changed, 66 insertions(+), 64 deletions(-)
diff --git a/tools/nfs-iostat/nfs-iostat.py b/tools/nfs-iostat/nfs-iostat.py
index d909632..dfbef87 100644
--- a/tools/nfs-iostat/nfs-iostat.py
+++ b/tools/nfs-iostat/nfs-iostat.py
@@ -3,6 +3,8 @@
"""Emulate iostat for NFS mount points using /proc/self/mountstats
"""
+from __future__ import print_function
+
__copyright__ = """
Copyright (C) 2005, Chuck Lever <cel@netapp.com>
@@ -201,9 +203,9 @@ class DeviceData:
result = DeviceData()
# copy self into result
- for key, value in self.__nfs_data.iteritems():
+ for key, value in self.__nfs_data.items():
result.__nfs_data[key] = value
- for key, value in self.__rpc_data.iteritems():
+ for key, value in self.__rpc_data.items():
result.__rpc_data[key] = value
# compute the difference of each item in the list
@@ -233,9 +235,9 @@ class DeviceData:
client_bytes_read = float(nfs_stats['serverreadbytes'] - nfs_stats['directreadbytes'])
ratio = ((app_bytes_read - client_bytes_read) * 100) / app_bytes_read
- print
- print 'app bytes: %f client bytes %f' % (app_bytes_read, client_bytes_read)
- print 'Data cache hit ratio: %4.2f%%' % ratio
+ print()
+ print('app bytes: %f client bytes %f' % (app_bytes_read, client_bytes_read))
+ print('Data cache hit ratio: %4.2f%%' % ratio)
def __print_attr_cache_stats(self, sample_time):
"""Print attribute cache efficiency stats
@@ -255,13 +257,13 @@ class DeviceData:
data_invalidates = float(nfs_stats['datainvalidates'])
attr_invalidates = float(nfs_stats['attrinvalidates'])
- print
- print '%d inode revalidations, hitting in cache %4.2f%% of the time' % \
- (revalidates, ratio)
- print '%d open operations (mandatory GETATTR requests)' % opens
+ print()
+ print('%d inode revalidations, hitting in cache %4.2f%% of the time' % \
+ (revalidates, ratio))
+ print('%d open operations (mandatory GETATTR requests)' % opens)
if getattr_ops != 0:
- print '%4.2f%% of GETATTRs resulted in data cache invalidations' % \
- ((data_invalidates * 100) / getattr_ops)
+ print('%4.2f%% of GETATTRs resulted in data cache invalidations' % \
+ ((data_invalidates * 100) / getattr_ops))
def __print_dir_cache_stats(self, sample_time):
"""Print directory stats
@@ -277,13 +279,13 @@ class DeviceData:
lookups = nfs_stats['vfslookup']
getdents = nfs_stats['vfsreaddir']
- print
- print '%d open operations (pathname lookups)' % opens
- print '%d dentry revalidates and %d vfs lookup requests' % \
- (dentry_revals, lookups),
- print 'resulted in %d LOOKUPs on the wire' % lookup_ops
- print '%d vfs getdents calls resulted in %d READDIRs on the wire' % \
- (getdents, readdir_ops)
+ print()
+ print('%d open operations (pathname lookups)' % opens)
+ print('%d dentry revalidates and %d vfs lookup requests' % \
+ (dentry_revals, lookups))
+ print('resulted in %d LOOKUPs on the wire' % lookup_ops)
+ print('%d vfs getdents calls resulted in %d READDIRs on the wire' % \
+ (getdents, readdir_ops))
def __print_page_stats(self, sample_time):
"""Print page cache stats
@@ -297,33 +299,33 @@ class DeviceData:
vfswritepages = nfs_stats['vfswritepages']
pages_written = nfs_stats['writepages']
- print
- print '%d nfs_readpage() calls read %d pages' % \
- (vfsreadpage, vfsreadpage)
- print '%d nfs_readpages() calls read %d pages' % \
- (vfsreadpages, pages_read - vfsreadpage),
+ print()
+ print('%d nfs_readpage() calls read %d pages' % \
+ (vfsreadpage, vfsreadpage))
+ print('%d nfs_readpages() calls read %d pages' % \
+ (vfsreadpages, pages_read - vfsreadpage))
if vfsreadpages != 0:
- print '(%.1f pages per call)' % \
- (float(pages_read - vfsreadpage) / vfsreadpages)
+ print('(%.1f pages per call)' % \
+ (float(pages_read - vfsreadpage) / vfsreadpages))
else:
- print
-
- print
- print '%d nfs_updatepage() calls' % nfs_stats['vfsupdatepage']
- print '%d nfs_writepage() calls wrote %d pages' % \
- (vfswritepage, vfswritepage)
- print '%d nfs_writepages() calls wrote %d pages' % \
- (vfswritepages, pages_written - vfswritepage),
+ print()
+
+ print()
+ print('%d nfs_updatepage() calls' % nfs_stats['vfsupdatepage'])
+ print('%d nfs_writepage() calls wrote %d pages' % \
+ (vfswritepage, vfswritepage))
+ print('%d nfs_writepages() calls wrote %d pages' % \
+ (vfswritepages, pages_written - vfswritepage))
if (vfswritepages) != 0:
- print '(%.1f pages per call)' % \
- (float(pages_written - vfswritepage) / vfswritepages)
+ print('(%.1f pages per call)' % \
+ (float(pages_written - vfswritepage) / vfswritepages))
else:
- print
+ print()
congestionwaits = nfs_stats['congestionwait']
if congestionwaits != 0:
- print
- print '%d congestion waits' % congestionwaits
+ print()
+ print('%d congestion waits' % congestionwaits)
def __print_rpc_op_stats(self, op, sample_time):
"""Print generic stats for one RPC op
@@ -351,15 +353,15 @@ class DeviceData:
exe_per_op = 0.0
op += ':'
- print '%s' % op.lower().ljust(15),
- print ' ops/s\t\t kB/s\t\t kB/op\t\tretrans\t\tavg RTT (ms)\tavg exe (ms)'
+ print('%s' % op.lower().ljust(15))
+ print(' ops/s\t\t kB/s\t\t kB/op\t\tretrans\t\tavg RTT (ms)\tavg exe (ms)')
- print '\t\t%7.3f' % (ops / sample_time),
- print '\t%7.3f' % (kilobytes / sample_time),
- print '\t%7.3f' % kb_per_op,
- print ' %7d (%3.1f%%)' % (retrans, retrans_percent),
- print '\t%7.3f' % rtt_per_op,
- print '\t%7.3f' % exe_per_op
+ print('\t\t%7.3f' % (ops / sample_time))
+ print('\t%7.3f' % (kilobytes / sample_time))
+ print('\t%7.3f' % kb_per_op)
+ print(' %7d (%3.1f%%)' % (retrans, retrans_percent))
+ print('\t%7.3f' % rtt_per_op)
+ print('\t%7.3f' % exe_per_op)
def ops(self, sample_time):
sends = float(self.__rpc_data['rpcsends'])
@@ -384,14 +386,14 @@ class DeviceData:
else:
backlog = 0.0
- print
- print '%s mounted on %s:' % \
- (self.__nfs_data['export'], self.__nfs_data['mountpoint'])
- print
+ print()
+ print('%s mounted on %s:' % \
+ (self.__nfs_data['export'], self.__nfs_data['mountpoint']))
+ print()
- print ' op/s\t\trpc bklog'
- print '%7.2f' % (sends / sample_time),
- print '\t%7.2f' % backlog
+ print(' op/s\t\trpc bklog')
+ print('%7.2f' % (sends / sample_time))
+ print('\t%7.2f' % backlog)
if which == 0:
self.__print_rpc_op_stats('READ', sample_time)
@@ -424,7 +426,7 @@ def parse_stats_file(filename):
ms_dict = dict()
key = ''
- f = file(filename)
+ f = open(filename)
for line in f.readlines():
words = line.split()
if len(words) == 0:
@@ -494,7 +496,7 @@ def list_nfs_mounts(givenlist, mountstats):
if stats.is_nfs_mountpoint():
list += [device]
else:
- for device, descr in mountstats.iteritems():
+ for device, descr in mountstats.items():
stats = DeviceData()
stats.parse_stats(descr)
if stats.is_nfs_mountpoint():
@@ -527,7 +529,7 @@ client are listed.
usage="usage: %prog [ <interval> [ <count> ] ] [ <options> ] [ <mount point> ]",
description=mydescription,
version='version %s' % Iostats_version)
- parser.set_defaults(which=0, sort=False, list=sys.maxint)
+ parser.set_defaults(which=0, sort=False, list=sys.maxsize)
statgroup = OptionGroup(parser, "Statistics Options",
'File I/O is displayed unless one of the following is specified:')
@@ -572,29 +574,29 @@ client are listed.
try:
interval = int(arg)
except:
- print 'Illegal <interval> value %s' % arg
+ print('Illegal <interval> value %s' % arg)
return
if interval > 0:
interval_seen = True
else:
- print 'Illegal <interval> value %s' % arg
+ print('Illegal <interval> value %s' % arg)
return
elif not count_seen:
try:
count = int(arg)
except:
- print 'Ilegal <count> value %s' % arg
+ print('Ilegal <count> value %s' % arg)
return
if count > 0:
count_seen = True
else:
- print 'Illegal <count> value %s' % arg
+ print('Illegal <count> value %s' % arg)
return
# make certain devices contains only NFS mount points
devices = list_nfs_mounts(origdevices, mountstats)
if len(devices) == 0:
- print 'No NFS mount points were found'
+ print('No NFS mount points were found')
return
@@ -616,7 +618,7 @@ client are listed.
# we need to recheck the devices list when reparsing
devices = list_nfs_mounts(origdevices,mountstats)
if len(devices) == 0:
- print 'No NFS mount points were found'
+ print('No NFS mount points were found')
return
count -= 1
else:
@@ -630,7 +632,7 @@ client are listed.
# we need to recheck the devices list when reparsing
devices = list_nfs_mounts(origdevices,mountstats)
if len(devices) == 0:
- print 'No NFS mount points were found'
+ print('No NFS mount points were found')
return
#
@@ -641,7 +643,7 @@ prog = os.path.basename(sys.argv[0])
try:
iostat_command(prog)
except KeyboardInterrupt:
- print 'Caught ^C... exiting'
+ print('Caught ^C... exiting')
sys.exit(1)
sys.exit(0)
--
1.8.1.2

View File

@@ -0,0 +1,38 @@
# /etc/conf.d/nfs
# If you wish to set the port numbers for lockd,
# please see /etc/sysctl.conf
# Optional services to include in default `/etc/init.d/nfs start`
# For NFSv4 users, you'll want to add "rpc.idmapd" here.
NFS_NEEDED_SERVICES=""
# Number of servers to be started up by default
OPTS_RPC_NFSD="8"
# Options to pass to rpc.mountd
# ex. OPTS_RPC_MOUNTD="-p 32767"
OPTS_RPC_MOUNTD=""
# Options to pass to rpc.statd
# ex. OPTS_RPC_STATD="-p 32765 -o 32766"
OPTS_RPC_STATD=""
# Options to pass to rpc.idmapd
OPTS_RPC_IDMAPD=""
# Options to pass to rpc.gssd
OPTS_RPC_GSSD=""
# Options to pass to rpc.svcgssd
OPTS_RPC_SVCGSSD=""
# Options to pass to rpc.rquotad (requires sys-fs/quota)
OPTS_RPC_RQUOTAD=""
# Timeout (in seconds) for exportfs
EXPORTFS_TIMEOUT=30
# Options to set in the nfsd filesystem (/proc/fs/nfsd/).
# Format is <option>=<value>. Multiple options are allowed.
#OPTS_NFSD="nfsv4leasetime=30 max_block_size=4096"

163
net-fs/nfs-utils/files/nfs.initd Executable file
View File

@@ -0,0 +1,163 @@
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-fs/nfs-utils/files/nfs.initd,v 1.27 2013/03/24 19:37:22 vapier Exp $
extra_started_commands="reload"
# This variable is used for controlling whether or not to run exportfs -ua;
# see stop() for more information
restarting=no
# The binary locations
exportfs=/usr/sbin/exportfs
mountd=/usr/sbin/rpc.mountd
nfsd=/usr/sbin/rpc.nfsd
smnotify=/usr/sbin/sm-notify
depend() {
local myneed=""
# XXX: no way to detect NFSv4 is desired and so need rpc.idmapd
myneed="${myneed} $(
awk '!/^[[:space:]]*#/ {
# clear the path to avoid spurious matches
$1 = "";
if ($0 ~ /[(][^)]*sec=(krb|spkm)[^)]*[)]/) {
print "rpc.svcgssd"
exit 0
}
}' /etc/exports /etc/exports.d/*.exports 2>/dev/null
)"
config /etc/exports /etc/exports.d/*.exports
need portmap rpc.statd ${myneed} ${NFS_NEEDED_SERVICES}
use ypbind net dns rpc.rquotad rpc.idmapd rpc.svcgssd
after quota
}
mkdir_nfsdirs() {
local d
for d in rpc_pipefs v4recovery v4root ; do
d="/var/lib/nfs/${d}"
[ ! -d "${d}" ] && mkdir -p "${d}"
done
}
waitfor_exportfs() {
local pid=$1
( sleep ${EXPORTFS_TIMEOUT:-30}; kill -9 ${pid} 2>/dev/null ) &
wait $1
}
mount_nfsd() {
if [ -e /proc/modules ] ; then
# Make sure nfs support is loaded in the kernel #64709
if ! grep -qs nfsd /proc/filesystems ; then
modprobe -q nfsd
fi
# Restart idmapd if needed #220747
if grep -qs nfsd /proc/modules ; then
killall -q -HUP rpc.idmapd
fi
fi
# This is the new "kernel 2.6 way" to handle the exports file
if grep -qs nfsd /proc/filesystems ; then
if ! grep -qs "nfsd /proc/fs/nfsd" /proc/mounts ; then
ebegin "Mounting nfsd filesystem in /proc"
mount -t nfsd -o nodev,noexec,nosuid nfsd /proc/fs/nfsd
eend $?
fi
local o
for o in ${OPTS_NFSD} ; do
echo "${o#*=}" > "/proc/fs/nfsd/${o%%=*}"
done
fi
}
start_it() {
ebegin "Starting NFS $1"
shift
"$@"
eend $?
ret=$((ret + $?))
}
start() {
mount_nfsd
mkdir_nfsdirs
# Exportfs likes to hang if networking isn't working.
# If that's the case, then try to kill it so the
# bootup process can continue.
if grep -qs '^[[:space:]]*/' /etc/exports /etc/exports.d/*.exports ; then
ebegin "Exporting NFS directories"
${exportfs} -r &
waitfor_exportfs $!
eend $?
fi
local ret=0
start_it mountd ${mountd} ${OPTS_RPC_MOUNTD}
start_it daemon ${nfsd} ${OPTS_RPC_NFSD}
[ -x "${smnotify}" ] && start_it smnotify ${smnotify} ${OPTS_SMNOTIFY}
return ${ret}
}
stop() {
local ret=0
ebegin "Stopping NFS mountd"
start-stop-daemon --stop --exec ${mountd}
eend $?
ret=$((ret + $?))
# nfsd sets its process name to [nfsd] so don't look for $nfsd
ebegin "Stopping NFS daemon"
start-stop-daemon --stop --name nfsd --user root --signal 2
eend $?
ret=$((ret + $?))
# in case things don't work out ... #228127
rpc.nfsd 0
# When restarting the NFS server, running "exportfs -ua" probably
# isn't what the user wants. Running it causes all entries listed
# in xtab to be removed from the kernel export tables, and the
# xtab file is cleared. This effectively shuts down all NFS
# activity, leaving all clients holding stale NFS filehandles,
# *even* when the NFS server has restarted.
#
# That's what you would want if you were shutting down the NFS
# server for good, or for a long period of time, but not when the
# NFS server will be running again in short order. In this case,
# then "exportfs -r" will reread the xtab, and all the current
# clients will be able to resume NFS activity, *without* needing
# to umount/(re)mount the filesystem.
if [ "${restarting}" = no -o "${RC_CMD}" = "restart" ] ; then
ebegin "Unexporting NFS directories"
# Exportfs likes to hang if networking isn't working.
# If that's the case, then try to kill it so the
# shutdown process can continue.
${exportfs} -ua &
waitfor_exportfs $!
eend $?
fi
return ${ret}
}
reload() {
# Exportfs likes to hang if networking isn't working.
# If that's the case, then try to kill it so the
# bootup process can continue.
ebegin "Reloading /etc/exports"
${exportfs} -r 1>&2 &
waitfor_exportfs $!
eend $?
}
restart() {
# See long comment in stop() regarding "restarting" and exportfs -ua
restarting=yes
svc_stop
svc_start
}

View File

@@ -0,0 +1,7 @@
# You will need to set the dependencies in the nfsmount script to match
# the network configuration tools you are using. This should be done in
# this file by following the examples below, and not by changing the
# service script itself. See /etc/conf.d/netmount for more examples.
#
# This is a safe default.
rc_after="net"

View File

@@ -0,0 +1,48 @@
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-fs/nfs-utils/files/nfsmount.initd,v 1.15 2013/03/24 20:29:48 vapier Exp $
[ -e /etc/conf.d/nfs ] && . /etc/conf.d/nfs
depend() {
local myneed=""
if [ -e /etc/fstab ] ; then
myneed="${myneed} $(
awk '!/^[[:space:]]*#/ && ($3 == "nfs" || $3 == "nfs4") {
if ($3 == "nfs4")
idmapd = "rpc.idmapd"
if ($4 ~ /sec=(krb|spkm)/)
gssd = "rpc.gssd"
}
END { print idmapd " " gssd }
' /etc/fstab
)"
fi
config /etc/fstab
need portmap rpc.statd ${myneed}
use ypbind dns rpc.idmapd rpc.gssd
}
start() {
if [ -x /usr/sbin/sm-notify ] ; then
ebegin "Starting NFS sm-notify"
/usr/sbin/sm-notify ${OPTS_SMNOTIFY}
eend $?
fi
# Make sure nfs support is loaded in the kernel #64709
if [ -e /proc/modules ] && ! grep -qs 'nfs$' /proc/filesystems ; then
modprobe -q nfs
fi
ebegin "Mounting NFS filesystems"
mount -a -t nfs,nfs4
eend $?
}
stop() {
ebegin "Unmounting NFS filesystems"
umount -a -t nfs,nfs4
eend $?
}

View File

@@ -0,0 +1,24 @@
#!/sbin/runscript
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-fs/nfs-utils/files/rpc.gssd.initd,v 1.11 2008/10/26 09:02:47 vapier Exp $
[ -e /etc/conf.d/nfs ] && . /etc/conf.d/nfs
depend() {
use ypbind net
need portmap rpc.pipefs
after quota
}
start() {
ebegin "Starting gssd"
start-stop-daemon --start --exec /usr/sbin/rpc.gssd -- ${OPTS_RPC_GSSD}
eend $?
}
stop() {
ebegin "Stopping gssd"
start-stop-daemon --stop --exec /usr/sbin/rpc.gssd
eend $?
}

View File

@@ -0,0 +1,26 @@
#!/sbin/runscript
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-fs/nfs-utils/files/rpc.idmapd.initd,v 1.8 2009/03/14 18:43:18 vapier Exp $
[ -e /etc/conf.d/nfs ] && . /etc/conf.d/nfs
rpc_bin=/usr/sbin/rpc.idmapd
depend() {
use ypbind net
need portmap rpc.pipefs
after quota
}
start() {
ebegin "Starting idmapd"
${rpc_bin} ${OPTS_RPC_IDMAPD}
eend $? "make sure DNOTIFY support is enabled ..."
}
stop() {
ebegin "Stopping idmapd"
start-stop-daemon --stop --exec ${rpc_bin}
eend $?
}

View File

@@ -0,0 +1,25 @@
#!/sbin/runscript
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-fs/nfs-utils/files/rpc.pipefs.initd,v 1.2 2011/06/19 23:04:36 vapier Exp $
mount_pipefs() {
local fstype=rpc_pipefs mntpoint=/var/lib/nfs/rpc_pipefs
# if things are already mounted, nothing to do
mountinfo -q ${mntpoint} && return 0
# if rpc_pipefs is not available, try to load sunrpc for it #219566
grep -qs ${fstype} /proc/filesystems || modprobe -q sunrpc
# if still not available, the `mount` will issue an error for the user
# now just do it for kicks
mkdir -p ${mntpoint}
mount -t ${fstype} ${fstype} ${mntpoint}
}
start() {
ebegin "Setting up RPC pipefs"
mount_pipefs
eend $? "make sure you have NFS/SUNRPC enabled in your kernel"
}

View File

@@ -0,0 +1,33 @@
#!/sbin/runscript
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-fs/nfs-utils/files/rpc.statd.initd,v 1.7 2009/01/31 22:16:11 vapier Exp $
[ -e /etc/conf.d/nfs ] && . /etc/conf.d/nfs
rpc_bin=/sbin/rpc.statd
rpc_pid=/var/run/rpc.statd.pid
depend() {
use ypbind net
need portmap
after quota
}
start() {
# Don't start rpc.statd if already started by someone else ...
# Don't try and kill it if it's already dead ...
if killall -q -0 ${rpc_bin} ; then
return 0
fi
ebegin "Starting NFS statd"
start-stop-daemon --start --exec ${rpc_bin} -- --no-notify ${OPTS_RPC_STATD}
eend $?
}
stop() {
ebegin "Stopping NFS statd"
start-stop-daemon --stop --exec ${rpc_bin} --pidfile /var/run/rpc.statd.pid
eend $?
}

View File

@@ -0,0 +1,24 @@
#!/sbin/runscript
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-fs/nfs-utils/files/rpc.svcgssd.initd,v 1.5 2008/10/26 09:02:47 vapier Exp $
[ -e /etc/conf.d/nfs ] && . /etc/conf.d/nfs
depend() {
use ypbind net
need portmap rpc.pipefs
after quota
}
start() {
ebegin "Starting svcgssd"
start-stop-daemon --start --exec /usr/sbin/rpc.svcgssd -- ${OPTS_RPC_SVCGSSD}
eend $?
}
stop() {
ebegin "Stopping svcgssd"
start-stop-daemon --stop --exec /usr/sbin/rpc.svcgssd
eend $?
}