├── .gitignore ├── COPYING ├── INSTALL ├── Makefile.am ├── NEWS ├── README ├── aclocal ├── bsdsignals.m4 ├── ipv6.m4 ├── kerberos5.m4 ├── keyutils.m4 ├── libblkid.m4 ├── libcap.m4 ├── libevent.m4 ├── libnfsidmap.m4 ├── libpthread.m4 ├── libsqlite3.m4 ├── libtirpc.m4 ├── nfs-utils.m4 ├── rpcsec_vers.m4 └── tcp-wrappers.m4 ├── autogen.sh ├── configure.ac ├── linux-nfs ├── ChangeLog ├── INSTALL ├── KNOWNBUGS ├── Makefile.am ├── NEW ├── README ├── THANKS └── TODO ├── support ├── Makefile.am ├── export │ ├── Makefile.am │ ├── client.c │ ├── export.c │ ├── hostname.c │ ├── mount.x │ ├── nfsctl.c │ ├── rmtab.c │ └── xtab.c ├── include │ ├── Makefile.am │ ├── cld.h │ ├── conffile.h │ ├── exportfs.h │ ├── ha-callout.h │ ├── misc.h │ ├── nfs │ │ ├── Makefile.am │ │ ├── debug.h │ │ ├── export.h │ │ └── nfs.h │ ├── nfs_mntent.h │ ├── nfs_paths.h │ ├── nfslib.h │ ├── nfsrpc.h │ ├── nls.h │ ├── nsm.h │ ├── pseudoflavors.h │ ├── rpcmisc.h │ ├── rpcsvc │ │ ├── Makefile.am │ │ └── nfs_prot.h │ ├── sockaddr.h │ ├── sys │ │ ├── Makefile.am │ │ └── fs │ │ │ ├── Makefile.am │ │ │ └── ext2fs.h │ ├── tcpwrapper.h │ ├── v4root.h │ ├── xcommon.h │ ├── xio.h │ ├── xlog.h │ └── xmalloc.h ├── misc │ ├── Makefile.am │ ├── from_local.c │ ├── mountpoint.c │ └── tcpwrapper.c ├── nfs │ ├── Makefile.am │ ├── atomicio.c │ ├── cacheio.c │ ├── closeall.c │ ├── conffile.c │ ├── exports.c │ ├── getfh.c │ ├── getport.c │ ├── mydaemon.c │ ├── nfs_mntent.c │ ├── nfsclient.c │ ├── nfsctl.c │ ├── nfsexport.c │ ├── rmtab.c │ ├── rpc_socket.c │ ├── rpcdispatch.c │ ├── rpcmisc.c │ ├── strlcat.c │ ├── strlcpy.c │ ├── svc_create.c │ ├── svc_socket.c │ ├── wildmat.c │ ├── xcommon.c │ ├── xio.c │ └── xlog.c └── nsm │ ├── Makefile.am │ ├── file.c │ ├── rpc.c │ └── sm_inter.x ├── systemd ├── Makefile.am ├── README ├── auth-rpcgss-module.service ├── nfs-blkmap.service ├── nfs-client.target ├── nfs-config.service.in ├── nfs-idmapd.service ├── nfs-mountd.service ├── nfs-server-generator.c ├── nfs-server.service ├── nfs-utils.service ├── proc-fs-nfsd.mount ├── rpc-gssd.service.in ├── rpc-statd-notify.service ├── rpc-statd.service ├── rpc-svcgssd.service └── var-lib-nfs-rpc_pipefs.mount ├── tests ├── Makefile.am ├── nsm_client │ ├── Makefile.am │ ├── README │ ├── nlm_sm_inter.x │ └── nsm_client.c ├── statdb_dump.c ├── t0001-statd-basic-mon-unmon.sh └── test-lib.sh ├── tools ├── Makefile.am ├── locktest │ ├── Makefile.am │ └── testlk.c ├── mountstats │ ├── Makefile.am │ ├── mountstats.man │ └── mountstats.py ├── nfs-iostat │ ├── Makefile.am │ ├── nfs-iostat.py │ └── nfsiostat.man ├── nlmtest │ ├── Makefile.am │ ├── README │ ├── host.h │ ├── nlm_prot.x │ └── nlmtest.c ├── rpcdebug │ ├── Makefile.am │ ├── rpcdebug.c │ └── rpcdebug.man └── rpcgen │ ├── Makefile.am │ ├── README │ ├── rpc_clntout.c │ ├── rpc_cout.c │ ├── rpc_hout.c │ ├── rpc_main.c │ ├── rpc_output.h │ ├── rpc_parse.c │ ├── rpc_parse.h │ ├── rpc_sample.c │ ├── rpc_scan.c │ ├── rpc_scan.h │ ├── rpc_svcout.c │ ├── rpc_tblout.c │ ├── rpc_util.c │ ├── rpc_util.h │ └── rpcgen.new.1 └── utils ├── Makefile.am ├── blkmapd ├── Makefile.am ├── blkmapd.man ├── device-discovery.c ├── device-discovery.h ├── device-inq.c ├── device-process.c └── dm-device.c ├── exportfs ├── Makefile.am ├── exportfs.c ├── exportfs.man ├── exports.man └── nfsd.man ├── gssd ├── .gitignore ├── Makefile.am ├── context.c ├── context.h ├── context_heimdal.c ├── context_lucid.c ├── context_mit.c ├── err_util.c ├── err_util.h ├── gss_names.c ├── gss_names.h ├── gss_oids.c ├── gss_oids.h ├── gss_util.c ├── gss_util.h ├── gssd.c ├── gssd.h ├── gssd.man ├── gssd_proc.c ├── krb5_util.c ├── krb5_util.h ├── svcgssd.c ├── svcgssd.h ├── svcgssd.man ├── svcgssd_krb5.c ├── svcgssd_krb5.h ├── svcgssd_main_loop.c ├── svcgssd_mech2file.c ├── svcgssd_proc.c └── write_bytes.h ├── idmapd ├── Makefile.am ├── idmapd.c ├── idmapd.man ├── nfs_idmap.h └── queue.h ├── mount ├── Makefile.am ├── configfile.c ├── error.c ├── error.h ├── fstab.c ├── fstab.h ├── mount.c ├── mount.nfs.man ├── mount_config.h ├── mount_constants.h ├── mount_libmount.c ├── network.c ├── network.h ├── nfs.man ├── nfs4_mount.h ├── nfs4mount.c ├── nfs_mount.h ├── nfsmount.c ├── nfsmount.conf ├── nfsmount.conf.man ├── nfsumount.c ├── parse_dev.c ├── parse_dev.h ├── parse_opt.c ├── parse_opt.h ├── stropts.c ├── stropts.h ├── token.c ├── token.h ├── umount.nfs.man ├── utils.c ├── utils.h └── version.h ├── mountd ├── Makefile.am ├── auth.c ├── cache.c ├── fsloc.c ├── fsloc.h ├── mount_dispatch.c ├── mountd.c ├── mountd.h ├── mountd.man ├── rmtab.c ├── svc_run.c └── v4root.c ├── nfsd ├── Makefile.am ├── nfsd.c ├── nfsd.man ├── nfssvc.c └── nfssvc.h ├── nfsdcltrack ├── Makefile.am ├── nfsdcltrack.c ├── nfsdcltrack.man ├── sqlite.c └── sqlite.h ├── nfsidmap ├── Makefile.am ├── id_resolver.conf ├── nfsidmap.c └── nfsidmap.man ├── nfsstat ├── Makefile.am ├── nfsstat.c └── nfsstat.man ├── osd_login ├── Makefile.am └── osd_login ├── showmount ├── Makefile.am ├── showmount.c └── showmount.man └── statd ├── .gitignore ├── COPYING ├── Makefile.am ├── TODO ├── callback.c ├── hostname.c ├── misc.c ├── monitor.c ├── notlist.c ├── notlist.h ├── rmtcall.c ├── sim_sm_inter.x ├── simu.c ├── simulate.c ├── sm-notify.c ├── sm-notify.man ├── start-statd ├── stat.c ├── statd.c ├── statd.h ├── statd.man ├── svc_run.c └── system.h /.gitignore: -------------------------------------------------------------------------------- 1 | # files generated by autoconf, automake, autoheader and libtoolize 2 | aclocal.m4 3 | autom4te.cache 4 | compile 5 | config.guess 6 | config.sub 7 | configure 8 | depcomp 9 | install-sh 10 | libtool 11 | ltmain.sh 12 | Makefile.in 13 | missing 14 | support/include/config.h.in 15 | aclocal/libtool.m4 16 | aclocal/ltoptions.m4 17 | aclocal/ltsugar.m4 18 | aclocal/ltversion.m4 19 | aclocal/lt~obsolete.m4 20 | # files generated by configure 21 | confdefs.h 22 | config.cache 23 | config.log 24 | config.status 25 | conftest 26 | conftest.c 27 | conftest.cpp 28 | conftest.er1 29 | conftest.err 30 | .deps 31 | Makefile 32 | support/include/config.h 33 | support/include/stamp-h1 34 | # file generated during compilation 35 | *.o 36 | .libs 37 | lib*.a 38 | test-driver 39 | tools/rpcgen/rpcgen 40 | tools/rpcdebug/rpcdebug 41 | utils/blkmapd/blkmapd 42 | utils/exportfs/exportfs 43 | utils/idmapd/idmapd 44 | utils/lockd/lockd 45 | utils/mount/mount.nfs 46 | utils/mountd/mountd 47 | utils/nfsd/nfsd 48 | utils/nfsstat/nfsstat 49 | utils/nhfsstone/nhfsstone 50 | utils/rquotad/rquotad 51 | utils/rquotad/rquota.h 52 | utils/rquotad/rquota_xdr.c 53 | utils/showmount/showmount 54 | utils/nfsdcltrack/nfsdcltrack 55 | utils/statd/statd 56 | tools/locktest/testlk 57 | tools/getiversion/getiversion 58 | support/export/mount.h 59 | support/export/mount_clnt.c 60 | support/export/mount_xdr.c 61 | support/include/mount.h 62 | support/nsm/sm_inter.h 63 | support/nsm/sm_inter_clnt.c 64 | support/nsm/sm_inter_svc.c 65 | support/nsm/sm_inter_xdr.c 66 | support/include/sm_inter.h 67 | tests/nsm_client/nlm_sm_inter.h 68 | tests/nsm_client/nlm_sm_inter_clnt.c 69 | tests/nsm_client/nlm_sm_inter_svc.c 70 | tests/nsm_client/nlm_sm_inter_xdr.c 71 | utils/nfsidmap/nfsidmap 72 | systemd/nfs-server-generator 73 | systemd/nfs-config.service 74 | systemd/rpc-gssd.service 75 | # cscope database files 76 | cscope.* 77 | # generic editor backup et al 78 | *~ 79 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | AUTOMAKE_OPTIONS = foreign 4 | 5 | SUBDIRS = tools support utils linux-nfs tests systemd 6 | 7 | MAINTAINERCLEANFILES = Makefile.in 8 | 9 | EXTRA_DIST = \ 10 | autogen.sh \ 11 | \ 12 | aclocal/bsdsignals.m4 \ 13 | aclocal/nfs-utils.m4 \ 14 | aclocal/kerberos5.m4 \ 15 | aclocal/tcp-wrappers.m4 \ 16 | aclocal/libtirpc.m4 \ 17 | aclocal/libevent.m4 \ 18 | aclocal/libnfsidmap.m4 \ 19 | aclocal/rpcsec_vers.m4 \ 20 | aclocal/ipv6.m4 21 | 22 | ACLOCAL_AMFLAGS = -I aclocal 23 | 24 | install-data-hook: 25 | if [ ! -d $(DESTDIR)$(statedir) ]; then mkdir -p $(DESTDIR)$(statedir); fi 26 | touch $(DESTDIR)$(statedir)/xtab; chmod 644 $(DESTDIR)$(statedir)/xtab 27 | touch $(DESTDIR)$(statedir)/etab; chmod 644 $(DESTDIR)$(statedir)/etab 28 | touch $(DESTDIR)$(statedir)/rmtab; chmod 644 $(DESTDIR)$(statedir)/rmtab 29 | mkdir -p $(DESTDIR)$(statdpath)/sm $(DESTDIR)$(statdpath)/sm.bak 30 | touch $(DESTDIR)$(statdpath)/state 31 | chmod go-rwx $(DESTDIR)$(statdpath)/sm $(DESTDIR)$(statdpath)/sm.bak $(DESTDIR)$(statdpath)/state 32 | -chown $(statduser) $(DESTDIR)$(statdpath)/sm $(DESTDIR)$(statdpath)/sm.bak $(DESTDIR)$(statdpath)/state 33 | 34 | uninstall-hook: 35 | rm $(DESTDIR)$(statedir)/xtab 36 | rm $(DESTDIR)$(statedir)/etab 37 | rm $(DESTDIR)$(statedir)/rmtab 38 | rm $(DESTDIR)$(statdpath)/state 39 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | Significant changes for nfs-utils 1.1.0 - March/April 2007 2 | 3 | - rpc.lockd is gone. One 3 old kernel releases need it. 4 | - rpc.rquotad is gone. Use the one from the 'quota' package. 5 | Everone else does. 6 | - /sbin/{u,}mount.nfs{,4} are now installed so 'mount' will 7 | use these to mount nfs filesystems instead of internal code. 8 | + mount.nfs will check for 'statd' to be running when mounting 9 | a filesystem which requires it. If it is not running it will 10 | run "/usr/sbin/start-statd" to try to start it. 11 | If statd is not running and cannot be started, mount.nfs will 12 | refuse to mount the filesystem and will suggest the 'nolock' 13 | option. 14 | - Substantial changes to statd 15 | + The 'notify' process that must happen at boot has been split 16 | into a separate program "sm-notify". It ensures that it 17 | only runs once even if you restart statd. This is correct 18 | behaviour. 19 | + statd stores state in the files in /var/lib/nfs/sm/ so that 20 | if you kill and restart it, it will restore that state and 21 | continue working correctly. 22 | + statd makes more use of DNS lookup and should handle 23 | multi-homed peers better. In particular, files in 24 | /var/lib/nfs/sm/ are named with the Full Qualified Domain Name 25 | if available. 26 | - If you export a directory as 'crossmnt', all filesystems 27 | mounted beneath are automatically exported with the same 28 | options (unless explicitly exported with different options). 29 | - subtree_check is no-longer the default. The default is now 30 | no_subtree_check. 31 | - By default the system 'rpcgen' is used while building 32 | nfs-utils rather than the internal one. 33 | - Exportfs will warn if you try to export a filesystem that does 34 | not support NFS export. 35 | - Comprehensive notes on startup dependencies have been added 36 | to the README file. 37 | - Mount and statd now listen on a non-privileged port by default. 38 | For maximum safety an upgrade to portmap-6.0 is recommended. 39 | http://neil.brown.name/portmap/ 40 | git://neil.brown.name/portmap 41 | 42 | - This release should work with MIT Kerberos and Heimdal 0.8.1 and later. 43 | 44 | - A new option, -n, was added to rpc.gssd which specifies that 45 | accesses by root should not use 'machine credentials' when 46 | accessing NFS file systems mounted with Kerberos. Using this 47 | option allows the root user to access the NFS space using any 48 | Kerberos principal, rather than always using the machine 49 | credentials. However, its use also requires that root manually 50 | authenticate before attempting a mount with Kerberos. 51 | 52 | When rpc.gssd uses machine credentials, the selection algorithm has 53 | been changed. Instead of simply using the first "nfs/*" key in the 54 | keytab, the keytab is now searched for keys in the following 55 | defined order: 56 | 57 | root/@REALM 58 | nfs/@REALM 59 | host/@REALM 60 | root/@REALM 61 | nfs/@REALM 62 | host/@REALM 63 | 64 | -------------------------------------------------------------------------------- /aclocal/bsdsignals.m4: -------------------------------------------------------------------------------- 1 | dnl *********** BSD vs. POSIX signal handling ************** 2 | AC_DEFUN([AC_BSD_SIGNALS], [ 3 | AC_MSG_CHECKING(for BSD signal semantics) 4 | AC_CACHE_VAL(knfsd_cv_bsd_signals, 5 | [AC_TRY_RUN([ 6 | #include 7 | #include 8 | #include 9 | 10 | static int counter = 0; 11 | static RETSIGTYPE handler(int num) { counter++; } 12 | 13 | int main() 14 | { 15 | int s; 16 | if ((s = fork()) < 0) return 1; 17 | if (s != 0) { 18 | if (wait(&s) < 0) return 1; 19 | return WIFSIGNALED(s)? 1 : 0; 20 | } 21 | 22 | signal(SIGHUP, handler); 23 | kill(getpid(), SIGHUP); kill(getpid(), SIGHUP); 24 | return (counter == 2)? 0 : 1; 25 | } 26 | ], knfsd_cv_bsd_signals=yes, knfsd_cv_bsd_signals=no, 27 | [ 28 | case "$host_os" in 29 | *linux*) knfsd_cv_bsd_signals=no;; 30 | *bsd*) knfsd_cv_bsd_signals=yes;; 31 | *) AC_MSG_ERROR([unable to guess signal semantics for $host_os; please set knfsd_cv_bsd_signals]);; 32 | esac 33 | ])]) dnl 34 | AC_MSG_RESULT($knfsd_cv_bsd_signals) 35 | test $knfsd_cv_bsd_signals = yes && AC_DEFINE(HAVE_BSD_SIGNALS, 1, [Define this if you want to use BSD signal semantics]) 36 | ])dnl 37 | -------------------------------------------------------------------------------- /aclocal/ipv6.m4: -------------------------------------------------------------------------------- 1 | dnl Checks for IPv6 support 2 | dnl 3 | AC_DEFUN([AC_IPV6], [ 4 | 5 | if test "$enable_ipv6" = yes; then 6 | 7 | dnl TI-RPC required for IPv6 8 | if test "$enable_tirpc" = no; then 9 | AC_MSG_ERROR(['--enable-ipv6' requires TIRPC support.]) 10 | fi 11 | 12 | dnl IPv6-enabled networking functions required for IPv6 13 | AC_CHECK_FUNCS([getifaddrs getnameinfo], , 14 | [AC_MSG_ERROR([Missing library functions needed for IPv6.])]) 15 | 16 | AC_CHECK_LIB([tirpc], [bindresvport_sa], [:], 17 | [AC_MSG_ERROR([Missing library functions needed for IPv6.])]) 18 | fi 19 | 20 | ])dnl 21 | -------------------------------------------------------------------------------- /aclocal/keyutils.m4: -------------------------------------------------------------------------------- 1 | dnl Checks for keyutils library and headers 2 | dnl 3 | AC_DEFUN([AC_KEYUTILS], [ 4 | 5 | dnl Check for libkeyutils; do not add to LIBS if found 6 | AC_CHECK_LIB([keyutils], [keyctl_instantiate], [LIBKEYUTILS=-lkeyutils], ,) 7 | AC_SUBST(LIBKEYUTILS) 8 | 9 | AC_CHECK_HEADERS([keyutils.h]) 10 | 11 | AC_CHECK_LIB([keyutils], [find_key_by_type_and_desc], 12 | [AC_DEFINE([HAVE_FIND_KEY_BY_TYPE_AND_DESC], [1], 13 | [Define to 1 if you have the `find_key_by_type_and_desc' function.])],) 14 | 15 | ])dnl 16 | -------------------------------------------------------------------------------- /aclocal/libblkid.m4: -------------------------------------------------------------------------------- 1 | dnl *************************** libblkid needs version 1.40 or later *********************** 2 | AC_DEFUN([AC_BLKID_VERS], [ 3 | AC_MSG_CHECKING(for suitable libblkid version) 4 | AC_CACHE_VAL([libblkid_cv_is_recent], 5 | [ 6 | saved_LIBS="$LIBS" 7 | LIBS=-lblkid 8 | AC_TRY_RUN([ 9 | #include 10 | int main() 11 | { 12 | int vers = blkid_get_library_version(0, 0); 13 | return vers >= 140 ? 0 : 1; 14 | } 15 | ], [libblkid_cv_is_recent=yes], [libblkid_cv_is_recent=no], 16 | [libblkid_cv_is_recent=unknown]) 17 | LIBS="$saved_LIBS"]) 18 | AC_MSG_RESULT($libblkid_cv_is_recent) 19 | ])dnl 20 | -------------------------------------------------------------------------------- /aclocal/libcap.m4: -------------------------------------------------------------------------------- 1 | dnl Checks for libcap.so 2 | dnl 3 | AC_DEFUN([AC_LIBCAP], [ 4 | 5 | dnl look for prctl 6 | AC_CHECK_FUNC([prctl], , AC_MSG_ERROR([prctl syscall is not available])) 7 | 8 | AC_ARG_ENABLE([caps], 9 | [AS_HELP_STRING([--disable-caps], [Disable capabilities support])]) 10 | 11 | LIBCAP= 12 | 13 | if test "x$enable_caps" != "xno" ; then 14 | dnl look for the library; do not add to LIBS if found 15 | AC_CHECK_LIB([cap], [cap_get_proc], [LIBCAP=-lcap], ,) 16 | 17 | AC_CHECK_HEADERS([sys/capability.h], , 18 | [test "x$enable_caps" = "xyes" && AC_MSG_ERROR([libcap headers not found.])]) 19 | fi 20 | 21 | AC_SUBST(LIBCAP) 22 | 23 | ])dnl 24 | -------------------------------------------------------------------------------- /aclocal/libevent.m4: -------------------------------------------------------------------------------- 1 | dnl Checks for libevent 2 | AC_DEFUN([AC_LIBEVENT], [ 3 | 4 | dnl Check for libevent, but do not add -levent to LIBS 5 | AC_CHECK_LIB([event], [event_dispatch], [LIBEVENT=-levent], 6 | [AC_MSG_ERROR([libevent not found.])]) 7 | AC_SUBST(LIBEVENT) 8 | 9 | AC_CHECK_HEADERS([event.h], , 10 | [AC_MSG_ERROR([libevent headers not found.])]) 11 | 12 | ])dnl 13 | -------------------------------------------------------------------------------- /aclocal/libnfsidmap.m4: -------------------------------------------------------------------------------- 1 | dnl Checks for libnfsidmap 2 | dnl 3 | AC_DEFUN([AC_LIBNFSIDMAP], [ 4 | 5 | dnl Check for libnfsidmap, but do not add -lnfsidmap to LIBS 6 | AC_CHECK_LIB([nfsidmap], [nfs4_init_name_mapping], [LIBNFSIDMAP=-lnfsidmap], 7 | [AC_MSG_ERROR([libnfsidmap not found.])]) 8 | 9 | AC_CHECK_HEADERS([nfsidmap.h], , 10 | [AC_MSG_ERROR([libnfsidmap headers not found.])]) 11 | 12 | dnl nfs4_set_debug() doesn't appear in all versions of libnfsidmap 13 | AC_CHECK_LIB([nfsidmap], [nfs4_set_debug], 14 | [AC_DEFINE([HAVE_NFS4_SET_DEBUG], 1, 15 | [Define to 1 if you have the `nfs4_set_debug' function.])]) 16 | 17 | dnl nfs4_owner_to_uid() doesn't appear in all versions of libnfsidmap 18 | dnl We just need this test to set $ac_cv_lib_nfsidmap_nfs4_owner_to_uid 19 | AC_CHECK_LIB([nfsidmap], [nfs4_owner_to_uid], [:]) 20 | 21 | AC_SUBST(LIBNFSIDMAP) 22 | 23 | ])dnl 24 | -------------------------------------------------------------------------------- /aclocal/libpthread.m4: -------------------------------------------------------------------------------- 1 | dnl Checks for pthreads library and headers 2 | dnl 3 | AC_DEFUN([AC_LIBPTHREAD], [ 4 | 5 | dnl Check for library, but do not add -lpthreads to LIBS 6 | AC_CHECK_LIB([pthread], [pthread_create], [LIBPTHREAD=-lpthread], 7 | [AC_MSG_ERROR([libpthread not found.])]) 8 | AC_SUBST(LIBPTHREAD) 9 | 10 | AC_CHECK_HEADERS([pthread.h], , 11 | [AC_MSG_ERROR([libpthread headers not found.])]) 12 | 13 | ])dnl 14 | -------------------------------------------------------------------------------- /aclocal/libsqlite3.m4: -------------------------------------------------------------------------------- 1 | dnl Checks for matching sqlite3 header and library, and 2 | dnl sufficient sqlite3 version. 3 | dnl 4 | AC_DEFUN([AC_SQLITE3_VERS], [ 5 | AC_CHECK_HEADERS([sqlite3.h], ,) 6 | 7 | dnl look for the library; do not add to LIBS if found 8 | AC_CHECK_LIB([sqlite3], [sqlite3_libversion_number], [LIBSQLITE=-lsqlite3], ,) 9 | AC_SUBST(LIBSQLITE) 10 | 11 | AC_MSG_CHECKING(for suitable sqlite3 version) 12 | 13 | AC_CACHE_VAL([libsqlite3_cv_is_recent], 14 | [ 15 | saved_LIBS="$LIBS" 16 | LIBS=-lsqlite3 17 | AC_TRY_RUN([ 18 | #include 19 | #include 20 | int main() 21 | { 22 | int vers = sqlite3_libversion_number(); 23 | 24 | return vers != SQLITE_VERSION_NUMBER || 25 | vers < 3003000; 26 | } 27 | ], [libsqlite3_cv_is_recent=yes], [libsqlite3_cv_is_recent=no], 28 | [libsqlite3_cv_is_recent=unknown]) 29 | LIBS="$saved_LIBS"]) 30 | 31 | AC_MSG_RESULT($libsqlite3_cv_is_recent) 32 | ])dnl 33 | -------------------------------------------------------------------------------- /aclocal/libtirpc.m4: -------------------------------------------------------------------------------- 1 | dnl Checks for TI-RPC library and headers 2 | dnl 3 | AC_DEFUN([AC_LIBTIRPC], [ 4 | 5 | PKG_PROG_PKG_CONFIG([0.9.0]) 6 | AS_IF( 7 | [test "$enable_tirpc" != "no"], 8 | [PKG_CHECK_MODULES([TIRPC], [libtirpc], 9 | [LIBTIRPC="${TIRPC_LIBS}" 10 | AM_CPPFLAGS="${AM_CPPFLAGS} ${TIRPC_CFLAGS}" 11 | AC_DEFINE([HAVE_LIBTIRPC], [1], 12 | [Define to 1 if you have and wish to use libtirpc.])], 13 | [AC_LIBTIRPC_OLD 14 | AS_IF([test "$enable_tirpc" = "yes" -a -z "${LIBTIRPC}"], 15 | [AC_MSG_ERROR([libtirpc not found.])])])]) 16 | 17 | AS_IF([test -n "${LIBTIRPC}"], 18 | [AC_CHECK_LIB([tirpc], [authgss_free_private_data], 19 | [AC_DEFINE([HAVE_AUTHGSS_FREE_PRIVATE_DATA], [1], 20 | [Define to 1 if your rpcsec library provides authgss_free_private_data])],, 21 | [${LIBS}])]) 22 | 23 | AS_IF([test -n "${LIBTIRPC}"], 24 | [AC_CHECK_LIB([tirpc], [libtirpc_set_debug], 25 | [AC_DEFINE([HAVE_LIBTIRPC_SET_DEBUG], [1], 26 | [Define to 1 if your tirpc library provides libtirpc_set_debug])],, 27 | [${LIBS}])]) 28 | 29 | AC_SUBST([AM_CPPFLAGS]) 30 | AC_SUBST(LIBTIRPC) 31 | 32 | ])dnl 33 | 34 | dnl Old way of checking libtirpc without pkg-config 35 | dnl This can go away when virtually all libtirpc provide a .pc file 36 | dnl 37 | AC_DEFUN([AC_LIBTIRPC_OLD], [ 38 | 39 | AC_ARG_WITH([tirpcinclude], 40 | [AC_HELP_STRING([--with-tirpcinclude=DIR], 41 | [use TI-RPC headers in DIR])], 42 | [tirpc_header_dir=$withval], 43 | [tirpc_header_dir=/usr/include/tirpc]) 44 | 45 | dnl Look for the library 46 | AC_CHECK_LIB([tirpc], [clnt_tli_create], 47 | [has_libtirpc="yes"], 48 | [has_libtirpc="no"]) 49 | 50 | dnl Also must have the headers installed where we expect 51 | dnl to look for headers; add -I compiler option if found 52 | AS_IF([test "$has_libtirpc" = "yes"], 53 | [AC_CHECK_HEADERS([${tirpc_header_dir}/netconfig.h], 54 | [AC_SUBST([AM_CPPFLAGS], ["-I${tirpc_header_dir}"])], 55 | [has_libtirpc="no"])]) 56 | 57 | dnl Now set $LIBTIRPC accordingly 58 | AS_IF([test "$has_libtirpc" = "yes"], 59 | [AC_DEFINE([HAVE_LIBTIRPC], [1], 60 | [Define to 1 if you have and wish to use libtirpc.]) 61 | LIBTIRPC="-ltirpc"]) 62 | 63 | ])dnl 64 | -------------------------------------------------------------------------------- /aclocal/nfs-utils.m4: -------------------------------------------------------------------------------- 1 | dnl *********** GNU libc 2 *************** 2 | AC_DEFUN([AC_GNULIBC],[ 3 | AC_MSG_CHECKING(for GNU libc2) 4 | AC_CACHE_VAL(knfsd_cv_glibc2, 5 | [AC_TRY_CPP([ 6 | #include 7 | #if !defined(__GLIBC__) 8 | # error Nope 9 | #endif 10 | ], 11 | knfsd_cv_glibc2=yes, knfsd_cv_glibc2=no)]) 12 | AC_MSG_RESULT($knfsd_cv_glibc2) 13 | if test $knfsd_cv_glibc2 = yes; then 14 | CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" 15 | CPPFLAGS_FOR_BUILD="$CPPFLAGS_FOR_BUILD -D_GNU_SOURCE" 16 | fi 17 | ]) 18 | -------------------------------------------------------------------------------- /aclocal/rpcsec_vers.m4: -------------------------------------------------------------------------------- 1 | dnl Checks librpcsec version 2 | AC_DEFUN([AC_RPCSEC_VERSION], [ 3 | 4 | AC_ARG_WITH([gssglue], 5 | [AC_HELP_STRING([--with-gssglue], [Use libgssglue for GSS support])]) 6 | if test x"$with_gssglue" = x"yes"; then 7 | PKG_CHECK_MODULES([GSSGLUE], [libgssglue >= 0.3]) 8 | AC_CHECK_LIB([gssglue], [gss_set_allowable_enctypes]) 9 | fi 10 | 11 | dnl TI-RPC replaces librpcsecgss 12 | if test "$enable_tirpc" = no; then 13 | PKG_CHECK_MODULES([RPCSECGSS], [librpcsecgss >= 0.16]) 14 | fi 15 | 16 | ])dnl 17 | -------------------------------------------------------------------------------- /aclocal/tcp-wrappers.m4: -------------------------------------------------------------------------------- 1 | # Check whether user wants TCP wrappers support 2 | AC_DEFUN([AC_TCP_WRAPPERS],[ 3 | TCPW_MSG="no" 4 | AC_ARG_WITH(tcp-wrappers, 5 | [ --with-tcp-wrappers[[=PATH]] Enable tcpwrappers support 6 | (optionally in PATH)], 7 | with_tcpw=$withval, with_tcpw=yes) 8 | if test "x$with_tcpw" != "xno" ; then 9 | saved_LIBS="$LIBS" 10 | saved_LDFLAGS="$LDFLAGS" 11 | saved_CPPFLAGS="$CPPFLAGS" 12 | if test -n "${with_tcpw}" -a "${with_tcpw}" != "yes"; then 13 | if test -d "${with_tcpw}/lib"; then 14 | if test -n "${need_dash_r}"; then 15 | LDFLAGS="-L${with_tcpw}/lib -R${with_tcpw}/lib ${LDFLAGS}" 16 | else 17 | LDFLAGS="-L${with_tcpw}/lib ${LDFLAGS}" 18 | fi 19 | else 20 | if test -n "${need_dash_r}"; then 21 | LDFLAGS="-L${with_tcpw} -R${with_tcpw} ${LDFLAGS}" 22 | else 23 | LDFLAGS="-L${with_tcpw} ${LDFLAGS}" 24 | fi 25 | fi 26 | if test -d "${with_tcpw}/include"; then 27 | CPPFLAGS="-I${with_tcpw}/include ${CPPFLAGS}" 28 | else 29 | CPPFLAGS="-I${with_tcpw} ${CPPFLAGS}" 30 | fi 31 | fi 32 | LIBWRAP="-lwrap" 33 | LIBS="$LIBWRAP $LIBS" 34 | AC_MSG_CHECKING(for libwrap) 35 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 36 | #include 37 | int deny_severity = 0, allow_severity = 0; 38 | ]], [[hosts_access(0);]])],[ 39 | AC_MSG_RESULT(yes) 40 | AC_SUBST(LIBWRAP) 41 | AC_DEFINE([LIBWRAP], [1], [tcp-wrapper]) 42 | AC_DEFINE([HAVE_LIBWRAP], [1], [tcp-wrapper]) 43 | AC_DEFINE([HAVE_TCP_WRAPPER], [1], [tcp-wrapper]) 44 | TCPW_MSG="yes" 45 | ],[ 46 | AC_MSG_ERROR([*** libwrap missing]) 47 | 48 | ]) 49 | LIBS="$saved_LIBS" 50 | fi 51 | AC_SUBST(LIBWRAP) 52 | AC_SUBST(HAVE_LIBWRAP) 53 | AC_SUBST(HAVE_TCP_WRAPPER) 54 | ]) 55 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | echo -n cleaning up . 4 | 5 | # Clean up the generated crud 6 | ( 7 | for FILE in compile config.guess config.sub depcomp install-sh ltmain.sh missing mkinstalldirs; do 8 | if test -f $FILE; then 9 | rm -f $FILE 10 | fi 11 | echo -n . 12 | done 13 | ) 14 | 15 | for FILE in aclocal.m4 configure config.h.in; do 16 | if test -f $FILE; then 17 | rm -f $FILE 18 | fi 19 | echo -n . 20 | done 21 | 22 | for DIR in autom4te.cache; do 23 | if test -d $DIR; then 24 | rm -rf $DIR 25 | fi 26 | echo -n . 27 | done 28 | 29 | find . -type f -name 'Makefile.in' -print0 | xargs -r0 rm -f -- 30 | find . -type f -name 'Makefile' -print0 | xargs -r0 rm -f -- 31 | 32 | echo ' done' 33 | 34 | if test x"${1}" = x"clean"; then 35 | exit 36 | fi 37 | 38 | aclocal -I aclocal 39 | libtoolize --force --copy 40 | autoheader 41 | automake --add-missing --copy --gnu # -Wall 42 | autoconf # -Wall 43 | -------------------------------------------------------------------------------- /linux-nfs/ChangeLog: -------------------------------------------------------------------------------- 1 | 2 | Release 0.4.11 3 | 4 | * Added async writes. 5 | * Fixed bug where two rpciod's would be started when insmod'ing 6 | both nfs.o and nfsd.o. 7 | 8 | Release 0.4.12 9 | 10 | * Fixed compile problem after renaming some debug macros. 11 | * Improved readdir cache, which can now hold up to 16 (configurable) 12 | readdir replies. 13 | * Fixed async write bug(s) 14 | * client file locking now does at least lock/unlock without 15 | crashing the machine 16 | * Started to work on NFS swapping 17 | * nfs_get_super no longer requires the file handle passed by 18 | mount but does a straight xprt_create_proto(). 19 | * TCP reconnect should work now (not yet tested for long disconnect 20 | periods, but it does work if you kill and restart nfsd). 21 | 22 | Release 0.4.13 23 | 24 | * More writeback bugs removed. 25 | * Added a modified (and ansified) tirpc rpcgen to get rid of all 26 | the warnings in files generated from *.x descriptions. That old Sun 27 | code is a real mess. 28 | * Cleaned up nfsd export handling a bit. All syscalls now 29 | take dev/ino rather than the pathname. 30 | * Added sysctl interface to set/get debug flags (see tools/rpcdebug). 31 | * Cleaned up Makefiles. 32 | * (experimental) Gathered writes for nfsd (use the wdelay option in 33 | /etc/exports). 34 | * Fixed silly bug in nfs_readdir (the in-place decoding of readdir 35 | replies requires a temporary buffer). 36 | * Fixed readdir bug in nfsd (long directories were truncated). 37 | 38 | Release 0.4.14 39 | 40 | * Upgraded to kernel 2.0.23 41 | * Fixed bug in rpcdebug 42 | * readdir still didn't work right in nfsd. Argh! 43 | * nfsd would refuse to create symlinks with slashes in them:-) 44 | * nfsd's RPC reply cache should now work again. 45 | * Heavily modified rpc.statd for more robust callback/notify handling 46 | 47 | Release 0.4.17 48 | 49 | * Upgraded to kernel 2.1.14 50 | * Got lockd working with HPUX in most areas. 51 | 52 | Release 0.4.19 53 | 54 | * RPC server UDP sockets now receive the sk_buff directly rather 55 | than going through sock->ops->recvmsg. 56 | Also got rid of all those cli/sti's and replaced them with 57 | disable_bh/enable_bh calls. 58 | * Fixed a bug in nfsd's handling of rename and friends. 59 | 60 | Release 0.4.20 61 | 62 | * Some bugfixes, esp in the writeback code 63 | * Avoid some unnecessary cli/sti pairs 64 | * Added nhfsstone 65 | 66 | Release 0.4.21 67 | 68 | * Minor bugfixes 69 | * Moved to post-2.1.16 module handling code 70 | 71 | Release 0.4.22 72 | 73 | * Fixed a bug that made rpcinfo -u host nlockmgr provoke a kernel 74 | oops. 75 | * Upgraded to mount-2.6b 76 | * Added NFSv3 support to mountd and nfsd 77 | * Made sure it compiles with glibc2. 78 | 79 | -------------------------------------------------------------------------------- /linux-nfs/INSTALL: -------------------------------------------------------------------------------- 1 | 2 | Even though the Makefiles offer a `make install' instruction, 3 | I would suggest against using it yet. I have run nfsd and the nfs 4 | client without kernel oopses for a while, but the picture may change 5 | if you start playing with lockd. Automatic installation may not even 6 | work for the kernel makefiles yet. 7 | 8 | I'd therefore advise that you use a separate Linux box for testing 9 | if you have one. Use the etc/copy script to copy all modules and 10 | support programs, and run the ins script to start the show. rmm 11 | will clean up afterwards (provided you didn't trigger an oops). 12 | -------------------------------------------------------------------------------- /linux-nfs/KNOWNBUGS: -------------------------------------------------------------------------------- 1 | 2 | nfsd: 3 | 4 | * We currently keep the inode in the exports struct. This is 5 | a bad idea with directories that are intended to be used as 6 | a mount point. Must store the file name instead and do a 7 | lookup when getfh is called. Yuck! 8 | 9 | Even yuckier: what do we do about exports matching when we 10 | can't keep the inode number? 11 | 12 | * stating a file on remote cdrom returns st_blocks == 0 for some 13 | apps. 14 | 15 | * Should allow multiple exports per dev if one of the directories 16 | isn't a subdir of the other. 17 | 18 | nfsclnt: 19 | 20 | * On some occasions, an EAGAIN reported by the transport layer 21 | will be propagated to the VFS. 22 | * Some operations do not seem to release the inode properly, so 23 | unmounting the device fails. 24 | 25 | lockd: 26 | 27 | * Handle portmap registration in a separate thread. portmap may 28 | not be running when we try to mount the first NFS volume (esp. 29 | when mounting /usr). 30 | 31 | * Does not inform rpc.statd when hosts no longer require 32 | monitoring; hosts are incorrectly monitored until next system 33 | reboot. 34 | 35 | exportfs/mountd: 36 | 37 | * Export handling is reported to do odd things at times. 38 | -------------------------------------------------------------------------------- /linux-nfs/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | EXTRA_DIST = ChangeLog INSTALL KNOWNBUGS NEW README THANKS TODO 4 | 5 | MAINTAINERCLEANFILES = Makefile.in 6 | -------------------------------------------------------------------------------- /linux-nfs/README: -------------------------------------------------------------------------------- 1 | 2 | This package contains a greatly revised NFS implementation for Linux 3 | along with the necessary daemons and utilities. There are still several 4 | features missing that I'd want to include, and there are some recent 5 | improvements to the Linux NFS kernel client not reflected here (notably 6 | the attrtimeo fix). 7 | 8 | This thing has become much too large for me to handle all alone anymore. 9 | Originally, I had planned to have most of the NFS implementation running 10 | stably by August, so I could start to concentrate more on other jobs that 11 | are currently in the queue (like updating the NAG). As it turned out, it 12 | was much more work than I anticipated, and I fell short of my time goal. 13 | I'm therefore looking for volunteers who would like to work with me on 14 | finishing this package. Otherwise, this project could end up rusting in 15 | the corner of some FTP site... 16 | 17 | Ideally, I would want to hand over parts of the source tree to other 18 | hackers to maintain/enhance/etc. But that's not a requirement; if you 19 | feel you don't have that much time, you can also contribute by picking 20 | up one of the loose ends and finish what needs to be done (take a look 21 | at the TODO file...) And then, you can also be plainly a tester. 22 | 23 | There's currently a mailing list for lockd development at NRAO 24 | (lockd-statd@linux.nrao.edu --- mail majordomo@linux.nrao.edu to 25 | subscribe). If Jeff agress, we could turn this into a general linux-nfs 26 | mailing list. 27 | 28 | 29 | Hope this covers about what I wanted to say, 30 | Olaf 31 | 32 | ------------------------------------------------------------------ 33 | 34 | 35 | SOURCE TREE OVERVIEW 36 | 37 | 38 | 39 | support/ Support libraries for user-space programs 40 | 41 | support/nfs Generic library for nfsd utilities 42 | support/export Manipulation of /etc/exports and /var/lib/nfs/{xtab,rmtab} 43 | 44 | utils/ Code for various user-space programs. 45 | utils/exportfs Management of nfsd export table. 46 | utils/mount Modified mount command to support NFS over TCP. 47 | utils/mountd New rpc.mountd for kernel nfsd. 48 | utils/nfsd New nfsd (just starts kernel nfsd). 49 | utils/nfsstat Pretty-print NFS stats from /proc/net/rpc/nfs* 50 | utils/rquotad Marco van Wieringen's rquotad 51 | utils/showmount Rick Sladkey's showmount client 52 | utils/statd Jeff Uphoff's rpc.statd. 53 | 54 | tools/ Support tools for developers/debuggers/testers 55 | tools/rpcdebug This one sets/gets the debug flags for each of the kernel 56 | modules. 57 | -------------------------------------------------------------------------------- /linux-nfs/THANKS: -------------------------------------------------------------------------------- 1 | 2 | This piece of software owes a lot to all the people who 3 | hacked on Linux NFS before me, most notably Rick Sladkey 4 | and Donald Becker. 5 | 6 | I also wish to thank Holger Grothe for loaning me a hard 7 | disk and a monitor to get my old 486 flying again so I have 8 | a decentish test platform. 9 | 10 | Olaf 11 | -------------------------------------------------------------------------------- /support/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | SUBDIRS = export include misc nfs nsm 4 | 5 | MAINTAINERCLEANFILES = Makefile.in 6 | 7 | -------------------------------------------------------------------------------- /support/export/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | 4 | GENFILES_CLNT = mount_clnt.c 5 | GENFILES_XDR = mount_xdr.c 6 | GENFILES_H = mount.h 7 | 8 | GENFILES = $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H) 9 | 10 | EXTRA_DIST = mount.x 11 | 12 | noinst_LIBRARIES = libexport.a 13 | libexport_a_SOURCES = client.c export.c hostname.c nfsctl.c rmtab.c \ 14 | xtab.c mount_clnt.c mount_xdr.c 15 | BUILT_SOURCES = $(GENFILES) 16 | 17 | noinst_HEADERS = mount.h 18 | 19 | dist-hook: 20 | for f in $(GENFILES); do \ 21 | rm ${distdir}/$$f; \ 22 | done 23 | 24 | if CONFIG_RPCGEN 25 | RPCGEN = $(top_builddir)/tools/rpcgen/rpcgen 26 | $(RPCGEN): 27 | make -C $(top_srcdir)/tools/rpcgen all 28 | else 29 | RPCGEN = @RPCGEN_PATH@ 30 | endif 31 | 32 | $(GENFILES_CLNT): %_clnt.c: %.x $(RPCGEN) 33 | test -f $@ && rm -rf $@ || true 34 | $(RPCGEN) -l -o $@ $< 35 | 36 | $(GENFILES_XDR): %_xdr.c: %.x $(RPCGEN) 37 | test -f $@ && rm -rf $@ || true 38 | $(RPCGEN) -c -o $@ $< 39 | 40 | $(GENFILES_H): %.h: %.x $(RPCGEN) 41 | test -f $@ && rm -rf $@ || true 42 | $(RPCGEN) -h -o $@ $< 43 | rm -f $(top_builddir)/support/include/mount.h 44 | $(LN_S) ../export/mount.h $(top_builddir)/support/include/mount.h 45 | 46 | MAINTAINERCLEANFILES = Makefile.in 47 | 48 | CLEANFILES = $(GENFILES) $(top_builddir)/support/include/mount.h 49 | -------------------------------------------------------------------------------- /support/export/nfsctl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * support/export/nfsctl.c 3 | * 4 | * Communicate export information to knfsd. 5 | * 6 | * Copyright (C) 1995 Olaf Kirch 7 | */ 8 | 9 | #ifdef HAVE_CONFIG_H 10 | #include 11 | #endif 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "nfslib.h" 19 | #include "exportfs.h" 20 | #include "xio.h" 21 | 22 | static int expsetup(struct nfsctl_export *exparg, nfs_export *exp, int unexport); 23 | static int cltsetup(struct nfsctl_client *cltarg, nfs_client *clp); 24 | 25 | int 26 | export_export(nfs_export *exp) 27 | { 28 | nfs_client * clp = exp->m_client; 29 | struct nfsctl_export exparg; 30 | struct nfsctl_client cltarg; 31 | 32 | if (!clp->m_exported && (clp->m_type != MCL_GSS)) { 33 | if (!cltsetup(&cltarg, clp)) 34 | return 0; 35 | if (nfsaddclient(&cltarg) < 0) 36 | return 0; 37 | clp->m_exported = 1; 38 | } 39 | if (!expsetup(&exparg, exp, 0)) 40 | return 0; 41 | if (nfsexport(&exparg) < 0) 42 | return 0; 43 | exp->m_exported = 1; 44 | return 1; 45 | } 46 | 47 | int 48 | export_unexport(nfs_export *exp) 49 | { 50 | struct nfsctl_export exparg; 51 | 52 | if (!expsetup(&exparg, exp, 1) || nfsunexport(&exparg) < 0) 53 | return 0; 54 | exp->m_exported = 0; 55 | return 1; 56 | } 57 | 58 | static void 59 | str_tolower(char *s) 60 | { 61 | for ( ; *s; s++) 62 | if (isupper(*s)) 63 | *s = tolower(*s); 64 | } 65 | 66 | static int 67 | cltsetup(struct nfsctl_client *cltarg, nfs_client *clp) 68 | { 69 | int i, j; 70 | 71 | if (clp->m_type != MCL_FQDN) { 72 | xlog(L_ERROR, "internal: can't export non-FQDN host"); 73 | return 0; 74 | } 75 | memset(cltarg, 0, sizeof(*cltarg)); 76 | strncpy(cltarg->cl_ident, clp->m_hostname, 77 | sizeof (cltarg->cl_ident) - 1); 78 | str_tolower(cltarg->cl_ident); 79 | 80 | j = 0; 81 | for (i = 0; i < clp->m_naddr && i < NFSCLNT_ADDRMAX; i++) { 82 | const struct sockaddr_in *sin = get_addrlist_in(clp, i); 83 | if (sin->sin_family == AF_INET) 84 | cltarg->cl_addrlist[j++] = sin->sin_addr; 85 | } 86 | if (j == 0) { 87 | xlog(L_ERROR, "internal: no supported addresses in nfs_client"); 88 | return 0; 89 | } 90 | 91 | cltarg->cl_naddr = j; 92 | return 1; 93 | } 94 | 95 | static int 96 | expsetup(struct nfsctl_export *exparg, nfs_export *exp, int unexport) 97 | { 98 | nfs_client *clp = exp->m_client; 99 | struct stat stb; 100 | 101 | if (stat(exp->m_export.e_path, &stb) < 0) 102 | return 0; 103 | 104 | memset(exparg, 0, sizeof(*exparg)); 105 | strncpy(exparg->ex_path, exp->m_export.e_path, 106 | sizeof (exparg->ex_path) - 1); 107 | strncpy(exparg->ex_client, clp->m_hostname, 108 | sizeof (exparg->ex_client) - 1); 109 | str_tolower(exparg->ex_client); 110 | exparg->ex_flags = exp->m_export.e_flags; 111 | exparg->ex_dev = (!unexport && (exp->m_export.e_flags & NFSEXP_FSID)) ? 112 | (__nfsd_dev_t)exp->m_export.e_fsid : stb.st_dev; 113 | exparg->ex_ino = stb.st_ino; 114 | exparg->ex_anon_uid = exp->m_export.e_anonuid; 115 | exparg->ex_anon_gid = exp->m_export.e_anongid; 116 | 117 | return 1; 118 | } 119 | -------------------------------------------------------------------------------- /support/export/rmtab.c: -------------------------------------------------------------------------------- 1 | /* 2 | * support/export/rmtab.c 3 | * 4 | * Interface to the rmtab file. 5 | * 6 | */ 7 | 8 | #ifdef HAVE_CONFIG_H 9 | #include 10 | #endif 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "misc.h" 17 | #include "nfslib.h" 18 | #include "exportfs.h" 19 | #include "xio.h" 20 | #include "xlog.h" 21 | 22 | /* 23 | * See if the entry already exists. If not, 24 | * this was an instantiated wild card, and we 25 | * must add it. 26 | */ 27 | static void 28 | rmtab_read_wildcard(struct rmtabent *rep) 29 | { 30 | nfs_export *exp, *exp2; 31 | struct addrinfo *ai; 32 | 33 | ai = host_addrinfo(rep->r_client); 34 | if (ai == NULL) 35 | return; 36 | 37 | exp = export_allowed(ai, rep->r_path); 38 | freeaddrinfo(ai); 39 | if (exp == NULL) 40 | return; 41 | 42 | exp2 = export_lookup(rep->r_client, exp->m_export.e_path, 0); 43 | if (exp2 == NULL) { 44 | struct exportent ee; 45 | 46 | memset(&ee, 0, sizeof(ee)); 47 | dupexportent(&ee, &exp->m_export); 48 | 49 | ee.e_hostname = rep->r_client; 50 | exp2 = export_create(&ee, 0); 51 | exp2->m_changed = exp->m_changed; 52 | } 53 | exp2->m_mayexport = 1; 54 | } 55 | 56 | int 57 | rmtab_read(void) 58 | { 59 | struct rmtabent *rep; 60 | 61 | setrmtabent("r"); 62 | while ((rep = getrmtabent(1, NULL)) != NULL) { 63 | int htype; 64 | 65 | htype = client_gettype(rep->r_client); 66 | if (htype == MCL_FQDN || htype == MCL_SUBNETWORK) 67 | rmtab_read_wildcard(rep); 68 | } 69 | 70 | if (errno == EINVAL) { 71 | /* Something goes wrong. We need to fix the rmtab 72 | file. */ 73 | int lockid; 74 | FILE *fp; 75 | if ((lockid = xflock(_PATH_RMTABLCK, "w")) < 0) 76 | return -1; 77 | rewindrmtabent(); 78 | if (!(fp = fsetrmtabent(_PATH_RMTABTMP, "w"))) { 79 | endrmtabent (); 80 | xfunlock(lockid); 81 | return -1; 82 | } 83 | while ((rep = getrmtabent(0, NULL)) != NULL) { 84 | fputrmtabent(fp, rep, NULL); 85 | } 86 | if (rename(_PATH_RMTABTMP, _PATH_RMTAB) < 0) { 87 | xlog(L_ERROR, "couldn't rename %s to %s", 88 | _PATH_RMTABTMP, _PATH_RMTAB); 89 | } 90 | endrmtabent(); 91 | fendrmtabent(fp); 92 | xfunlock(lockid); 93 | } 94 | else { 95 | endrmtabent(); 96 | } 97 | return 0; 98 | } 99 | -------------------------------------------------------------------------------- /support/include/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | SUBDIRS = nfs rpcsvc sys 4 | 5 | noinst_HEADERS = \ 6 | cld.h \ 7 | exportfs.h \ 8 | ha-callout.h \ 9 | misc.h \ 10 | nfs_mntent.h \ 11 | nfs_paths.h \ 12 | nfslib.h \ 13 | nfsrpc.h \ 14 | nls.h \ 15 | nsm.h \ 16 | pseudoflavors.h \ 17 | rpcmisc.h \ 18 | sockaddr.h \ 19 | tcpwrapper.h \ 20 | v4root.h \ 21 | xio.h \ 22 | xlog.h \ 23 | xmalloc.h \ 24 | xcommon.h \ 25 | conffile.h 26 | 27 | MAINTAINERCLEANFILES = Makefile.in 28 | -------------------------------------------------------------------------------- /support/include/cld.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Upcall description for nfsdcld communication 3 | * 4 | * Copyright (c) 2012 Red Hat, Inc. 5 | * Author(s): Jeff Layton 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef _NFSD_CLD_H 23 | #define _NFSD_CLD_H 24 | 25 | /* latest upcall version available */ 26 | #define CLD_UPCALL_VERSION 1 27 | 28 | /* defined by RFC3530 */ 29 | #define NFS4_OPAQUE_LIMIT 1024 30 | 31 | enum cld_command { 32 | Cld_Create, /* create a record for this cm_id */ 33 | Cld_Remove, /* remove record of this cm_id */ 34 | Cld_Check, /* is this cm_id allowed? */ 35 | Cld_GraceDone, /* grace period is complete */ 36 | }; 37 | 38 | /* representation of long-form NFSv4 client ID */ 39 | struct cld_name { 40 | uint16_t cn_len; /* length of cm_id */ 41 | unsigned char cn_id[NFS4_OPAQUE_LIMIT]; /* client-provided */ 42 | } __attribute__((packed)); 43 | 44 | /* message struct for communication with userspace */ 45 | struct cld_msg { 46 | uint8_t cm_vers; /* upcall version */ 47 | uint8_t cm_cmd; /* upcall command */ 48 | int16_t cm_status; /* return code */ 49 | uint32_t cm_xid; /* transaction id */ 50 | union { 51 | int64_t cm_gracetime; /* grace period start time */ 52 | struct cld_name cm_name; 53 | } __attribute__((packed)) cm_u; 54 | } __attribute__((packed)); 55 | 56 | #endif /* !_NFSD_CLD_H */ 57 | -------------------------------------------------------------------------------- /support/include/conffile.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefanha/nfs-utils/708a963f5eb1892e39db1470d46429d8d8e17e38/support/include/conffile.h -------------------------------------------------------------------------------- /support/include/ha-callout.h: -------------------------------------------------------------------------------- 1 | /* 2 | * support/include/ha-callout.h 3 | * 4 | * High Availability NFS Callout support routines 5 | * 6 | * Copyright (c) 2004, Paul Clements, SteelEye Technology 7 | * 8 | * In order to implement HA NFS, we need several callouts at key 9 | * points in statd and mountd. These callouts all come to ha_callout(), 10 | * which, in turn, calls out to an ha-callout script (not part of nfs-utils; 11 | * defined by -H argument to rpc.statd and rpc.mountd). 12 | */ 13 | #ifndef HA_CALLOUT_H 14 | #define HA_CALLOUT_H 15 | 16 | #include 17 | #include 18 | 19 | extern char *ha_callout_prog; 20 | 21 | static inline void 22 | ha_callout(char *event, char *arg1, char *arg2, int arg3) 23 | { 24 | char buf[16]; /* should be plenty */ 25 | pid_t pid; 26 | int ret = -1; 27 | struct sigaction oldact, newact; 28 | 29 | if (!ha_callout_prog) /* HA callout is not enabled */ 30 | return; 31 | 32 | sprintf(buf, "%d", arg3); 33 | 34 | /* many daemons ignore SIGCHLD as tcpwrappers will 35 | * fork a child to do logging. We need to wait 36 | * for a child here, so we need to un-ignore 37 | * SIGCHLD temporarily 38 | */ 39 | newact.sa_handler = SIG_DFL; 40 | newact.sa_flags = 0; 41 | sigemptyset(&newact.sa_mask); 42 | sigaction(SIGCHLD, &newact, &oldact); 43 | pid = fork(); 44 | switch (pid) { 45 | case 0: execl(ha_callout_prog, ha_callout_prog, 46 | event, arg1, arg2, 47 | arg3 < 0 ? NULL : buf, 48 | NULL); 49 | perror("execl"); 50 | _exit(2); 51 | case -1: perror("fork"); 52 | break; 53 | default: pid = waitpid(pid, &ret, 0); 54 | } 55 | sigaction(SIGCHLD, &oldact, &newact); 56 | xlog(D_GENERAL, "ha callout returned %d\n", WEXITSTATUS(ret)); 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /support/include/misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * misc.h All that didn't fit elsewhere. 3 | * 4 | * Copyright (C) 1995 Olaf Kirch 5 | */ 6 | 7 | #ifndef MISC_H 8 | #define MISC_H 9 | 10 | /* 11 | * Generate random key, returning the length of the result. Currently, 12 | * weakrandomkey generates a maximum of 20 bytes are generated, but this 13 | * may change with future implementations. 14 | */ 15 | int randomkey(unsigned char *keyout, int len); 16 | int weakrandomkey(unsigned char *keyout, int len); 17 | 18 | extern int is_mountpoint(char *path); 19 | 20 | /* size of the file pointer buffers for rpc procfs files */ 21 | #define RPC_CHAN_BUF_SIZE 32768 22 | 23 | #endif /* MISC_H */ 24 | -------------------------------------------------------------------------------- /support/include/nfs/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | noinst_HEADERS = debug.h export.h nfs.h 4 | 5 | MAINTAINERCLEANFILES = Makefile.in 6 | -------------------------------------------------------------------------------- /support/include/nfs/debug.h: -------------------------------------------------------------------------------- 1 | #ifndef _NFS_DEBUG_H 2 | #define _NFS_DEBUG_H 3 | 4 | /* 5 | * RPC debug facilities 6 | */ 7 | #define RPCDBG_XPRT 0x0001 8 | #define RPCDBG_CALL 0x0002 9 | #define RPCDBG_DEBUG 0x0004 10 | #define RPCDBG_NFS 0x0008 11 | #define RPCDBG_AUTH 0x0010 12 | #define RPCDBG_BIND 0x0020 13 | #define RPCDBG_SCHED 0x0040 14 | #define RPCDBG_TRANS 0x0080 15 | #define RPCDBG_SVCSOCK 0x0100 16 | #define RPCDBG_SVCDSP 0x0200 17 | #define RPCDBG_MISC 0x0400 18 | #define RPCDBG_CACHE 0x0800 19 | #define RPCDBG_ALL 0x7fff 20 | 21 | /* 22 | * Declarations for the sysctl debug interface, which allows to read or 23 | * change the debug flags for rpc, nfs, nfsd, and lockd. Since the sunrpc 24 | * module currently registers its sysctl table dynamically, the sysctl path 25 | * for module FOO is . 26 | */ 27 | #define CTL_SUNRPC 7249 /* arbitrary and hopefully unused */ 28 | 29 | enum { 30 | CTL_RPCDEBUG = 1, 31 | CTL_NFSDEBUG, 32 | CTL_NFSDDEBUG, 33 | CTL_NLMDEBUG, 34 | }; 35 | 36 | 37 | /* 38 | * knfsd debug flags 39 | */ 40 | #define NFSDDBG_SOCK 0x0001 41 | #define NFSDDBG_FH 0x0002 42 | #define NFSDDBG_EXPORT 0x0004 43 | #define NFSDDBG_SVC 0x0008 44 | #define NFSDDBG_PROC 0x0010 45 | #define NFSDDBG_FILEOP 0x0020 46 | #define NFSDDBG_AUTH 0x0040 47 | #define NFSDDBG_REPCACHE 0x0080 48 | #define NFSDDBG_XDR 0x0100 49 | #define NFSDDBG_LOCKD 0x0200 50 | #define NFSDDBG_ALL 0x7FFF 51 | #define NFSDDBG_NOCHANGE 0xFFFF 52 | 53 | /* 54 | * Debug flags 55 | */ 56 | #define NLMDBG_SVC 0x0001 57 | #define NLMDBG_CLIENT 0x0002 58 | #define NLMDBG_CLNTLOCK 0x0004 59 | #define NLMDBG_SVCLOCK 0x0008 60 | #define NLMDBG_MONITOR 0x0010 61 | #define NLMDBG_CLNTSUBS 0x0020 62 | #define NLMDBG_SVCSUBS 0x0040 63 | #define NLMDBG_HOSTCACHE 0x0080 64 | #define NLMDBG_XDR 0x0100 65 | #define NLMDBG_ALL 0x7fff 66 | 67 | 68 | #define NFSDBG_VFS 0x0001 69 | #define NFSDBG_DIRCACHE 0x0002 70 | #define NFSDBG_LOOKUPCACHE 0x0004 71 | #define NFSDBG_PAGECACHE 0x0008 72 | #define NFSDBG_PROC 0x0010 73 | #define NFSDBG_XDR 0x0020 74 | #define NFSDBG_FILE 0x0040 75 | #define NFSDBG_ROOT 0x0080 76 | #define NFSDBG_CALLBACK 0x0100 77 | #define NFSDBG_CLIENT 0x0200 78 | #define NFSDBG_MOUNT 0x0400 79 | #define NFSDBG_FSCACHE 0x0800 80 | #define NFSDBG_PNFS 0x1000 81 | #define NFSDBG_PNFS_LD 0x2000 82 | #define NFSDBG_STATE 0x4000 83 | #define NFSDBG_ALL 0xFFFF 84 | 85 | #endif /* _NFS_DEBUG_H */ 86 | -------------------------------------------------------------------------------- /support/include/nfs/export.h: -------------------------------------------------------------------------------- 1 | #ifndef _NSF_EXPORT_H 2 | #define _NSF_EXPORT_H 3 | 4 | /* 5 | * Important limits for the exports stuff. 6 | */ 7 | #define NFSCLNT_IDMAX 1024 8 | #define NFSCLNT_ADDRMAX 16 9 | #define NFSCLNT_KEYMAX 32 10 | 11 | /* 12 | * Export flags. 13 | */ 14 | #define NFSEXP_READONLY 0x0001 15 | #define NFSEXP_INSECURE_PORT 0x0002 16 | #define NFSEXP_ROOTSQUASH 0x0004 17 | #define NFSEXP_ALLSQUASH 0x0008 18 | #define NFSEXP_ASYNC 0x0010 19 | #define NFSEXP_GATHERED_WRITES 0x0020 20 | #define NFSEXP_NOREADDIRPLUS 0x0040 21 | /* 80, 100 unused */ 22 | #define NFSEXP_NOHIDE 0x0200 23 | #define NFSEXP_NOSUBTREECHECK 0x0400 24 | #define NFSEXP_NOAUTHNLM 0x0800 25 | #define NFSEXP_FSID 0x2000 26 | #define NFSEXP_CROSSMOUNT 0x4000 27 | #define NFSEXP_NOACL 0x8000 /* reserved for possible ACL related use */ 28 | #define NFSEXP_V4ROOT 0x10000 29 | #define NFSEXP_PNFS 0x20000 30 | /* 31 | * All flags supported by the kernel before addition of the 32 | * export_features interface: 33 | */ 34 | #define NFSEXP_OLDFLAGS 0x7E3F 35 | /* 36 | * Flags that can vary per flavor, for kernels before addition of the 37 | * export_features interface: 38 | */ 39 | #define NFSEXP_OLD_SECINFO_FLAGS (NFSEXP_READONLY | NFSEXP_ROOTSQUASH \ 40 | | NFSEXP_ALLSQUASH) 41 | 42 | #endif /* _NSF_EXPORT_H */ 43 | -------------------------------------------------------------------------------- /support/include/nfs_mntent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 2006-06-08 Amit Gud 3 | * - Moved code snippets here from util-linux/mount/my_mntent.h 4 | */ 5 | 6 | #ifndef _NFS_MNTENT_H 7 | #define _NFS_MNTENT_H 8 | #include 9 | 10 | #define ERR_MAX 5 11 | 12 | typedef struct mntFILEstruct { 13 | FILE *mntent_fp; 14 | char *mntent_file; 15 | int mntent_lineno; 16 | int mntent_errs; 17 | int mntent_softerrs; 18 | } mntFILE; 19 | 20 | mntFILE *nfs_setmntent (const char *file, char *mode); 21 | void nfs_endmntent (mntFILE *mfp); 22 | int nfs_addmntent (mntFILE *mfp, struct mntent *mnt); 23 | struct nfs_mntent *my_getmntent (mntFILE *mfp); 24 | struct mntent *nfs_getmntent (mntFILE *mfp); 25 | 26 | #endif /* _NFS_MNTENT_H */ 27 | -------------------------------------------------------------------------------- /support/include/nfs_paths.h: -------------------------------------------------------------------------------- 1 | #ifndef _NFS_PATHS_H 2 | #define _NFS_PATHS_H 3 | 4 | #ifndef _PATH_MOUNTED 5 | #define _PATH_MOUNTED "/etc/fstab" 6 | #endif 7 | #define MOUNTED_LOCK _PATH_MOUNTED "~" 8 | #define MOUNTED_TEMP _PATH_MOUNTED ".tmp" 9 | 10 | #endif /* _NFS_PATHS_H */ 11 | 12 | -------------------------------------------------------------------------------- /support/include/nls.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 2006-06-08 Amit Gud 3 | * - Copied to nfs-utils/support/include from util-linux/mount 4 | */ 5 | 6 | #ifndef LOCALEDIR 7 | #define LOCALEDIR "/usr/share/locale" 8 | #endif 9 | 10 | #ifdef ENABLE_NLS 11 | # include 12 | # define _(Text) gettext (Text) 13 | # ifdef gettext_noop 14 | # define N_(String) gettext_noop (String) 15 | # else 16 | # define N_(String) (String) 17 | # endif 18 | #else 19 | # undef bindtextdomain 20 | # define bindtextdomain(Domain, Directory) /* empty */ 21 | # undef textdomain 22 | # define textdomain(Domain) /* empty */ 23 | # define _(Text) (Text) 24 | # define N_(Text) (Text) 25 | #endif 26 | 27 | 28 | -------------------------------------------------------------------------------- /support/include/nsm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 Oracle. All rights reserved. 3 | * 4 | * This file is part of nfs-utils. 5 | * 6 | * nfs-utils is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * nfs-utils is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with nfs-utils. If not, see . 18 | */ 19 | 20 | /* 21 | * NSM for Linux. 22 | */ 23 | 24 | #ifndef NFS_UTILS_SUPPORT_NSM_H 25 | #define NFS_UTILS_SUPPORT_NSM_H 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | #include 33 | 34 | #include "sm_inter.h" 35 | 36 | typedef unsigned int 37 | (*nsm_populate_t)(const char *hostname, 38 | const struct sockaddr *sap, 39 | const struct mon *mon, 40 | const time_t timestamp); 41 | 42 | /* file.c */ 43 | 44 | extern _Bool nsm_setup_pathnames(const char *progname, 45 | const char *parentdir); 46 | extern _Bool nsm_is_default_parentdir(void); 47 | extern _Bool nsm_drop_privileges(const int pidfd); 48 | 49 | extern int nsm_get_state(_Bool update); 50 | extern void nsm_update_kernel_state(const int state); 51 | 52 | extern unsigned int 53 | nsm_retire_monitored_hosts(void); 54 | extern unsigned int 55 | nsm_load_monitor_list(nsm_populate_t func); 56 | extern unsigned int 57 | nsm_load_notify_list(nsm_populate_t func); 58 | 59 | extern _Bool nsm_insert_monitored_host(const char *hostname, 60 | const struct sockaddr *sap, const struct mon *m); 61 | extern void nsm_delete_monitored_host(const char *hostname, 62 | const char *mon_name, const char *my_name, 63 | const int chatty); 64 | extern void nsm_delete_notified_host(const char *hostname, 65 | const char *mon_name, const char *my_name); 66 | extern size_t nsm_priv_to_hex(const char *priv, char *buf, 67 | const size_t buflen); 68 | 69 | /* rpc.c */ 70 | 71 | #define NSM_MAXMSGSIZE (2048u) 72 | 73 | extern uint32_t nsm_xmit_getport(const int sock, 74 | const struct sockaddr_in *sin, 75 | const unsigned long program, 76 | const unsigned long version); 77 | extern uint32_t nsm_xmit_getaddr(const int sock, 78 | const struct sockaddr_in6 *sin6, 79 | const rpcprog_t program, const rpcvers_t version); 80 | extern uint32_t nsm_xmit_rpcbind(const int sock, const struct sockaddr *sap, 81 | const rpcprog_t program, const rpcvers_t version); 82 | extern uint32_t nsm_xmit_notify(const int sock, const struct sockaddr *sap, 83 | const socklen_t salen, const rpcprog_t program, 84 | const char *mon_name, const int state); 85 | extern uint32_t nsm_xmit_nlmcall(const int sock, const struct sockaddr *sap, 86 | const socklen_t salen, const struct mon *m, 87 | const int state); 88 | extern uint32_t nsm_parse_reply(XDR *xdrs); 89 | extern unsigned long 90 | nsm_recv_getport(XDR *xdrs); 91 | extern uint16_t nsm_recv_getaddr(XDR *xdrs); 92 | extern uint16_t nsm_recv_rpcbind(const sa_family_t family, XDR *xdrs); 93 | 94 | #endif /* !NFS_UTILS_SUPPORT_NSM_H */ 95 | -------------------------------------------------------------------------------- /support/include/pseudoflavors.h: -------------------------------------------------------------------------------- 1 | #define RPC_AUTH_GSS_KRB5 390003 2 | #define RPC_AUTH_GSS_KRB5I 390004 3 | #define RPC_AUTH_GSS_KRB5P 390005 4 | #define RPC_AUTH_GSS_LKEY 390006 5 | #define RPC_AUTH_GSS_LKEYI 390007 6 | #define RPC_AUTH_GSS_LKEYP 390008 7 | 8 | struct flav_info { 9 | char *flavour; 10 | int fnum; 11 | }; 12 | 13 | extern struct flav_info flav_map[]; 14 | extern const int flav_map_size; 15 | -------------------------------------------------------------------------------- /support/include/rpcmisc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rpcmisc Support for RPC startup, dispatching and logging. 3 | * 4 | * Copyright (C) 1995 Olaf Kirch 5 | */ 6 | 7 | #ifndef RPCMISC_H 8 | #define RPCMISC_H 9 | 10 | #include 11 | #include 12 | 13 | #ifdef __STDC__ 14 | # define CONCAT(a,b) a##b 15 | # define STRING(a) #a 16 | #else 17 | # define CONCAT(a,b) a/**/b 18 | # define STRING(a) "a" 19 | #endif 20 | 21 | typedef bool_t (*rpcsvc_fn_t)(struct svc_req *, void *argp, void *resp); 22 | 23 | struct rpc_dentry { 24 | const char *name; 25 | rpcsvc_fn_t func; 26 | xdrproc_t xdr_arg_fn; /* argument XDR */ 27 | size_t xdr_arg_size; 28 | xdrproc_t xdr_res_fn; /* result XDR */ 29 | size_t xdr_res_size; 30 | }; 31 | 32 | struct rpc_dtable { 33 | struct rpc_dentry *entries; 34 | rpcproc_t nproc; 35 | }; 36 | 37 | #define dtable_ent(func, vers, arg_type, res_type) \ 38 | { STRING(func), \ 39 | (rpcsvc_fn_t)func##_##vers##_svc, \ 40 | (xdrproc_t)xdr_##arg_type, sizeof(arg_type), \ 41 | (xdrproc_t)xdr_##res_type, sizeof(res_type), \ 42 | } 43 | 44 | void nfs_svc_unregister(const rpcprog_t program, 45 | const rpcvers_t version); 46 | unsigned int nfs_svc_create(char *name, const rpcprog_t program, 47 | const rpcvers_t version, 48 | void (*dispatch)(struct svc_req *, SVCXPRT *), 49 | const uint16_t port); 50 | void rpc_init(char *name, int prog, int vers, 51 | void (*dispatch)(struct svc_req *, SVCXPRT *), 52 | int defport); 53 | void rpc_dispatch(struct svc_req *rq, SVCXPRT *xprt, 54 | struct rpc_dtable *dtable, int nvers, 55 | void *argp, void *resp); 56 | int getservport(u_long number, const char *proto); 57 | 58 | extern int _rpcpmstart; 59 | extern unsigned int _rpcprotobits; 60 | extern int _rpcsvcdirty; 61 | 62 | static inline struct sockaddr_in *nfs_getrpccaller_in(SVCXPRT *xprt) 63 | { 64 | return (struct sockaddr_in *)(char *)svc_getcaller(xprt); 65 | } 66 | 67 | static inline struct sockaddr *nfs_getrpccaller(SVCXPRT *xprt) 68 | { 69 | return (struct sockaddr *)(char *)svc_getcaller(xprt); 70 | } 71 | 72 | #endif /* RPCMISC_H */ 73 | -------------------------------------------------------------------------------- /support/include/rpcsvc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | noinst_HEADERS = nfs_prot.h 4 | 5 | MAINTAINERCLEANFILES = Makefile.in 6 | -------------------------------------------------------------------------------- /support/include/sys/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | SUBDIRS = fs 4 | 5 | MAINTAINERCLEANFILES = Makefile.in 6 | -------------------------------------------------------------------------------- /support/include/sys/fs/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | noinst_HEADERS = ext2fs.h 4 | 5 | MAINTAINERCLEANFILES = Makefile.in 6 | -------------------------------------------------------------------------------- /support/include/sys/fs/ext2fs.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_FS_EXT2FS_H 2 | #define _SYS_FS_EXT2FS_H 3 | 4 | /* 5 | * ioctl commands 6 | */ 7 | #define EXT2_IOC_GETFLAGS _IOR('f', 1, long) 8 | #define EXT2_IOC_SETFLAGS _IOW('f', 2, long) 9 | #define EXT2_IOC_GETVERSION _IOR('v', 1, long) 10 | #define EXT2_IOC_SETVERSION _IOW('v', 2, long) 11 | 12 | /* 13 | * File system states 14 | */ 15 | #define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */ 16 | #define EXT2_ERROR_FS 0x0002 /* Errors detected */ 17 | 18 | /* 19 | * Mount flags 20 | */ 21 | #define EXT2_MOUNT_CHECK_NORMAL 0x0001 /* Do some more checks */ 22 | #define EXT2_MOUNT_CHECK_STRICT 0x0002 /* Do again more checks */ 23 | #define EXT2_MOUNT_CHECK (EXT2_MOUNT_CHECK_NORMAL | \ 24 | EXT2_MOUNT_CHECK_STRICT) 25 | #define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */ 26 | #define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */ 27 | #define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */ 28 | #define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */ 29 | #define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */ 30 | #define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */ 31 | 32 | #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt 33 | #define set_opt(o, opt) o |= EXT2_MOUNT_##opt 34 | #define test_opt(sb, opt) ((sb)->u.ext2_sb.s_mount_opt & \ 35 | EXT2_MOUNT_##opt) 36 | /* 37 | * Maximal mount counts between two filesystem checks 38 | */ 39 | #define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */ 40 | #define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */ 41 | 42 | #endif /* _SYS_FS_EXT2FS_H */ 43 | -------------------------------------------------------------------------------- /support/include/tcpwrapper.h: -------------------------------------------------------------------------------- 1 | #ifndef TCP_WRAPPER_H 2 | #define TCP_WRAPPER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | extern int from_local(const struct sockaddr *sap); 9 | extern int check_default(char *name, struct sockaddr *sap, 10 | const unsigned long program); 11 | 12 | #endif /* TCP_WRAPPER_H */ 13 | -------------------------------------------------------------------------------- /support/include/v4root.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Red Hat 3 | * support/include/v4root.h 4 | * 5 | * Support routines for dynamic pseudo roots. 6 | * 7 | */ 8 | 9 | #ifndef V4ROOT_H 10 | #define V4ROOT_H 11 | 12 | extern int v4root_needed; 13 | extern void v4root_set(void); 14 | 15 | #endif /* V4ROOT_H */ 16 | -------------------------------------------------------------------------------- /support/include/xcommon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * xcommon.h -- Support function prototypes. Functions are in xcommon.c. 3 | * 4 | * 2006-06-06 Amit Gud 5 | * - Moved code snippets from mount/sundries.h of util-linux 6 | * and merged code from support/nfs/xmalloc.c by Olaf Kirch here. 7 | */ 8 | 9 | #ifndef _XMALLOC_H 10 | #define _MALLOC_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #ifdef MAJOR_IN_MKDEV 21 | #include 22 | #elif defined(MAJOR_IN_SYSMACROS) 23 | #include 24 | #endif 25 | 26 | #define streq(s, t) (strcmp ((s), (t)) == 0) 27 | 28 | /* Functions in sundries.c that are used in mount.c and umount.c */ 29 | char *canonicalize (const char *path); 30 | void nfs_error (const char *fmt, ...); 31 | void *xmalloc (size_t size); 32 | void *xrealloc(void *p, size_t size); 33 | void xfree(void *); 34 | char *xstrdup (const char *s); 35 | char *xstrndup (const char *s, int n); 36 | char *xstrconcat2 (const char *, const char *); 37 | char *xstrconcat3 (const char *, const char *, const char *); 38 | char *xstrconcat4 (const char *, const char *, const char *, const char *); 39 | void die (int errcode, const char *fmt, ...); 40 | 41 | extern void die(int err, const char *fmt, ...); 42 | extern void (*at_die)(void); 43 | 44 | /* exit status - bits below are ORed */ 45 | #define EX_SUCCESS 0 /* no failure occurred */ 46 | #define EX_USAGE 1 /* incorrect invocation or permission */ 47 | #define EX_SYSERR 2 /* out of memory, cannot fork, ... */ 48 | #define EX_SOFTWARE 4 /* internal mount bug or wrong version */ 49 | #define EX_USER 8 /* user interrupt */ 50 | #define EX_FILEIO 16 /* problems writing, locking, ... mtab/fstab */ 51 | #define EX_FAIL 32 /* mount failure */ 52 | #define EX_SOMEOK 64 /* some mount succeeded */ 53 | #define EX_BG 256 /* retry in background (internal only) */ 54 | 55 | #endif /* XMALLOC_H */ 56 | -------------------------------------------------------------------------------- /support/include/xio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * xio.h Declarations for simple parsing functions. 3 | * 4 | */ 5 | 6 | #ifndef XIO_H 7 | #define XIO_H 8 | 9 | #include 10 | 11 | typedef struct XFILE { 12 | FILE *x_fp; 13 | int x_line; 14 | } XFILE; 15 | 16 | XFILE *xfopen(char *fname, char *type); 17 | int xflock(char *fname, char *type); 18 | void xfunlock(int lockid); 19 | void xfclose(XFILE *xfp); 20 | int xgettok(XFILE *xfp, char sepa, char *tok, int len); 21 | int xgetc(XFILE *xfp); 22 | void xungetc(int c, XFILE *xfp); 23 | void xskip(XFILE *xfp, char *str); 24 | char xskipcomment(XFILE *xfp); 25 | 26 | #endif /* XIO_H */ 27 | -------------------------------------------------------------------------------- /support/include/xlog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * xlog Logging functionality 3 | * 4 | * Copyright (C) 1995 Olaf Kirch 5 | */ 6 | 7 | #ifndef XLOG_H 8 | #define XLOG_H 9 | 10 | #include 11 | 12 | /* These are logged always. L_FATAL also does exit(1) */ 13 | #define L_FATAL 0x0100 14 | #define L_ERROR 0x0200 15 | #define L_WARNING 0x0400 16 | #define L_NOTICE 0x0800 17 | #define L_ALL 0xFF00 18 | 19 | /* These are logged if enabled with xlog_[s]config */ 20 | /* NB: code does not expect ORing together D_ and L_ */ 21 | #define D_GENERAL 0x0001 /* general debug info */ 22 | #define D_CALL 0x0002 23 | #define D_AUTH 0x0004 24 | #define D_FAC3 0x0008 25 | #define D_FAC4 0x0010 26 | #define D_FAC5 0x0020 27 | #define D_PARSE 0x0040 28 | #define D_FAC7 0x0080 29 | #define D_ALL 0x00FF 30 | 31 | /* This can be used to define symbolic log names that can be passed to 32 | * xlog_config. */ 33 | struct xlog_debugfac { 34 | char *df_name; 35 | int df_fac; 36 | }; 37 | 38 | extern int export_errno; 39 | void xlog_open(char *progname); 40 | void xlog_stderr(int on); 41 | void xlog_syslog(int on); 42 | void xlog_config(int fac, int on); 43 | void xlog_sconfig(char *, int on); 44 | int xlog_enabled(int fac); 45 | void xlog(int fac, const char *fmt, ...); 46 | void xlog_warn(const char *fmt, ...); 47 | void xlog_err(const char *fmt, ...); 48 | void xlog_errno(int err, const char *fmt, ...); 49 | void xlog_backend(int fac, const char *fmt, va_list args); 50 | 51 | #endif /* XLOG_H */ 52 | -------------------------------------------------------------------------------- /support/include/xmalloc.h: -------------------------------------------------------------------------------- 1 | #include "xcommon.h" 2 | -------------------------------------------------------------------------------- /support/misc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | noinst_LIBRARIES = libmisc.a 4 | libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c 5 | 6 | MAINTAINERCLEANFILES = Makefile.in 7 | -------------------------------------------------------------------------------- /support/misc/mountpoint.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * check if a given path is a mountpoint 4 | */ 5 | 6 | #include 7 | #include "xcommon.h" 8 | #include 9 | 10 | int 11 | is_mountpoint(char *path) 12 | { 13 | /* Check if 'path' is a current mountpoint. 14 | * Possibly we should also check it is the mountpoint of the 15 | * filesystem holding the target directory, but there doesn't 16 | * seem a lot of point. 17 | * 18 | * We deem it to be a mountpoint if appending a ".." gives a different 19 | * device or the same inode number. 20 | */ 21 | char *dotdot; 22 | struct stat stb, pstb; 23 | int rv; 24 | 25 | dotdot = xmalloc(strlen(path)+4); 26 | 27 | strcat(strcpy(dotdot, path), "/.."); 28 | if (lstat(path, &stb) != 0 || 29 | lstat(dotdot, &pstb) != 0) 30 | rv = 0; 31 | else 32 | if (stb.st_dev != pstb.st_dev || 33 | stb.st_ino == pstb.st_ino) 34 | rv = 1; 35 | else 36 | rv = 0; 37 | free(dotdot); 38 | return rv; 39 | } 40 | -------------------------------------------------------------------------------- /support/nfs/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | noinst_LIBRARIES = libnfs.a 4 | libnfs_a_SOURCES = exports.c rmtab.c xio.c rpcmisc.c rpcdispatch.c \ 5 | xlog.c xcommon.c wildmat.c mydaemon.c nfsclient.c \ 6 | nfsexport.c getfh.c nfsctl.c rpc_socket.c getport.c \ 7 | svc_socket.c cacheio.c closeall.c nfs_mntent.c conffile.c \ 8 | svc_create.c atomicio.c strlcpy.c strlcat.c 9 | 10 | MAINTAINERCLEANFILES = Makefile.in 11 | 12 | -------------------------------------------------------------------------------- /support/nfs/atomicio.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 Marius Aamodt Eriksen 3 | * Copyright (c) 1995,1999 Theo de Raadt. All rights reserved. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | /* 32 | * ensure all of data on socket comes through. f==read || f==write 33 | */ 34 | ssize_t atomicio(ssize_t(*f) (int, void *, size_t), int fd, void *_s, size_t n) 35 | { 36 | char *s = _s; 37 | ssize_t res, pos = 0; 38 | 39 | while ((ssize_t)n > pos) { 40 | res = (f) (fd, s + pos, n - pos); 41 | switch (res) { 42 | case -1: 43 | if (errno == EINTR || errno == EAGAIN) 44 | continue; 45 | case 0: 46 | if (pos != 0) 47 | return pos; 48 | return res; 49 | default: 50 | pos += res; 51 | } 52 | } 53 | return pos; 54 | } 55 | -------------------------------------------------------------------------------- /support/nfs/closeall.c: -------------------------------------------------------------------------------- 1 | /* 2 | * support/nfs/closeall.c 3 | * Close all file descriptors greater than some limit, 4 | * Use readdir "/proc/self/fd" to avoid excess close(2) calls. 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | void 13 | closeall(int min) 14 | { 15 | char *endp; 16 | long n; 17 | DIR *dir = opendir("/proc/self/fd"); 18 | 19 | if (dir != NULL) { 20 | int dfd = dirfd(dir); 21 | struct dirent *d; 22 | 23 | while ((d = readdir(dir)) != NULL) { 24 | errno = 0; 25 | n = strtol(d->d_name, &endp, 10); 26 | if (!errno && *endp == '\0' && endp != d->d_name && 27 | n >= min && n != dfd) 28 | (void) close(n); 29 | } 30 | closedir(dir); 31 | } else { 32 | int fd = sysconf(_SC_OPEN_MAX); 33 | while (--fd >= min) 34 | if(fd >= 0) 35 | (void) close(fd); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /support/nfs/conffile.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefanha/nfs-utils/708a963f5eb1892e39db1470d46429d8d8e17e38/support/nfs/conffile.c -------------------------------------------------------------------------------- /support/nfs/nfsclient.c: -------------------------------------------------------------------------------- 1 | /* 2 | * support/nfs/client.c 3 | * 4 | * Add or delete an NFS client in knfsd. 5 | * 6 | * Copyright (C) 1995, 1996 Olaf Kirch 7 | */ 8 | 9 | #ifdef HAVE_CONFIG_H 10 | #include 11 | #endif 12 | 13 | #include 14 | #include "nfslib.h" 15 | 16 | int 17 | nfsaddclient(struct nfsctl_client *clp) 18 | { 19 | struct nfsctl_arg arg; 20 | 21 | arg.ca_version = NFSCTL_VERSION; 22 | memcpy(&arg.ca_client, clp, sizeof(arg.ca_client)); 23 | return nfsctl(NFSCTL_ADDCLIENT, &arg, NULL); 24 | } 25 | 26 | int 27 | nfsdelclient(struct nfsctl_client *clp) 28 | { 29 | struct nfsctl_arg arg; 30 | 31 | arg.ca_version = NFSCTL_VERSION; 32 | memcpy(&arg.ca_client, clp, sizeof(arg.ca_client)); 33 | return nfsctl(NFSCTL_DELCLIENT, &arg, NULL); 34 | } 35 | -------------------------------------------------------------------------------- /support/nfs/nfsctl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * support/nfs/nfsctl.c 3 | * 4 | * Central syscall to the nfsd kernel module. 5 | * 6 | * Copyright (C) 1995, 1996 Olaf Kirch 7 | */ 8 | 9 | #ifdef HAVE_CONFIG_H 10 | #include 11 | #endif 12 | 13 | #include 14 | #include 15 | #include 16 | #include "nfslib.h" 17 | 18 | /* compatibility hack... */ 19 | #if !defined(__NR_nfsctl) && defined(__NR_nfsservctl) 20 | #define __NR_nfsctl __NR_nfsservctl 21 | #endif 22 | 23 | int 24 | nfsctl (int cmd, struct nfsctl_arg * argp, union nfsctl_res * resp) 25 | { 26 | #ifdef __NR_nfsctl 27 | return syscall (__NR_nfsctl, cmd, argp, resp); 28 | #else 29 | errno = ENOSYS; 30 | return -1; 31 | #endif 32 | } 33 | -------------------------------------------------------------------------------- /support/nfs/rpcdispatch.c: -------------------------------------------------------------------------------- 1 | /* 2 | * support/nfs/rcpdispatch.c 3 | * 4 | * Generic RPC dispatcher. 5 | * 6 | * Copyright (C) 1995, 1996, Olaf Kirch 7 | */ 8 | 9 | #ifdef HAVE_CONFIG_H 10 | #include 11 | #endif 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include "rpcmisc.h" 21 | #include "xlog.h" 22 | 23 | void 24 | rpc_dispatch(struct svc_req *rqstp, SVCXPRT *transp, 25 | struct rpc_dtable *dtable, int nvers, 26 | void *argp, void *resp) 27 | { 28 | struct rpc_dentry *dent; 29 | 30 | if (((int)rqstp->rq_vers) > nvers) { 31 | svcerr_progvers(transp, 1, nvers); 32 | return; 33 | } 34 | dtable += (rqstp->rq_vers - 1); 35 | if (rqstp->rq_proc > dtable->nproc) { 36 | svcerr_noproc(transp); 37 | return; 38 | } 39 | 40 | if (dtable->nproc <= rqstp->rq_proc) { 41 | svcerr_noproc(transp); 42 | return; 43 | } 44 | 45 | dent = dtable->entries + rqstp->rq_proc; 46 | 47 | if (dent->func == NULL) { 48 | svcerr_noproc(transp); 49 | return; 50 | } 51 | 52 | memset(argp, 0, dent->xdr_arg_size); 53 | memset(resp, 0, dent->xdr_res_size); 54 | 55 | if (!svc_getargs(transp, dent->xdr_arg_fn, argp)) { 56 | svcerr_decode(transp); 57 | return; 58 | } 59 | 60 | if ((dent->func)(rqstp, argp, resp) && resp != 0) { 61 | if (!svc_sendreply(transp, dent->xdr_res_fn, (caddr_t)resp)) 62 | svcerr_systemerr(transp); 63 | } 64 | if (!svc_freeargs(transp, dent->xdr_arg_fn, argp)) { 65 | xlog(L_ERROR, "failed to free RPC arguments"); 66 | exit (2); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /support/nfs/strlcat.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: strlcat.c,v 1.8 2001/05/13 15:40:15 deraadt Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1998 Todd C. Miller 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 20 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 21 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 24 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #if defined(LIBC_SCCS) && !defined(lint) 31 | static char *rcsid = "$OpenBSD: strlcat.c,v 1.8 2001/05/13 15:40:15 deraadt Exp $"; 32 | #endif /* LIBC_SCCS and not lint */ 33 | 34 | #include 35 | #include 36 | 37 | #ifdef HAVE_CONFIG_H 38 | #include "config.h" 39 | #endif /* HAVE_CONFIG_H */ 40 | 41 | /* 42 | * Appends src to string dst of size siz (unlike strncat, siz is the 43 | * full size of dst, not space left). At most siz-1 characters 44 | * will be copied. Always NUL terminates (unless siz <= strlen(dst)). 45 | * Returns strlen(src) + MIN(siz, strlen(initial dst)). 46 | * If retval >= siz, truncation occurred. 47 | */ 48 | size_t 49 | strlcat(char *dst, 50 | const char *src, 51 | size_t siz) 52 | { 53 | register char *d = dst; 54 | register const char *s = src; 55 | register size_t n = siz; 56 | size_t dlen; 57 | 58 | /* Find the end of dst and adjust bytes left but don't go past end */ 59 | while (n-- != 0 && *d != '\0') 60 | d++; 61 | dlen = d - dst; 62 | n = siz - dlen; 63 | 64 | if (n == 0) 65 | return(dlen + strlen(s)); 66 | while (*s != '\0') { 67 | if (n != 1) { 68 | *d++ = *s; 69 | n--; 70 | } 71 | s++; 72 | } 73 | *d = '\0'; 74 | 75 | return(dlen + (s - src)); /* count does not include NUL */ 76 | } 77 | -------------------------------------------------------------------------------- /support/nfs/strlcpy.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1998 Todd C. Miller 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 20 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 21 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 24 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #if defined(LIBC_SCCS) && !defined(lint) 31 | static char *rcsid = "$OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp $"; 32 | #endif /* LIBC_SCCS and not lint */ 33 | 34 | #include 35 | #include 36 | 37 | #ifdef HAVE_CONFIG_H 38 | #include "config.h" 39 | #endif /* HAVE_CONFIG_H */ 40 | 41 | /* 42 | * Copy src to string dst of size siz. At most siz-1 characters 43 | * will be copied. Always NUL terminates (unless siz == 0). 44 | * Returns strlen(src); if retval >= siz, truncation occurred. 45 | */ 46 | size_t 47 | strlcpy(char *dst, 48 | const char *src, 49 | size_t siz) 50 | { 51 | register char *d = dst; 52 | register const char *s = src; 53 | register size_t n = siz; 54 | 55 | /* Copy as many bytes as will fit */ 56 | if (n != 0 && --n != 0) { 57 | do { 58 | if ((*d++ = *s++) == 0) 59 | break; 60 | } while (--n != 0); 61 | } 62 | 63 | /* Not enough room in dst, add NUL and traverse rest of src */ 64 | if (n == 0) { 65 | if (siz != 0) 66 | *d = '\0'; /* NUL-terminate dst */ 67 | while (*s++) 68 | ; 69 | } 70 | 71 | return(s - src - 1); /* count does not include NUL */ 72 | } 73 | -------------------------------------------------------------------------------- /support/nsm/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | GENFILES_CLNT = sm_inter_clnt.c 4 | GENFILES_SVC = sm_inter_svc.c 5 | GENFILES_XDR = sm_inter_xdr.c 6 | GENFILES_H = sm_inter.h 7 | 8 | GENFILES = $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H) 9 | 10 | EXTRA_DIST = sm_inter.x 11 | 12 | noinst_LIBRARIES = libnsm.a 13 | libnsm_a_SOURCES = $(GENFILES) file.c rpc.c 14 | 15 | BUILT_SOURCES = $(GENFILES) 16 | 17 | if CONFIG_RPCGEN 18 | RPCGEN = $(top_builddir)/tools/rpcgen/rpcgen 19 | $(RPCGEN): 20 | make -C ../../tools/rpcgen all 21 | else 22 | RPCGEN = @RPCGEN_PATH@ 23 | endif 24 | 25 | $(GENFILES_CLNT): %_clnt.c: %.x $(RPCGEN) 26 | test -f $@ && rm -rf $@ || true 27 | $(RPCGEN) -l -o $@ $< 28 | 29 | $(GENFILES_SVC): %_svc.c: %.x $(RPCGEN) 30 | test -f $@ && rm -rf $@ || true 31 | $(RPCGEN) -m -o $@ $< 32 | 33 | $(GENFILES_XDR): %_xdr.c: %.x $(RPCGEN) 34 | test -f $@ && rm -rf $@ || true 35 | $(RPCGEN) -c -o $@ $< 36 | 37 | $(GENFILES_H): %.h: %.x $(RPCGEN) 38 | test -f $@ && rm -rf $@ || true 39 | $(RPCGEN) -h -o $@ $< 40 | rm -f $(top_builddir)/support/include/sm_inter.h 41 | $(LN_S) ../nsm/sm_inter.h $(top_builddir)/support/include/sm_inter.h 42 | 43 | MAINTAINERCLEANFILES = Makefile.in 44 | 45 | CLEANFILES = $(GENFILES) $(top_builddir)/support/include/sm_inter.h 46 | -------------------------------------------------------------------------------- /systemd/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | MAINTAINERCLEANFILES = Makefile.in 4 | 5 | unit_files = \ 6 | nfs-client.target \ 7 | \ 8 | nfs-config.service \ 9 | nfs-mountd.service \ 10 | nfs-server.service \ 11 | nfs-utils.service \ 12 | rpc-statd-notify.service \ 13 | rpc-statd.service \ 14 | \ 15 | proc-fs-nfsd.mount \ 16 | var-lib-nfs-rpc_pipefs.mount 17 | 18 | if CONFIG_NFSV4 19 | unit_files += \ 20 | nfs-idmapd.service 21 | endif 22 | 23 | if CONFIG_NFSV41 24 | unit_files += \ 25 | nfs-blkmap.service 26 | endif 27 | 28 | if CONFIG_GSS 29 | unit_files += \ 30 | auth-rpcgss-module.service \ 31 | rpc-gssd.service 32 | 33 | if CONFIG_SVCGSS 34 | unit_files += \ 35 | rpc-svcgssd.service 36 | endif 37 | endif 38 | 39 | EXTRA_DIST = $(unit_files) 40 | 41 | unit_dir = /usr/lib/systemd/system 42 | generator_dir = /usr/lib/systemd/system-generators 43 | 44 | EXTRA_PROGRAMS = nfs-server-generator 45 | genexecdir = $(generator_dir) 46 | nfs_server_generator_LDADD = ../support/export/libexport.a \ 47 | ../support/nfs/libnfs.a \ 48 | ../support/misc/libmisc.a 49 | 50 | if INSTALL_SYSTEMD 51 | genexec_PROGRAMS = nfs-server-generator 52 | install-data-hook: $(unit_files) 53 | mkdir -p $(DESTDIR)/$(unitdir) 54 | cp $(unit_files) $(DESTDIR)/$(unitdir) 55 | endif 56 | -------------------------------------------------------------------------------- /systemd/README: -------------------------------------------------------------------------------- 1 | 2 | Notes about systemd unit files for nfs-utils. 3 | 4 | The unit files provided here should be sufficient for systemd 5 | to manage all daemons and related services provides by nfs-utils. 6 | 7 | They do *not* include any unit files for separate services such as 8 | rpc.rquotad (in the 'quota' package) or rpcbind. 9 | 10 | There are 4 units that can be 'enabled' or 'disabled' by systemctl, or 11 | by a suitable 'preset' setting: 12 | 13 | nfs-server.service 14 | If enabled, nfs service is started together with dependencies 15 | such as mountd, statd, rpc.idmapd 16 | This is a "service" file rather than a "target" (which is the 17 | normal grouping construct) so that 18 | systemctl start nfs-server 19 | can work (if no type is given, ".service" is assumed). 20 | 21 | nfs-client.target 22 | If enabled, daemons needs for an nfs client are enabled. 23 | This does *not* include rpc.statd. the rpc-statd.service unit 24 | is started by /usr/sbin/start-statd which mount.nfs will run 25 | if statd is needed. 26 | 27 | nfs-blkmap.service 28 | If enabled, then blkmapd will be run when nfs-client.target is 29 | started. 30 | 31 | Another special unit is "nfs-utils.service". This doesn't really do 32 | anything, but exists so that other units may declare themselves as 33 | "PartOf" nfs-utils.service. 34 | The effect of this is that 35 | systemctl restart nfs-utils 36 | will restart all nfs-utils daemons as maybe be required during 37 | software update. It isn't possible to make 38 | systemctl try-restart nfs-server nfs-client.target 39 | do this as some daemon are included in both, and rpc.statd would 40 | not be restarted if nfs-server were not active (as nfs-client doesn't 41 | Want it - it is started by mount.nfs running start-statd). 42 | 43 | It is possible that we should have an nfs-statd.target which can 44 | selectively enable statd being stared by -server and sm-notify 45 | being started by -server or -client. That way it could be disabled 46 | completely on V4-only configurations. Currently statd is always 47 | started on the server and sm-notify is always run if server or 48 | client is enabled. 49 | 50 | Stopping nfs-server will also stop rpc.mountd, and rpc.svcgssd. 51 | It cannot stop rpc.statd or rpc.gssd as they may be in use by the 52 | client and systemd cannot specify is two-pronged reverse dependency. 53 | (i.e. stop this unit if none of these units are running) 54 | 55 | Distro specific commandline configuration can be provided by 56 | installing a script /usr/libexec/nfs-utils/nfs-utils_env.sh 57 | This should write /run/sysconfig/nfs-utils based on configuration 58 | information such as in /etc/sysconfig/nfs or /etc/defaults/nfs. 59 | It is run once by nfs-config.service. 60 | 61 | rpc.gssd and rpc.svcgssd are assumed to be needed if /etc/krb5.keytab 62 | is present. 63 | If a site needs this file present but does not want the gss daemons 64 | running, it should create 65 | /etc/systemd/system/rpc-gssd.service.d/01-disable.conf 66 | and 67 | /etc/systemd/system/rpc-svcgssd.service.d/01-disable.conf 68 | 69 | containing 70 | [Unit] 71 | ConditionNull=false 72 | -------------------------------------------------------------------------------- /systemd/auth-rpcgss-module.service: -------------------------------------------------------------------------------- 1 | # We want to start gss-proxy on kernels that support it and rpc.svcgssd 2 | # on those that don't. Those services check for support by checking 3 | # for existence of the path /proc/net/rpc/use-gss-proxy. Before they 4 | # can perform that check, they need this module loaded. (Unless 5 | # rpcsec_gss support is built directly into the kernel, in which case this 6 | # unit will fail. But that's OK.) 7 | [Unit] 8 | Description=Kernel Module supporting RPCSEC_GSS 9 | DefaultDependencies=no 10 | Before=gssproxy.service rpc-svcgssd.service rpc-gssd.service 11 | Wants=gssproxy.service rpc-svcgssd.service rpc-gssd.service 12 | ConditionPathExists=/etc/krb5.keytab 13 | 14 | [Service] 15 | Type=oneshot 16 | ExecStart=/sbin/modprobe -q auth_rpcgss 17 | -------------------------------------------------------------------------------- /systemd/nfs-blkmap.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=pNFS block layout mapping daemon 3 | DefaultDependencies=no 4 | Conflicts=umount.target 5 | After=var-lib-nfs-rpc_pipefs.mount 6 | Requires=var-lib-nfs-rpc_pipefs.mount 7 | 8 | PartOf=nfs-utils.service 9 | 10 | [Service] 11 | Type=forking 12 | PIDFile=/var/run/blkmapd.pid 13 | EnvironmentFile=-/run/sysconfig/nfs-utils 14 | ExecStart=/usr/sbin/blkmapd $BLKMAPDARGS 15 | 16 | [Install] 17 | WantedBy=nfs-client.target 18 | -------------------------------------------------------------------------------- /systemd/nfs-client.target: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=NFS client services 3 | Before=remote-fs-pre.target 4 | Wants=remote-fs-pre.target 5 | 6 | # Note: we don't "Wants=rpc-statd.service" as "mount.nfs" will arrange to 7 | # start that on demand if needed. 8 | Wants=rpc-statd-notify.service 9 | 10 | # GSS services dependencies and ordering 11 | Wants=auth-rpcgss-module.service 12 | After=rpc-gssd.service rpc-svcgssd.service gssproxy.service 13 | 14 | [Install] 15 | WantedBy=multi-user.target 16 | WantedBy=remote-fs.target 17 | -------------------------------------------------------------------------------- /systemd/nfs-config.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Preprocess NFS configuration 3 | After=local-fs.target 4 | DefaultDependencies=no 5 | 6 | [Service] 7 | Type=oneshot 8 | # This service needs to run any time any nfs service 9 | # is started, so changes to local config files get 10 | # incorporated. Having "RemainAfterExit=no" (the default) 11 | # ensures this happens. 12 | RemainAfterExit=no 13 | ExecStart=@_libexecdir@/nfs-utils/nfs-utils_env.sh 14 | -------------------------------------------------------------------------------- /systemd/nfs-idmapd.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=NFSv4 ID-name mapping service 3 | DefaultDependencies=no 4 | Requires=var-lib-nfs-rpc_pipefs.mount 5 | After=var-lib-nfs-rpc_pipefs.mount local-fs.target 6 | 7 | BindsTo=nfs-server.service 8 | 9 | Wants=nfs-config.service 10 | After=nfs-config.service 11 | 12 | [Service] 13 | EnvironmentFile=-/run/sysconfig/nfs-utils 14 | Type=forking 15 | ExecStart=/usr/sbin/rpc.idmapd $RPCIDMAPDARGS 16 | -------------------------------------------------------------------------------- /systemd/nfs-mountd.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=NFS Mount Daemon 3 | DefaultDependencies=no 4 | Requires=proc-fs-nfsd.mount 5 | After=proc-fs-nfsd.mount 6 | After=network.target local-fs.target 7 | BindsTo=nfs-server.service 8 | 9 | Wants=nfs-config.service 10 | After=nfs-config.service 11 | 12 | [Service] 13 | EnvironmentFile=-/run/sysconfig/nfs-utils 14 | Type=forking 15 | ExecStart=/usr/sbin/rpc.mountd $RPCMOUNTDARGS 16 | -------------------------------------------------------------------------------- /systemd/nfs-server.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=NFS server and services 3 | DefaultDependencies=no 4 | Requires= network.target proc-fs-nfsd.mount 5 | Requires= nfs-mountd.service 6 | Wants=rpcbind.socket 7 | Wants=rpc-statd.service nfs-idmapd.service 8 | Wants=rpc-statd-notify.service 9 | 10 | After= local-fs.target 11 | After= network.target proc-fs-nfsd.mount rpcbind.socket nfs-mountd.service 12 | After= nfs-idmapd.service rpc-statd.service 13 | Before= rpc-statd-notify.service 14 | 15 | # GSS services dependencies and ordering 16 | Wants=auth-rpcgss-module.service 17 | After=rpc-gssd.service gssproxy.service rpc-svcgssd.service 18 | 19 | Wants=nfs-config.service 20 | After=nfs-config.service 21 | 22 | [Service] 23 | EnvironmentFile=-/run/sysconfig/nfs-utils 24 | 25 | Type=oneshot 26 | RemainAfterExit=yes 27 | ExecStartPre=/usr/sbin/exportfs -r 28 | ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS 29 | ExecStop=/usr/sbin/rpc.nfsd 0 30 | ExecStopPost=/usr/sbin/exportfs -au 31 | ExecStopPost=/usr/sbin/exportfs -f 32 | 33 | ExecReload=/usr/sbin/exportfs -r 34 | 35 | [Install] 36 | WantedBy=multi-user.target 37 | -------------------------------------------------------------------------------- /systemd/nfs-utils.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=NFS server and client services 3 | # This service should never be stopped, only restarted. 4 | # When it is re-started, all other services which declare 5 | # themselves to be "PartOf" this service will also be 6 | # restarted. Thus 7 | # systemctl restart nfs-utils 8 | # will restart all daemons which are part of nfs-utils 9 | # and which are running. This is useful after a software 10 | # update. 11 | 12 | # This is a "service" rather than "target" so that we 13 | # don't need to say "systemctl restart nfs-utils.target". 14 | [Service] 15 | Type=oneshot 16 | RemainAfterExit=yes 17 | ExecStart=/bin/true 18 | -------------------------------------------------------------------------------- /systemd/proc-fs-nfsd.mount: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=NFSD configuration filesystem 3 | 4 | [Mount] 5 | What=nfsd 6 | Where=/proc/fs/nfsd 7 | Type=nfsd 8 | -------------------------------------------------------------------------------- /systemd/rpc-gssd.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=RPC security service for NFS client and server 3 | DefaultDependencies=no 4 | Conflicts=umount.target 5 | Requires=var-lib-nfs-rpc_pipefs.mount 6 | After=var-lib-nfs-rpc_pipefs.mount 7 | 8 | ConditionPathExists=@_sysconfdir@/krb5.keytab 9 | 10 | PartOf=nfs-utils.service 11 | 12 | Wants=nfs-config.service 13 | After=nfs-config.service 14 | 15 | [Service] 16 | EnvironmentFile=-/run/sysconfig/nfs-utils 17 | 18 | Type=forking 19 | ExecStart=/usr/sbin/rpc.gssd $GSSDARGS 20 | -------------------------------------------------------------------------------- /systemd/rpc-statd-notify.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Notify NFS peers of a restart 3 | DefaultDependencies=no 4 | Requires=network.target 5 | After=local-fs.target network.target nss-lookup.target 6 | 7 | # if we run an nfs server, it needs to be running before we 8 | # tell clients that it has restarted. 9 | After=nfs-server.service 10 | 11 | PartOf=nfs-utils.service 12 | 13 | Wants=nfs-config.service 14 | After=nfs-config.service 15 | 16 | [Service] 17 | EnvironmentFile=-/run/sysconfig/nfs-utils 18 | Type=forking 19 | ExecStart=-/usr/sbin/sm-notify $SMNOTIFYARGS 20 | -------------------------------------------------------------------------------- /systemd/rpc-statd.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=NFS status monitor for NFSv2/3 locking. 3 | DefaultDependencies=no 4 | Conflicts=umount.target 5 | Requires=nss-lookup.target rpcbind.socket 6 | After=network.target nss-lookup.target rpcbind.socket 7 | 8 | PartOf=nfs-utils.service 9 | 10 | Wants=nfs-config.service 11 | After=nfs-config.service 12 | 13 | [Service] 14 | EnvironmentFile=-/run/sysconfig/nfs-utils 15 | Type=forking 16 | PIDFile=/var/run/rpc.statd.pid 17 | ExecStart=/usr/sbin/rpc.statd --no-notify $STATDARGS 18 | -------------------------------------------------------------------------------- /systemd/rpc-svcgssd.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=RPC security service for NFS server 3 | DefaultDependencies=no 4 | Requires=var-lib-nfs-rpc_pipefs.mount 5 | After=var-lib-nfs-rpc_pipefs.mount local-fs.target 6 | PartOf=nfs-server.service 7 | PartOf=nfs-utils.service 8 | 9 | After=gssproxy.service 10 | ConditionPathExists=|!/run/gssproxy.pid 11 | ConditionPathExists=|!/proc/net/rpc/use-gss-proxy 12 | ConditionPathExists=/etc/krb5.keytab 13 | 14 | Wants=nfs-config.service 15 | After=nfs-config.service 16 | 17 | [Service] 18 | EnvironmentFile=-/run/sysconfig/nfs-utils 19 | Type=forking 20 | ExecStart=/usr/sbin/rpc.svcgssd $SVCGSSDARGS 21 | -------------------------------------------------------------------------------- /systemd/var-lib-nfs-rpc_pipefs.mount: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=RPC Pipe File System 3 | DefaultDependencies=no 4 | After=systemd-tmpfiles-setup.service 5 | Conflicts=umount.target 6 | 7 | [Mount] 8 | What=sunrpc 9 | Where=/var/lib/nfs/rpc_pipefs 10 | Type=rpc_pipefs 11 | -------------------------------------------------------------------------------- /tests/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | check_PROGRAMS = statdb_dump 4 | statdb_dump_SOURCES = statdb_dump.c 5 | 6 | statdb_dump_LDADD = ../support/nfs/libnfs.a \ 7 | ../support/nsm/libnsm.a $(LIBCAP) 8 | 9 | SUBDIRS = nsm_client 10 | 11 | MAINTAINERCLEANFILES = Makefile.in 12 | 13 | TESTS = t0001-statd-basic-mon-unmon.sh 14 | EXTRA_DIST = test-lib.sh $(TESTS) 15 | -------------------------------------------------------------------------------- /tests/nsm_client/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | GENFILES_CLNT = nlm_sm_inter_clnt.c 4 | GENFILES_SVC = nlm_sm_inter_svc.c 5 | GENFILES_XDR = nlm_sm_inter_xdr.c 6 | GENFILES_H = nlm_sm_inter.h 7 | 8 | GENFILES = $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H) 9 | 10 | EXTRA_DIST = nlm_sm_inter.x 11 | 12 | check_PROGRAMS = nsm_client 13 | nsm_client_SOURCES = $(GENFILES) nsm_client.c 14 | 15 | BUILT_SOURCES = $(GENFILES) 16 | nsm_client_LDADD = ../../support/nfs/libnfs.a \ 17 | ../../support/nsm/libnsm.a $(LIBCAP) $(LIBTIRPC) 18 | 19 | if CONFIG_RPCGEN 20 | RPCGEN = $(top_builddir)/tools/rpcgen/rpcgen 21 | $(RPCGEN): 22 | make -C ../../tools/rpcgen all 23 | else 24 | RPCGEN = @RPCGEN_PATH@ 25 | endif 26 | 27 | $(GENFILES_CLNT): %_clnt.c: %.x $(RPCGEN) 28 | test -f $@ && rm -rf $@ || true 29 | $(RPCGEN) -l -o $@ $< 30 | 31 | $(GENFILES_SVC): %_svc.c: %.x $(RPCGEN) 32 | test -f $@ && rm -rf $@ || true 33 | $(RPCGEN) -m -o $@ $< 34 | 35 | $(GENFILES_XDR): %_xdr.c: %.x $(RPCGEN) 36 | test -f $@ && rm -rf $@ || true 37 | $(RPCGEN) -c -o $@ $< 38 | 39 | $(GENFILES_H): %.h: %.x $(RPCGEN) 40 | test -f $@ && rm -rf $@ || true 41 | $(RPCGEN) -h -o $@ $< 42 | 43 | MAINTAINERCLEANFILES = Makefile.in 44 | 45 | CLEANFILES = $(GENFILES) 46 | 47 | -------------------------------------------------------------------------------- /tests/nsm_client/README: -------------------------------------------------------------------------------- 1 | The nsm_client program is intended for testing statd. It has the ability 2 | to act as a synthetic NSM client for sending artificial NSM calls to any 3 | host you choose. 4 | 5 | It also has an NLM simulator that implements the call that statd uses to 6 | communicate with lockd. The daemon simulator will start itself up, 7 | register as an NLM service and listen for "downcalls" from statd. When 8 | it gets one, it will log a message. 9 | 10 | Note that lockd will need to be down when using the daemon simulator. It 11 | also does not implement the entire NLM protocol and is only really 12 | useful for testing statd's downcall. 13 | -------------------------------------------------------------------------------- /tests/nsm_client/nlm_sm_inter.x: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1995, 1997-1999 Jeffrey A. Uphoff 3 | * Modified by Olaf Kirch, 1996. 4 | * Modified by H.J. Lu, 1998. 5 | * Modified by Jeff Layton, 2010. 6 | * 7 | * NLM similator for Linux 8 | */ 9 | 10 | #ifdef RPC_CLNT 11 | %#include 12 | #endif 13 | 14 | /* 15 | * statd rejects monitor registrations for any non-lockd services, so pretend 16 | * to be lockd when testing. Furthermore, the only call we care about from 17 | * statd is #16, which is the downcall to notify the kernel of a host's status 18 | * change. 19 | */ 20 | program NLM_SM_PROG { 21 | /* version 3 of the NLM protocol */ 22 | version NLM_SM_VERS3 { 23 | void NLM_SM_NOTIFY(struct nlm_sm_notify) = 16; 24 | } = 3; 25 | 26 | /* version 2 of NLM protocol */ 27 | version NLM_SM_VERS4 { 28 | void NLM_SM_NOTIFY(struct nlm_sm_notify) = 16; 29 | } = 4; 30 | } = 100021; 31 | 32 | const SM_MAXSTRLEN = 1024; 33 | const SM_PRIV_SIZE = 16; 34 | 35 | /* 36 | * structure of the status message sent back by the status monitor 37 | * when monitor site status changes 38 | */ 39 | struct nlm_sm_notify { 40 | string mon_name; 41 | int state; 42 | opaque priv[SM_PRIV_SIZE]; /* stored private information */ 43 | }; 44 | -------------------------------------------------------------------------------- /tests/statdb_dump.c: -------------------------------------------------------------------------------- 1 | /* 2 | * statdb_dump.c -- dump contents of statd's monitor DB 3 | * 4 | * Copyright (C) 2010 Red Hat, Jeff Layton 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include "config.h" 24 | #endif 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include "nsm.h" 31 | #include "xlog.h" 32 | 33 | static char cookiebuf[(SM_PRIV_SIZE * 2) + 1]; 34 | static char addrbuf[INET6_ADDRSTRLEN + 1]; 35 | 36 | static unsigned int 37 | dump_host(const char *hostname, const struct sockaddr *sa, const struct mon *m, 38 | const time_t timestamp) 39 | { 40 | int ret; 41 | const char *addr; 42 | const struct sockaddr_in *sin; 43 | const struct sockaddr_in6 *sin6; 44 | 45 | ret = nsm_priv_to_hex(m->priv, cookiebuf, sizeof(cookiebuf)); 46 | if (!ret) { 47 | xlog(L_ERROR, "Unable to convert cookie to hex string.\n"); 48 | return ret; 49 | } 50 | 51 | switch (sa->sa_family) { 52 | case AF_INET: 53 | sin = (struct sockaddr_in *)(char *)sa; 54 | addr = inet_ntop(sa->sa_family, &sin->sin_addr.s_addr, addrbuf, 55 | (socklen_t)sizeof(addrbuf)); 56 | break; 57 | case AF_INET6: 58 | sin6 = (struct sockaddr_in6 *)(char *)sa; 59 | addr = inet_ntop(sa->sa_family, &sin6->sin6_addr, addrbuf, 60 | (socklen_t)sizeof(addrbuf)); 61 | break; 62 | default: 63 | xlog(L_ERROR, "Unrecognized address family: %hu\n", 64 | sa->sa_family); 65 | return 0; 66 | } 67 | 68 | if (addr == NULL) { 69 | xlog(L_ERROR, "Unable to convert sockaddr to string: %s\n", 70 | strerror(errno)); 71 | return 0; 72 | } 73 | 74 | /* 75 | * Callers of this program should assume that in the future, extra 76 | * fields may be added to the output. Anyone adding extra fields to 77 | * the output should add them to the end of the line. 78 | */ 79 | printf("%s %s %s %s %s %d %d %d\n", 80 | hostname, addr, cookiebuf, 81 | m->mon_id.mon_name, 82 | m->mon_id.my_id.my_name, 83 | m->mon_id.my_id.my_prog, 84 | m->mon_id.my_id.my_vers, 85 | m->mon_id.my_id.my_proc); 86 | 87 | return 1; 88 | } 89 | 90 | int 91 | main(int argc, char **argv) 92 | { 93 | xlog_syslog(0); 94 | xlog_stderr(1); 95 | xlog_open(argv[0]); 96 | 97 | nsm_load_monitor_list(dump_host); 98 | return 0; 99 | } 100 | -------------------------------------------------------------------------------- /tests/t0001-statd-basic-mon-unmon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # statd_basic_mon_unmon -- test basic mon/unmon functionality with statd 4 | # 5 | # Copyright (C) 2010 Red Hat, Jeff Layton 6 | # 7 | # This program is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU General Public License 9 | # as published by the Free Software Foundation; either version 2 10 | # of the License, or (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software Foundation, Inc., 19 | # 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA 20 | # 21 | 22 | . ./test-lib.sh 23 | 24 | # This test needs root privileges 25 | check_root 26 | 27 | start_statd 28 | if [ $? -ne 0 ]; then 29 | echo "FAIL: problem starting statd" 30 | exit 1 31 | fi 32 | 33 | COOKIE=`echo $$ | md5sum | cut -d' ' -f1` 34 | MON_NAME=`hostname` 35 | 36 | nsm_client mon $MON_NAME $COOKIE 37 | if [ $? -ne 0 ]; then 38 | echo "FAIL: mon failed" 39 | kill_statd 40 | exit 1 41 | fi 42 | 43 | statdb_dump | grep $MON_NAME | grep -q $COOKIE 44 | if [ $? -ne 0 ]; then 45 | echo "FAIL: monitor DB doesn't seem to contain entry" 46 | kill_statd 47 | exit 1 48 | fi 49 | 50 | nsm_client unmon $MON_NAME 51 | if [ $? -ne 0 ]; then 52 | echo "FAIL: unmon failed" 53 | kill_statd 54 | exit 1 55 | fi 56 | 57 | kill_statd 58 | 59 | -------------------------------------------------------------------------------- /tests/test-lib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # test-lib.sh -- library of functions for nfs-utils tests 4 | # 5 | # Copyright (C) 2010 Red Hat, Jeff Layton 6 | # 7 | # This program is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU General Public License 9 | # as published by the Free Software Foundation; either version 2 10 | # of the License, or (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software Foundation, Inc., 19 | # 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA 20 | # 21 | 22 | # make sure $srcdir is set and sanity check it 23 | srcdir=${srcdir-.} 24 | if [ ! -d ${srcdir} ]; then 25 | echo "***ERROR***: bad installation -- \$srcdir=${srcdir}" 26 | exit 1 27 | fi 28 | 29 | export PATH=$PATH:${srcdir}:${srcdir}/nsm_client 30 | 31 | # Some tests require root privileges. Check for them and skip the test (exit 77) 32 | # if the caller doesn't have them. 33 | check_root() { 34 | if [ $EUID -ne 0 ]; then 35 | echo "*** Skipping this test as it requires root privs ***" 36 | exit 77 37 | fi 38 | } 39 | 40 | # is lockd registered as a service? 41 | lockd_registered() { 42 | rpcinfo -p | grep -q nlockmgr 43 | return $? 44 | } 45 | 46 | # start up statd 47 | start_statd() { 48 | rpcinfo -u 127.0.0.1 status 1 &> /dev/null 49 | if [ $? -eq 0 ]; then 50 | echo "***ERROR***: statd is already running and should " 51 | echo " be down when starting this test" 52 | return 1 53 | fi 54 | $srcdir/../utils/statd/statd --no-notify 55 | } 56 | 57 | # shut down statd 58 | kill_statd() { 59 | kill `cat /var/run/rpc.statd.pid` 60 | } 61 | -------------------------------------------------------------------------------- /tools/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | OPTDIRS = 4 | 5 | if CONFIG_RPCGEN 6 | OPTDIRS += rpcgen 7 | endif 8 | 9 | SUBDIRS = locktest rpcdebug nlmtest mountstats nfs-iostat $(OPTDIRS) 10 | 11 | MAINTAINERCLEANFILES = Makefile.in 12 | -------------------------------------------------------------------------------- /tools/locktest/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | CC=$(CC_FOR_BUILD) 4 | LIBTOOL = @LIBTOOL@ --tag=CC 5 | 6 | noinst_PROGRAMS = testlk 7 | testlk_SOURCES = testlk.c 8 | testlk_CFLAGS=$(CFLAGS_FOR_BUILD) 9 | testlk_CPPFLAGS=$(CPPFLAGS_FOR_BUILD) 10 | testlk_LDFLAGS=$(LDFLAGS_FOR_BUILD) 11 | 12 | MAINTAINERCLEANFILES = Makefile.in 13 | -------------------------------------------------------------------------------- /tools/locktest/testlk.c: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | #include 3 | #endif 4 | 5 | #include 6 | #include 7 | #include 8 | #ifdef linux 9 | #include 10 | #endif 11 | #include 12 | 13 | static void usage(int exval); 14 | static void fatal(char *); 15 | 16 | int 17 | main(int argc, char **argv) 18 | { 19 | unsigned long start = 0, len = 0; 20 | struct flock fl; 21 | int c, fd, cmd, typ; 22 | char *fname; 23 | 24 | typ = F_RDLCK; 25 | cmd = F_SETLK; 26 | 27 | while ((c = getopt(argc, argv, "bhrtw")) != EOF) { 28 | switch (c) { 29 | case 'h': 30 | usage(0); 31 | case 'r': 32 | cmd = F_SETLK; 33 | typ = F_RDLCK; 34 | break; 35 | case 'w': 36 | cmd = F_SETLK; 37 | typ = F_WRLCK; 38 | break; 39 | case 'b': 40 | cmd = F_SETLKW; 41 | typ = F_WRLCK; 42 | break; 43 | case 't': 44 | cmd = F_GETLK; 45 | break; 46 | case '?': 47 | usage(1); 48 | } 49 | } 50 | 51 | argc -= optind; 52 | argv += optind; 53 | 54 | if (argc <= 0 || argc > 3) 55 | usage(1); 56 | 57 | fname = argv[0]; 58 | /* printf("TP\n"); */ 59 | if (argc > 1) 60 | start = atoi(argv[1]); 61 | /* printf("TP\n"); */ 62 | if (argc > 2) 63 | len = atoi(argv[2]); 64 | /* printf("TP\n"); */ 65 | 66 | if ((fd = open(fname, O_RDWR, 0644)) < 0) 67 | fatal(fname); 68 | 69 | /* printf("TP1\n"); */ 70 | fl.l_type = typ; 71 | fl.l_whence = 0; 72 | fl.l_start = start; 73 | fl.l_len = len; 74 | 75 | if (fcntl(fd, cmd, &fl) < 0) 76 | fatal("fcntl"); 77 | printf("fcntl: ok\n"); 78 | 79 | /* printf("TP2\n"); */ 80 | if (cmd == F_GETLK) { 81 | if (fl.l_type == F_UNLCK) { 82 | printf("%s: no conflicting lock\n", fname); 83 | } else { 84 | printf("%s: conflicting lock by %d on (%lld;%lld)\n", 85 | fname, fl.l_pid, fl.l_start, fl.l_len); 86 | } 87 | return 0; 88 | } 89 | 90 | /* printf("TP3\n"); */ 91 | pause(); 92 | return 0; 93 | } 94 | 95 | static void 96 | usage(int exval) 97 | { 98 | fprintf(stderr, "usage: testlk filename [start [len]]\n"); 99 | exit(exval); 100 | } 101 | 102 | static void 103 | fatal(char *msg) 104 | { 105 | perror(msg); 106 | exit(2); 107 | } 108 | -------------------------------------------------------------------------------- /tools/mountstats/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | PYTHON_FILES = mountstats.py 3 | 4 | man8_MANS = mountstats.man 5 | 6 | EXTRA_DIST = $(man8_MANS) $(PYTHON_FILES) 7 | 8 | all-local: $(PYTHON_FILES) 9 | 10 | install-data-hook: 11 | $(INSTALL) -m 755 mountstats.py $(DESTDIR)$(sbindir)/mountstats 12 | 13 | MAINTAINERCLEANFILES=Makefile.in 14 | -------------------------------------------------------------------------------- /tools/nfs-iostat/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | PYTHON_FILES = nfs-iostat.py 3 | 4 | man8_MANS = nfsiostat.man 5 | 6 | EXTRA_DIST = $(man8_MANS) $(PYTHON_FILES) 7 | 8 | all-local: $(PYTHON_FILES) 9 | 10 | install-data-hook: 11 | $(INSTALL) -m 755 nfs-iostat.py $(DESTDIR)$(sbindir)/nfsiostat 12 | 13 | MAINTAINERCLEANFILES=Makefile.in 14 | -------------------------------------------------------------------------------- /tools/nlmtest/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | EXTRA_DIST = \ 4 | README \ 5 | host.h \ 6 | nlm_prot.x \ 7 | nlmtest.c 8 | -------------------------------------------------------------------------------- /tools/nlmtest/README: -------------------------------------------------------------------------------- 1 | 2 | This is a simple tool to test your lockd server. This is a very 3 | primitive program. To use it on your system, you have to edit 4 | host.h and adjust the inode and device numbers in nltest.c to 5 | suit your nfs server. 6 | -------------------------------------------------------------------------------- /tools/nlmtest/host.h: -------------------------------------------------------------------------------- 1 | /* 2 | * host.h 3 | * 4 | * Defaults for nlmtest 5 | */ 6 | 7 | #ifndef NLMTEST_HOST_H 8 | #define NLMTEST_HOST_H 9 | 10 | /* 11 | * The host on which lockd runs 12 | */ 13 | #define NLMTEST_HOST "crutch" 14 | 15 | /* 16 | * NFS mount point 17 | */ 18 | #define NLMTEST_DIR "../../mount/" 19 | 20 | /* 21 | * The default file name and its inode version number. 22 | * There's no way the test program can find out the version number, 23 | * so you have to add it here. 24 | */ 25 | #define NLMTEST_FILE NLMTEST_DIR "COPYING" 26 | #define NLMTEST_VERSION 1 27 | 28 | #endif /* NLMTEST_HOST_H */ 29 | -------------------------------------------------------------------------------- /tools/rpcdebug/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | man8_MANS = rpcdebug.man 4 | EXTRA_DIST = $(man8_MANS) 5 | 6 | sbin_PROGRAMS = rpcdebug 7 | rpcdebug_SOURCES = rpcdebug.c 8 | 9 | MAINTAINERCLEANFILES = Makefile.in 10 | -------------------------------------------------------------------------------- /tools/rpcdebug/rpcdebug.man: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" rpcdebug(8) 3 | .\" 4 | .\" By Greg Banks 5 | .\" Copyright (c) 2006 Silicon Graphics, Inc. 6 | .\" Derived from nfsstat.man which bore the message: 7 | .\" Copyright (C) 1996-2005 Olaf Kirch 8 | .TH rpcdebug 8 "5 Jul 2006" 9 | .SH NAME 10 | rpcdebug \- set and clear NFS and RPC kernel debug flags 11 | .SH SYNOPSIS 12 | \fBrpcdebug\fP \fB\-vh\fP 13 | .br 14 | \fBrpcdebug\fP \fB\-m\fP \fImodule\fP 15 | .br 16 | \fBrpcdebug\fP \fB\-m\fP \fImodule\fP \fB\-s\fP \fIflags\fP... 17 | .br 18 | \fBrpcdebug\fP \fB\-m\fP \fImodule\fP \fB\-c\fP \fIflags\fP... 19 | .br 20 | .SH DESCRIPTION 21 | The \fBrpcdebug\fP command allows an administrator to set and clear 22 | the Linux kernel's NFS client and server debug flags. Setting these 23 | flags causes the kernel to emit messages to the system log in response 24 | to NFS activity; this is typically useful when debugging NFS problems. 25 | .PP 26 | The first form in the synopsis can be used to list all available 27 | debug flags. The second form shows the currently set debug flags 28 | for the given module. The third form sets one or more flags, and 29 | the fourth form clears one or more flags. 30 | .PP 31 | The value \fBall\fP may be used to set or clear all the flags for 32 | the given module. 33 | .SH OPTIONS 34 | .\" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 35 | .TP 36 | .B \-c 37 | Clear the given debug flags. 38 | .\" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 39 | .TP 40 | .B \-h 41 | Print a help message and exit. When combined with the \fB\-v\fP 42 | option, also prints the available debug flags. 43 | .\" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 44 | .TP 45 | .BI \-m " module" 46 | Specify which module's flags to set or clear. Available 47 | modules are: 48 | .RS 49 | .TP 50 | .BR nfsd 51 | The NFS server. 52 | .TP 53 | .BR nfs 54 | The NFS client. 55 | .TP 56 | .BR nlm 57 | The Network Lock Manager, in either an NFS client or server. 58 | .TP 59 | .BR rpc 60 | The Remote Procedure Call module, in either an NFS client or server. 61 | .RE 62 | .\" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 63 | .TP 64 | .B \-s 65 | Set the given debug flags. 66 | .\" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 67 | .TP 68 | .B \-v 69 | Increase the verbosity of \fBrpcdebug\fP's output. 70 | .\" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 71 | .SH FILES 72 | .TP 73 | .B /proc/sys/sunrpc/{rpc,nfs,nfsd,nlm}_debug 74 | procfs\-based interface to kernel debug flags. 75 | .\" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 76 | .SH SEE ALSO 77 | .BR rpc.nfsd (8), 78 | .BR nfs (5), 79 | .BR syslogd (8). 80 | .\" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 81 | .SH BUGS 82 | Bugs can be found or reported at 83 | .BR http://nfs.sf.net/ . 84 | .\" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 85 | .SH AUTHOR 86 | Program by Olaf Kirch and 87 | . 88 | Manpage by Greg Banks . 89 | -------------------------------------------------------------------------------- /tools/rpcgen/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | CC=$(CC_FOR_BUILD) 4 | LIBTOOL = @LIBTOOL@ --tag=CC 5 | 6 | noinst_PROGRAMS = rpcgen 7 | rpcgen_SOURCES = rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c \ 8 | rpc_parse.c rpc_scan.c rpc_svcout.c rpc_tblout.c \ 9 | rpc_util.c rpc_sample.c rpc_output.h rpc_parse.h \ 10 | rpc_scan.h rpc_util.h 11 | 12 | rpcgen_CFLAGS=$(CFLAGS_FOR_BUILD) 13 | rpcgen_CPPLAGS=$(CPPFLAGS_FOR_BUILD) 14 | rpcgen_LDFLAGS=$(LDFLAGS_FOR_BUILD) 15 | rpcgen_LDADD=$(LIBTIRPC) 16 | 17 | MAINTAINERCLEANFILES = Makefile.in 18 | 19 | EXTRA_DIST = rpcgen.new.1 20 | -------------------------------------------------------------------------------- /tools/rpcgen/README: -------------------------------------------------------------------------------- 1 | 2 | This directory contains the source for rpcgen.new from Sun TIRPC 3 | source distribution. I cleaned it up a little so that it will 4 | compile with gcc (without using -traditional), and modified the 5 | output to avoid those silly warnings you usually get when compiling 6 | an rpcgen-generated C file. 7 | 8 | Olaf Kirch 8 Oct 1996 9 | -------------------------------------------------------------------------------- /tools/rpcgen/rpc_output.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rpc_output.h 3 | * 4 | * Declarations for output functions 5 | * 6 | */ 7 | 8 | #ifndef RPCGEN_NEW_OUTPUT_H 9 | #define RPCGEN_NEW_OUTPUT_H 10 | 11 | void write_msg_out(void); 12 | int nullproc(proc_list *); 13 | void printarglist(proc_list *, char *, char *); 14 | void pdeclaration(char *, declaration *, int, char *); 15 | 16 | #endif /* RPCGEN_NEW_OUTPUT_H */ 17 | -------------------------------------------------------------------------------- /tools/rpcgen/rpc_scan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, Sun Microsystems, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of Sun Microsystems, Inc. nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /* @(#)rpc_scan.h 1.3 90/08/29 (C) 1987 SMI */ 30 | 31 | /* 32 | * rpc_scan.h, Definitions for the RPCL scanner 33 | */ 34 | 35 | /* 36 | * kinds of tokens 37 | */ 38 | enum tok_kind { 39 | TOK_IDENT, 40 | TOK_CHARCONST, 41 | TOK_STRCONST, 42 | TOK_LPAREN, 43 | TOK_RPAREN, 44 | TOK_LBRACE, 45 | TOK_RBRACE, 46 | TOK_LBRACKET, 47 | TOK_RBRACKET, 48 | TOK_LANGLE, 49 | TOK_RANGLE, 50 | TOK_STAR, 51 | TOK_COMMA, 52 | TOK_EQUAL, 53 | TOK_COLON, 54 | TOK_SEMICOLON, 55 | TOK_CONST, 56 | TOK_STRUCT, 57 | TOK_UNION, 58 | TOK_SWITCH, 59 | TOK_CASE, 60 | TOK_DEFAULT, 61 | TOK_ENUM, 62 | TOK_TYPEDEF, 63 | TOK_INT, 64 | TOK_SHORT, 65 | TOK_INT32, 66 | TOK_UNSIGNED, 67 | TOK_FLOAT, 68 | TOK_DOUBLE, 69 | TOK_OPAQUE, 70 | TOK_CHAR, 71 | TOK_STRING, 72 | TOK_BOOL, 73 | TOK_VOID, 74 | TOK_PROGRAM, 75 | TOK_VERSION, 76 | TOK_EOF 77 | }; 78 | typedef enum tok_kind tok_kind; 79 | 80 | /* 81 | * a token 82 | */ 83 | struct token { 84 | tok_kind kind; 85 | char *str; 86 | }; 87 | typedef struct token token; 88 | 89 | 90 | /* 91 | * routine interface 92 | */ 93 | void scan(); 94 | void scan2(); 95 | void scan3(); 96 | void scan_num(); 97 | void peek(); 98 | int peekscan(); 99 | void get_token(); 100 | void expected1(tok_kind); 101 | void expected2(tok_kind, tok_kind); 102 | void expected3(tok_kind, tok_kind, tok_kind); 103 | 104 | -------------------------------------------------------------------------------- /utils/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | OPTDIRS = 4 | 5 | if CONFIG_NFSV4 6 | OPTDIRS += idmapd 7 | if CONFIG_NFSIDMAP 8 | OPTDIRS += nfsidmap 9 | endif 10 | endif 11 | 12 | if CONFIG_NFSV41 13 | OPTDIRS += blkmapd 14 | endif 15 | 16 | if CONFIG_GSS 17 | OPTDIRS += gssd 18 | endif 19 | 20 | if CONFIG_MOUNT 21 | OPTDIRS += mount 22 | endif 23 | 24 | if CONFIG_NFSDCLTRACK 25 | OPTDIRS += nfsdcltrack 26 | endif 27 | 28 | SUBDIRS = \ 29 | exportfs \ 30 | mountd \ 31 | nfsd \ 32 | nfsstat \ 33 | showmount \ 34 | statd \ 35 | osd_login \ 36 | $(OPTDIRS) 37 | 38 | MAINTAINERCLEANFILES = Makefile.in 39 | -------------------------------------------------------------------------------- /utils/blkmapd/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | man8_MANS = blkmapd.man 4 | EXTRA_DIST = $(man8_MANS) 5 | 6 | AM_CFLAGS += -D_LARGEFILE64_SOURCE 7 | sbin_PROGRAMS = blkmapd 8 | 9 | blkmapd_SOURCES = \ 10 | device-discovery.c \ 11 | device-inq.c \ 12 | device-process.c \ 13 | dm-device.c \ 14 | device-discovery.h 15 | 16 | blkmapd_LDADD = -ldevmapper ../../support/nfs/libnfs.a 17 | 18 | MAINTAINERCLEANFILES = Makefile.in 19 | 20 | -------------------------------------------------------------------------------- /utils/blkmapd/blkmapd.man: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2011, Jim Rees. 3 | .\" 4 | .\" You may distribute under the terms of the GNU General Public 5 | .\" License as specified in the file COPYING that comes with the 6 | .\" nfs-utils distribution. 7 | .\" 8 | .TH blkmapd 8 "11 August 2011" 9 | .SH NAME 10 | blkmapd \- pNFS block layout mapping daemon 11 | .SH SYNOPSIS 12 | .B "blkmapd [-h] [-d] [-f]" 13 | .SH DESCRIPTION 14 | The 15 | .B blkmapd 16 | daemon performs device discovery and mapping for the parallel NFS (pNFS) block layout 17 | client [RFC5663]. 18 | .PP 19 | The pNFS block layout protocol builds a complex storage hierarchy from a set 20 | of 21 | .I simple volumes. 22 | These simple volumes are addressed by content, using a signature on the 23 | volume to uniquely name each one. 24 | The daemon locates a volume by examining each block device in the system for 25 | the given signature. 26 | .PP 27 | The topology typically consists of a hierarchy of volumes built by striping, 28 | slicing, and concatenating the simple volumes. 29 | The 30 | .B blkmapd 31 | daemon uses the device-mapper driver to construct logical devices that 32 | reflect the server topology, and passes these devices to the kernel for use 33 | by the pNFS block layout client. 34 | .SH OPTIONS 35 | .TP 36 | .B -h 37 | Display usage message. 38 | .TP 39 | .B -d 40 | Performs device discovery only then exits. 41 | .TP 42 | .B -f 43 | Runs 44 | .B blkmapd 45 | in the foreground and sends output to stderr (as opposed to syslogd) 46 | .SH SEE ALSO 47 | .BR nfs (5), 48 | .BR dmsetup (8) 49 | .sp 50 | RFC 5661 for the NFS version 4.1 specification. 51 | .br 52 | RFC 5663 for the pNFS block layout specification. 53 | .SH AUTHORS 54 | .br 55 | Haiying Tang 56 | .br 57 | Jim Rees 58 | -------------------------------------------------------------------------------- /utils/exportfs/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | man5_MANS = exports.man 4 | man7_MANS = nfsd.man 5 | man8_MANS = exportfs.man 6 | 7 | EXTRA_DIST = $(man5_MANS) $(man7_MANS) $(man8_MANS) 8 | sbin_PROGRAMS = exportfs 9 | exportfs_SOURCES = exportfs.c 10 | exportfs_LDADD = ../../support/export/libexport.a \ 11 | ../../support/nfs/libnfs.a \ 12 | ../../support/misc/libmisc.a \ 13 | $(LIBWRAP) $(LIBNSL) 14 | 15 | MAINTAINERCLEANFILES = Makefile.in 16 | -------------------------------------------------------------------------------- /utils/gssd/.gitignore: -------------------------------------------------------------------------------- 1 | gss_clnt_send_err 2 | gssd 3 | svcgssd 4 | -------------------------------------------------------------------------------- /utils/gssd/context.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2004 The Regents of the University of Michigan. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 3. Neither the name of the University nor the names of its 15 | contributors may be used to endorse or promote products derived 16 | from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifdef HAVE_CONFIG_H 32 | #include 33 | #endif /* HAVE_CONFIG_H */ 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include "gss_util.h" 42 | #include "gss_oids.h" 43 | #include "err_util.h" 44 | #include "context.h" 45 | 46 | int 47 | serialize_context_for_kernel(gss_ctx_id_t *ctx, 48 | gss_buffer_desc *buf, 49 | gss_OID mech, 50 | int32_t *endtime) 51 | { 52 | if (g_OID_equal(&krb5oid, mech)) 53 | return serialize_krb5_ctx(ctx, buf, endtime); 54 | else { 55 | printerr(0, "ERROR: attempting to serialize context with " 56 | "unknown/unsupported mechanism oid\n"); 57 | return -1; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /utils/gssd/context.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2004,2008 The Regents of the University of Michigan. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 3. Neither the name of the University nor the names of its 15 | contributors may be used to endorse or promote products derived 16 | from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _CONTEXT_H_ 32 | #define _CONTEXT_H_ 33 | 34 | #include 35 | 36 | /* Hopefully big enough to hold any serialized context */ 37 | #define MAX_CTX_LEN 4096 38 | 39 | /* New context format flag values */ 40 | #define KRB5_CTX_FLAG_INITIATOR 0x00000001 41 | #define KRB5_CTX_FLAG_CFX 0x00000002 42 | #define KRB5_CTX_FLAG_ACCEPTOR_SUBKEY 0x00000004 43 | 44 | int serialize_context_for_kernel(gss_ctx_id_t *ctx, gss_buffer_desc *buf, 45 | gss_OID mech, int32_t *endtime); 46 | int serialize_krb5_ctx(gss_ctx_id_t *ctx, gss_buffer_desc *buf, 47 | int32_t *endtime); 48 | 49 | #endif /* _CONTEXT_H_ */ 50 | -------------------------------------------------------------------------------- /utils/gssd/err_util.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2004 The Regents of the University of Michigan. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 3. Neither the name of the University nor the names of its 15 | contributors may be used to endorse or promote products derived 16 | from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifdef HAVE_CONFIG_H 32 | #include 33 | #endif /* HAVE_CONFIG_H */ 34 | 35 | #include 36 | #include 37 | #include 38 | #include "xlog.h" 39 | 40 | static int verbosity = 0; 41 | static int fg = 0; 42 | 43 | void initerr(char *progname, int set_verbosity, int set_fg) 44 | { 45 | verbosity = set_verbosity; 46 | fg = set_fg; 47 | if (!fg) 48 | xlog_open(progname); 49 | } 50 | 51 | 52 | void printerr(int priority, char *format, ...) 53 | { 54 | va_list args; 55 | 56 | /* Don't bother formatting a message we're never going to print! */ 57 | if (priority > verbosity) 58 | return; 59 | 60 | va_start(args, format); 61 | if (fg) 62 | vfprintf(stderr, format, args); 63 | else 64 | xlog_backend(L_ERROR, format, args); 65 | va_end(args); 66 | } 67 | 68 | int get_verbosity(void) 69 | { 70 | return verbosity; 71 | } 72 | -------------------------------------------------------------------------------- /utils/gssd/err_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2004 The Regents of the University of Michigan. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 3. Neither the name of the University nor the names of its 15 | contributors may be used to endorse or promote products derived 16 | from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _ERR_UTIL_H_ 32 | #define _ERR_UTIL_H_ 33 | 34 | void initerr(char *progname, int verbosity, int fg); 35 | void printerr(int priority, char *format, ...); 36 | int get_verbosity(void); 37 | 38 | #endif /* _ERR_UTIL_H_ */ 39 | -------------------------------------------------------------------------------- /utils/gssd/gss_names.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2000 The Regents of the University of Michigan. 3 | All rights reserved. 4 | 5 | Copyright (c) 2002 Bruce Fields 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. Neither the name of the University nor the names of its 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | extern int get_hostbased_client_name(gss_name_t client_name, gss_OID mech, 34 | char **hostbased_name); 35 | extern void get_hostbased_client_buffer(gss_name_t client_name, 36 | gss_OID mech, gss_buffer_t buf); 37 | -------------------------------------------------------------------------------- /utils/gssd/gss_oids.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2004 The Regents of the University of Michigan. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 3. Neither the name of the University nor the names of its 15 | contributors may be used to endorse or promote products derived 16 | from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifdef HAVE_CONFIG_H 32 | #include 33 | #endif /* HAVE_CONFIG_H */ 34 | 35 | #include 36 | #include 37 | 38 | /* from kerberos source, gssapi_krb5.c */ 39 | gss_OID_desc krb5oid = 40 | {9, "\052\206\110\206\367\022\001\002\002"}; 41 | -------------------------------------------------------------------------------- /utils/gssd/gss_oids.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2004 The Regents of the University of Michigan. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 3. Neither the name of the University nor the names of its 15 | contributors may be used to endorse or promote products derived 16 | from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _GSS_OIDS_H_ 32 | #define _GSS_OIDS_H_ 33 | 34 | #include 35 | 36 | extern gss_OID_desc krb5oid; 37 | 38 | #ifndef g_OID_equal 39 | #define g_OID_equal(o1,o2) \ 40 | (((o1)->length == (o2)->length) && \ 41 | (memcmp((o1)->elements,(o2)->elements,(unsigned int) (o1)->length) == 0)) 42 | #endif 43 | 44 | #endif /* _GSS_OIDS_H_ */ 45 | -------------------------------------------------------------------------------- /utils/gssd/gss_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2004 The Regents of the University of Michigan. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 3. Neither the name of the University nor the names of its 15 | contributors may be used to endorse or promote products derived 16 | from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _GSS_UTIL_H_ 32 | #define _GSS_UTIL_H_ 33 | 34 | #include 35 | #include 36 | #include "write_bytes.h" 37 | 38 | extern gss_cred_id_t gssd_creds; 39 | 40 | int gssd_acquire_cred(char *server_name, const gss_OID oid); 41 | void pgsserr(char *msg, u_int32_t maj_stat, u_int32_t min_stat, 42 | const gss_OID mech); 43 | int gssd_check_mechs(void); 44 | 45 | #ifndef HAVE_LIBGSSGLUE 46 | #include 47 | #define gss_free_lucid_sec_context(min, ctx, ret) \ 48 | gss_krb5_free_lucid_sec_context(min, ret) 49 | 50 | #define gss_export_lucid_sec_context gss_krb5_export_lucid_sec_context 51 | #define gss_set_allowable_enctypes(min, cred, oid, num, types) \ 52 | gss_krb5_set_allowable_enctypes(min, cred, num, types) 53 | #endif 54 | 55 | #endif /* _GSS_UTIL_H_ */ 56 | -------------------------------------------------------------------------------- /utils/gssd/krb5_util.h: -------------------------------------------------------------------------------- 1 | #ifndef KRB5_UTIL_H 2 | #define KRB5_UTIL_H 3 | 4 | #include 5 | 6 | #ifdef HAVE_LIBTIRPC 7 | #include 8 | #else 9 | #include "gss_oids.h" 10 | #endif 11 | 12 | /* 13 | * List of principals from our keytab that we 14 | * will try to use to obtain credentials 15 | * (known as a principal list entry (ple)) 16 | */ 17 | struct gssd_k5_kt_princ { 18 | struct gssd_k5_kt_princ *next; 19 | krb5_principal princ; 20 | char *ccname; 21 | char *realm; 22 | krb5_timestamp endtime; 23 | }; 24 | 25 | 26 | int gssd_setup_krb5_user_gss_ccache(uid_t uid, char *servername, 27 | char *dirname); 28 | int gssd_get_krb5_machine_cred_list(char ***list); 29 | void gssd_free_krb5_machine_cred_list(char **list); 30 | void gssd_destroy_krb5_machine_creds(void); 31 | int gssd_refresh_krb5_machine_credential(char *hostname, 32 | struct gssd_k5_kt_princ *ple, 33 | char *service); 34 | char *gssd_k5_err_msg(krb5_context context, krb5_error_code code); 35 | void gssd_k5_get_default_realm(char **def_realm); 36 | 37 | int gssd_acquire_user_cred(gss_cred_id_t *gss_cred); 38 | 39 | #ifdef HAVE_SET_ALLOWABLE_ENCTYPES 40 | extern int limit_to_legacy_enctypes; 41 | int limit_krb5_enctypes(struct rpc_gss_sec *sec); 42 | #endif 43 | 44 | /* 45 | * Hide away some of the MIT vs. Heimdal differences 46 | * here with macros... 47 | */ 48 | 49 | #ifdef HAVE_KRB5 50 | #define k5_free_unparsed_name(ctx, name) krb5_free_unparsed_name((ctx), (name)) 51 | #define k5_free_default_realm(ctx, realm) krb5_free_default_realm((ctx), (realm)) 52 | #define k5_free_kt_entry(ctx, kte) krb5_free_keytab_entry_contents((ctx),(kte)) 53 | #else /* Heimdal */ 54 | #define k5_free_unparsed_name(ctx, name) free(name) 55 | #define k5_free_default_realm(ctx, realm) free(realm) 56 | #define k5_free_kt_entry(ctx, kte) krb5_kt_free_entry((ctx),(kte)) 57 | #endif 58 | 59 | #endif /* KRB5_UTIL_H */ 60 | -------------------------------------------------------------------------------- /utils/gssd/svcgssd.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2004 The Regents of the University of Michigan. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 3. Neither the name of the University nor the names of its 15 | contributors may be used to endorse or promote products derived 16 | from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _RPC_SVCGSSD_H_ 32 | #define _RPC_SVCGSSD_H_ 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | void handle_nullreq(int f); 39 | void gssd_run(void); 40 | 41 | #define GSSD_SERVICE_NAME "nfs" 42 | 43 | #endif /* _RPC_SVCGSSD_H_ */ 44 | -------------------------------------------------------------------------------- /utils/gssd/svcgssd.man: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" rpc.svcgssd(8) 3 | .\" 4 | .\" Copyright (C) 2003 J. Bruce Fields 5 | .TH rpc.svcgssd 8 "12 Jan 2007" 6 | .SH NAME 7 | rpc.svcgssd \- server-side rpcsec_gss daemon 8 | .SH SYNOPSIS 9 | .B "rpc.svcgssd [-n] [-v] [-r] [-i] [-f] [-p principal]" 10 | .SH DESCRIPTION 11 | The rpcsec_gss protocol gives a means of using the gss-api generic security 12 | api to provide security for protocols using rpc (in particular, nfs). Before 13 | exchanging any rpc requests using rpcsec_gss, the rpc client must first 14 | establish a security context with the rpc server. The linux kernel's 15 | implementation of rpcsec_gss depends on the userspace daemon 16 | .B rpc.svcgssd 17 | to handle context establishment on the rpc server. The 18 | daemon uses files in the proc filesystem to communicate with 19 | the kernel. 20 | 21 | .SH OPTIONS 22 | .TP 23 | .B -f 24 | Runs 25 | .B rpc.svcgssd 26 | in the foreground and sends output to stderr (as opposed to syslogd) 27 | .TP 28 | .B -v 29 | Increases the verbosity of the output (can be specified multiple times). 30 | .TP 31 | .B -r 32 | If the rpcsec_gss library supports setting debug level, 33 | increases the verbosity of the output (can be specified multiple times). 34 | .TP 35 | .B -i 36 | If the nfsidmap library supports setting debug level, 37 | increases the verbosity of the output (can be specified multiple times). 38 | .TP 39 | .B -p 40 | Use \fIprincipal\fR instead of the default 41 | .RI nfs/ FQDN @ REALM . 42 | .TP 43 | .B -n 44 | Use the system default credentials 45 | .RI (host/ FQDN @ REALM ) 46 | rather than the default 47 | .RI nfs/ FQDN @ REALM . 48 | .SH SEE ALSO 49 | .BR rpc.gssd(8), 50 | .SH AUTHORS 51 | .br 52 | Dug Song 53 | .br 54 | Andy Adamson 55 | .br 56 | Marius Aamodt Eriksen 57 | .br 58 | J. Bruce Fields 59 | -------------------------------------------------------------------------------- /utils/gssd/svcgssd_krb5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT (c) 2011 3 | * The Regents of the University of Michigan 4 | * ALL RIGHTS RESERVED 5 | * 6 | * Permission is granted to use, copy, create derivative works 7 | * and redistribute this software and such derivative works 8 | * for any purpose, so long as the name of The University of 9 | * Michigan is not used in any advertising or publicity 10 | * pertaining to the use of distribution of this software 11 | * without specific, written prior authorization. If the 12 | * above copyright notice or any other identification of the 13 | * University of Michigan is included in any copy of any 14 | * portion of this software, then the disclaimer below must 15 | * also be included. 16 | * 17 | * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION 18 | * FROM THE UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY 19 | * PURPOSE, AND WITHOUT WARRANTY BY THE UNIVERSITY OF 20 | * MICHIGAN OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING 21 | * WITHOUT LIMITATION THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE 23 | * REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE 24 | * FOR ANY DAMAGES, INCLUDING SPECIAL, INDIRECT, INCIDENTAL, OR 25 | * CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM ARISING 26 | * OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN 27 | * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGES. 29 | */ 30 | 31 | #ifndef SVCGSSD_KRB5_H 32 | #define SVCGSSD_KRB5_H 33 | 34 | int svcgssd_limit_krb5_enctypes(void); 35 | 36 | #endif /* SVCGSSD_KRB5_H */ 37 | -------------------------------------------------------------------------------- /utils/gssd/svcgssd_main_loop.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2004 The Regents of the University of Michigan. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 3. Neither the name of the University nor the names of its 15 | contributors may be used to endorse or promote products derived 16 | from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifdef HAVE_CONFIG_H 32 | #include 33 | #endif /* HAVE_CONFIG_H */ 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | #include "svcgssd.h" 51 | #include "err_util.h" 52 | 53 | void 54 | gssd_run() 55 | { 56 | int ret; 57 | int f; 58 | struct pollfd pollfd; 59 | 60 | #define NULLRPC_FILE "/proc/net/rpc/auth.rpcsec.init/channel" 61 | 62 | f = open(NULLRPC_FILE, O_RDWR); 63 | if (f < 0) { 64 | printerr(0, "failed to open %s: %s\n", 65 | NULLRPC_FILE, strerror(errno)); 66 | exit(1); 67 | } 68 | pollfd.fd = f; 69 | pollfd.events = POLLIN; 70 | while (1) { 71 | int save_err; 72 | 73 | pollfd.revents = 0; 74 | printerr(1, "entering poll\n"); 75 | ret = poll(&pollfd, 1, -1); 76 | save_err = errno; 77 | printerr(1, "leaving poll\n"); 78 | if (ret < 0) { 79 | if (save_err != EINTR) 80 | printerr(0, "error return from poll: %s\n", 81 | strerror(save_err)); 82 | } else if (ret == 0) { 83 | /* timeout; shouldn't happen. */ 84 | } else { 85 | if (ret != 1) { 86 | printerr(0, "bug: unexpected poll return %d\n", 87 | ret); 88 | exit(1); 89 | } 90 | if (pollfd.revents & POLLIN) 91 | handle_nullreq(f); 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /utils/gssd/svcgssd_mech2file.c: -------------------------------------------------------------------------------- 1 | /* 2 | linux_downcall.c 3 | 4 | Copyright (c) 2000 The Regents of the University of Michigan. 5 | All rights reserved. 6 | 7 | Copyright (c) 2004 Andy Adamson . 8 | All rights reserved, all wrongs reversed. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions 12 | are met: 13 | 14 | 1. Redistributions of source code must retain the above copyright 15 | notice, this list of conditions and the following disclaimer. 16 | 2. Redistributions in binary form must reproduce the above copyright 17 | notice, this list of conditions and the following disclaimer in the 18 | documentation and/or other materials provided with the distribution. 19 | 3. Neither the name of the University nor the names of its 20 | contributors may be used to endorse or promote products derived 21 | from this software without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 24 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 30 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | 35 | */ 36 | 37 | #ifdef HAVE_CONFIG_H 38 | #include 39 | #endif /* HAVE_CONFIG_H */ 40 | 41 | #include 42 | #include 43 | 44 | 45 | #define g_OID_equal(o1,o2) \ 46 | (((o1)->length == (o2)->length) && \ 47 | (memcmp((o1)->elements,(o2)->elements,(int) (o1)->length) == 0)) 48 | 49 | struct mech2file { 50 | gss_OID_desc mech; 51 | char filename[8]; 52 | }; 53 | 54 | struct mech2file m2f[] = { 55 | {{9, "\052\206\110\206\367\022\001\002\002"}, "krb5"}, 56 | {{0,0},""}, 57 | }; 58 | 59 | /* 60 | * Find the Linux svcgssd downcall file name given the mechanism 61 | */ 62 | char * 63 | mech2file(gss_OID mech) 64 | { 65 | struct mech2file *m2fp = m2f; 66 | 67 | while(m2fp->mech.length != 0) { 68 | if (g_OID_equal(mech,&m2fp->mech)) 69 | return(m2fp->filename); 70 | m2fp++; 71 | } 72 | return NULL; 73 | } 74 | -------------------------------------------------------------------------------- /utils/idmapd/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | man8_MANS = idmapd.man 4 | 5 | RPCPREFIX = rpc. 6 | KPREFIX = @kprefix@ 7 | sbin_PROGRAMS = idmapd 8 | 9 | EXTRA_DIST = \ 10 | $(man8_MANS) 11 | 12 | idmapd_SOURCES = \ 13 | idmapd.c \ 14 | \ 15 | nfs_idmap.h \ 16 | queue.h 17 | 18 | idmapd_LDADD = $(LIBEVENT) $(LIBNFSIDMAP) ../../support/nfs/libnfs.a 19 | 20 | MAINTAINERCLEANFILES = Makefile.in 21 | 22 | ####################################################################### 23 | # The following allows the current practice of having 24 | # daemons renamed during the install to include RPCPREFIX 25 | # and the KPREFIX 26 | # This could all be done much easier with program_transform_name 27 | # ( program_transform_name = s/^/$(RPCPREFIX)$(KPREFIX)/ ) 28 | # but that also renames the man pages, which the current 29 | # practice does not do. 30 | install-exec-hook: 31 | (cd $(DESTDIR)$(sbindir) && \ 32 | for p in $(sbin_PROGRAMS); do \ 33 | mv -f $$p$(EXEEXT) $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ 34 | done) 35 | uninstall-hook: 36 | (cd $(DESTDIR)$(sbindir) && \ 37 | for p in $(sbin_PROGRAMS); do \ 38 | rm -f $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ 39 | done) 40 | 41 | 42 | # XXX This makes some assumptions about what automake does. 43 | # XXX But there is no install-man-hook or install-man-local. 44 | install-man: install-man8 install-man-links 45 | uninstall-man: uninstall-man8 uninstall-man-links 46 | 47 | install-man-links: 48 | (cd $(DESTDIR)$(man8dir) && \ 49 | for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ 50 | inst=`echo $$m | sed -e 's/man$$/8/'`; \ 51 | rm -f $(RPCPREFIX)$$inst ; \ 52 | $(LN_S) $$inst $(RPCPREFIX)$$inst ; \ 53 | done) 54 | 55 | uninstall-man-links: 56 | (cd $(DESTDIR)$(man8dir) && \ 57 | for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ 58 | inst=`echo $$m | sed -e 's/man$$/8/'`; \ 59 | rm -f $(RPCPREFIX)$$inst ; \ 60 | done) 61 | 62 | -------------------------------------------------------------------------------- /utils/idmapd/nfs_idmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/linux/nfs_idmap.h 3 | * 4 | * UID and GID to name mapping for clients. 5 | * 6 | * Copyright (c) 2002 The Regents of the University of Michigan. 7 | * All rights reserved. 8 | * 9 | * Marius Aamodt Eriksen 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. Neither the name of the University nor the names of its 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 25 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 31 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 32 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 33 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #ifndef NFS_IDMAP_H 38 | #define NFS_IDMAP_H 39 | 40 | /* XXX from bits/utmp.h */ 41 | #define IDMAP_NAMESZ 128 42 | 43 | #define IDMAP_TYPE_USER 0 44 | #define IDMAP_TYPE_GROUP 1 45 | 46 | #define IDMAP_CONV_IDTONAME 0 47 | #define IDMAP_CONV_NAMETOID 1 48 | 49 | #define IDMAP_STATUS_INVALIDMSG 0x01 50 | #define IDMAP_STATUS_AGAIN 0x02 51 | #define IDMAP_STATUS_LOOKUPFAIL 0x04 52 | #define IDMAP_STATUS_SUCCESS 0x08 53 | 54 | #define IDMAP_MAXMSGSZ 256 55 | 56 | struct idmap_msg { 57 | u_int8_t im_type; 58 | u_int8_t im_conv; 59 | char im_name[IDMAP_NAMESZ]; 60 | u_int32_t im_id; 61 | u_int8_t im_status; 62 | }; 63 | 64 | #endif /* NFS_IDMAP_H */ 65 | -------------------------------------------------------------------------------- /utils/mount/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | # These binaries go in /sbin (not /usr/sbin), and that cannot be 4 | # overridden at config time. 5 | sbindir = /sbin 6 | 7 | man8_MANS = mount.nfs.man umount.nfs.man 8 | man5_MANS = nfs.man 9 | 10 | sbin_PROGRAMS = mount.nfs 11 | EXTRA_DIST = nfsmount.conf $(man8_MANS) $(man5_MANS) 12 | mount_common = error.c network.c token.c \ 13 | parse_opt.c parse_dev.c \ 14 | nfsmount.c nfs4mount.c stropts.c\ 15 | mount_constants.h error.h network.h token.h \ 16 | parse_opt.h parse_dev.h \ 17 | nfs4_mount.h stropts.h version.h \ 18 | mount_config.h utils.c utils.h \ 19 | nfs_mount.h 20 | 21 | if MOUNT_CONFIG 22 | mount_common += configfile.c 23 | man5_MANS += nfsmount.conf.man 24 | else 25 | EXTRA_DIST += nfsmount.conf.man 26 | endif 27 | 28 | mount_nfs_LDADD = ../../support/nfs/libnfs.a \ 29 | ../../support/export/libexport.a \ 30 | $(LIBTIRPC) 31 | 32 | mount_nfs_SOURCES = $(mount_common) 33 | 34 | if CONFIG_LIBMOUNT 35 | mount_nfs_SOURCES += mount_libmount.c 36 | mount_nfs_LDADD += $(LIBMOUNT) 37 | else 38 | mount_nfs_SOURCES += mount.c fstab.c nfsumount.c fstab.h 39 | 40 | endif 41 | 42 | MAINTAINERCLEANFILES = Makefile.in 43 | 44 | install-exec-hook: 45 | (cd $(DESTDIR)$(sbindir) && \ 46 | ln -sf mount.nfs mount.nfs4 && \ 47 | ln -sf mount.nfs umount.nfs && \ 48 | ln -sf mount.nfs umount.nfs4 && \ 49 | chmod 4511 mount.nfs ) 50 | uninstall-hook: 51 | (cd $(DESTDIR)$(sbindir) && \ 52 | rm -f mount.nfs4 umount.nfs umount.nfs4) 53 | 54 | 55 | install-man-links: 56 | (cd $(DESTDIR)$(man8dir) && \ 57 | for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ 58 | inst=`echo $$m | sed -e 's/man$$/8/'`; \ 59 | rm -f $$inst ; \ 60 | done) 61 | (cd $(DESTDIR)$(man5dir) && \ 62 | for m in $(man5_MANS) $(dist_man5_MANS) $(nodist_man5_MANS); do \ 63 | inst=`echo $$m | sed -e 's/man$$/5/'`; \ 64 | rm -f $$inst ; \ 65 | done) 66 | 67 | uninstall-man-links: 68 | (cd $(DESTDIR)$(man8dir) && \ 69 | for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ 70 | inst=`echo $$m | sed -e 's/man$$/8/'`; \ 71 | rm -f $$inst ; \ 72 | done) 73 | (cd $(DESTDIR)$(man5dir) && \ 74 | for m in $(man5_MANS) $(dist_man5_MANS) $(nodist_man5_MANS); do \ 75 | inst=`echo $$m | sed -e 's/man$$/5/'`; \ 76 | rm -f $$inst ; \ 77 | done) 78 | 79 | -------------------------------------------------------------------------------- /utils/mount/error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * error.h: Common error handling functions 3 | * 4 | * Copyright (C) 2007 Oracle. All rights reserved. 5 | * Copyright (C) 2007 Chuck Lever 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public 18 | * License along with this program; if not, write to the 19 | * Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA 21 | * 22 | */ 23 | 24 | #ifndef _NFS_UTILS_MOUNT_ERROR_H 25 | #define _NFS_UTILS_MOUNT_ERROR_H 26 | 27 | char *nfs_strerror(unsigned int); 28 | 29 | void mount_error(const char *, const char *, int); 30 | void rpc_mount_errors(char *, int, int); 31 | void sys_mount_errors(char *, int, int, int); 32 | 33 | void umount_error(int, const char *); 34 | 35 | #endif /* _NFS_UTILS_MOUNT_ERROR_H */ 36 | -------------------------------------------------------------------------------- /utils/mount/fstab.h: -------------------------------------------------------------------------------- 1 | #ifndef _NFS_UTILS_MOUNT_FSTAB_H 2 | #define _NFS_UTILS_MOUNT_FSTAB_H 3 | 4 | #include "nfs_mntent.h" 5 | 6 | #ifndef _PATH_FSTAB 7 | #define _PATH_FSTAB "/etc/fstab" 8 | #endif 9 | 10 | int mtab_is_writable(void); 11 | int mtab_does_not_exist(void); 12 | void reset_mtab_info(void); 13 | 14 | struct mntentchn { 15 | struct mntentchn *nxt, *prev; 16 | struct mntent m; 17 | }; 18 | 19 | struct mntentchn *getmntoptfile (const char *file); 20 | struct mntentchn *getmntdirbackward (const char *dir, struct mntentchn *mc); 21 | struct mntentchn *getprocmntdirbackward (const char *name, struct mntentchn *mc); 22 | struct mntentchn *getmntdevbackward (const char *dev, struct mntentchn *mc); 23 | 24 | struct mntentchn *getfsfile (const char *file); 25 | struct mntentchn *getfsspec (const char *spec); 26 | 27 | void lock_mtab (void); 28 | void unlock_mtab (void); 29 | void update_mtab (const char *special, struct mntent *with); 30 | 31 | #endif /* _NFS_UTILS_MOUNT_FSTAB_H */ 32 | -------------------------------------------------------------------------------- /utils/mount/mount.nfs.man: -------------------------------------------------------------------------------- 1 | .\"@(#)mount.nfs.8" 2 | .TH MOUNT.NFS 8 "5 Jun 2006" 3 | .SH NAME 4 | mount.nfs, mount.nfs4 \- mount a Network File System 5 | .SH SYNOPSIS 6 | .BI "mount.nfs" " remotetarget dir" " [\-rvVwfnsh ] [\-o " options "] 7 | .SH DESCRIPTION 8 | .BR mount.nfs 9 | is a part of 10 | .BR nfs (5) 11 | utilities package, which provides NFS client functionality. 12 | 13 | .BR mount.nfs 14 | is meant to be used by the 15 | .BR mount (8) 16 | command for mounting NFS shares. This subcommand, however, can also be used as a standalone command with limited functionality. 17 | 18 | .I remotetarget 19 | is a server share usually in the form of 20 | .BR servername:/path/to/share. 21 | .I dir 22 | is the directory on which the file system is to be mounted. 23 | 24 | Under Linux 2.6.32 and later kernel versions, 25 | .BR mount.nfs 26 | can mount all NFS file system versions. Under earlier Linux kernel versions, 27 | .BR mount.nfs4 28 | must be used for mounting NFSv4 file systems while 29 | .BR mount.nfs 30 | must be used for NFSv3 and v2. 31 | 32 | .SH OPTIONS 33 | .TP 34 | .BI "\-r" 35 | Mount file system readonly. 36 | .TP 37 | .BI "\-v" 38 | Be verbose. 39 | .TP 40 | .BI "\-V" 41 | Print version. 42 | .TP 43 | .BI "\-w" 44 | Mount file system read-write. 45 | .TP 46 | .BI "\-f" 47 | Fake mount. Don't actually call the mount system call. 48 | .TP 49 | .BI "\-n" 50 | Do not update 51 | .I /etc/mtab. 52 | By default, an entry is created in 53 | .I /etc/mtab 54 | for every mounted file system. Use this option to skip making an entry. 55 | .TP 56 | .BI "\-s" 57 | Tolerate sloppy mount options rather than fail. 58 | .TP 59 | .BI "\-h" 60 | Print help message. 61 | .TP 62 | .BI "nfsoptions" 63 | Refer to 64 | .BR nfs (5) 65 | or 66 | .BR mount (8) 67 | manual pages. 68 | 69 | .SH NOTE 70 | For further information please refer 71 | .BR nfs (5) 72 | and 73 | .BR mount (8) 74 | manual pages. 75 | 76 | .SH FILES 77 | .TP 18n 78 | .I /etc/fstab 79 | file system table 80 | .TP 81 | .I /etc/mtab 82 | table of mounted file systems 83 | .TP 84 | .I /etc/nfsmount.conf 85 | Configuration file for NFS mounts 86 | .PD 87 | .SH "SEE ALSO" 88 | .BR nfs (5), 89 | .BR nfsmount.conf (5), 90 | .BR mount (8), 91 | 92 | .SH "AUTHOR" 93 | Amit Gud 94 | -------------------------------------------------------------------------------- /utils/mount/mount_config.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_MOUNT_CONFIG_H 2 | #define _LINUX_MOUNT_CONFIG_H 3 | /* 4 | * mount_config.h -- mount configuration file routines 5 | * Copyright (C) 2008 Red Hat, Inc 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | 19 | #ifdef MOUNT_CONFIG 20 | #include "conffile.h" 21 | #include "xlog.h" 22 | 23 | extern char *conf_get_mntopts(char *, char *, char *); 24 | 25 | static inline void mount_config_init(char *program) 26 | { 27 | xlog_open(program); 28 | /* 29 | * Read the the default mount options 30 | */ 31 | conf_init(); 32 | } 33 | 34 | static inline char *mount_config_opts(char *spec, 35 | char *mount_point, char *mount_opts) 36 | { 37 | return conf_get_mntopts(spec, mount_point, mount_opts); 38 | } 39 | 40 | #else /* MOUNT_CONFIG */ 41 | 42 | static inline void mount_config_init(__attribute__ ((unused)) char *program) { } 43 | 44 | static inline char *mount_config_opts(__attribute__ ((unused)) char *spec, 45 | __attribute__ ((unused)) char *mount_point, char *mount_opts) 46 | { 47 | return mount_opts; 48 | } 49 | #endif /* MOUNT_CONFIG */ 50 | 51 | #endif /* _LINUX_MOUNT_CONFIG_H */ 52 | -------------------------------------------------------------------------------- /utils/mount/mount_constants.h: -------------------------------------------------------------------------------- 1 | #ifndef _NFS_UTILS_MOUNT_CONSTANTS_H 2 | #define _NFS_UTILS_MOUNT_CONSTANTS_H 3 | 4 | #ifndef MS_DIRSYNC 5 | #define MS_DIRSYNC 128 /* Directory modifications are synchronous */ 6 | #endif 7 | 8 | #ifndef MS_ACTION_MASK 9 | #define MS_ACTION_MASK 0x380 10 | /* Remount, but new filesystem may be different from old. Atomic 11 | (i.e. there is no interval when nothing is mounted at the mountpoint). 12 | If new fs differs from the old one and old is busy - -EBUSY. */ 13 | #define MS_REPLACE 0x080 /* 128 */ 14 | /* After, Before: as soon as we get unions these will add a new member 15 | in the end or beginning of the chain. Fail if there is a stack 16 | on the mountpoint. */ 17 | #define MS_AFTER 0x100 /* 256 */ 18 | #define MS_BEFORE 0x180 19 | /* Over: if nothing mounted on a mountpoint - same as if none of these 20 | flags had been set; if we have a union with more than one element - fail; 21 | if we have a stack or plain mount - mount atop of it, forming a stack. */ 22 | #define MS_OVER 0x200 /* 512 */ 23 | #endif 24 | #ifndef MS_NOATIME 25 | #define MS_NOATIME 0x400 /* 1024: Do not update access times. */ 26 | #endif 27 | #ifndef MS_NODIRATIME 28 | #define MS_NODIRATIME 0x800 /* 2048: Don't update directory access times */ 29 | #endif 30 | #ifndef MS_BIND 31 | #define MS_BIND 0x1000 /* 4096: Mount existing tree also elsewhere */ 32 | #endif 33 | #ifndef MS_MOVE 34 | #define MS_MOVE 0x2000 /* 8192: Atomically move tree */ 35 | #endif 36 | #ifndef MS_REC 37 | #define MS_REC 0x4000 /* 16384: Recursive loopback */ 38 | #endif 39 | #ifndef MS_VERBOSE 40 | #define MS_VERBOSE 0x8000 /* 32768 */ 41 | #endif 42 | #ifndef MS_RELATIME 43 | #define MS_RELATIME 0x200000 /* 200000: Update access times relative 44 | to mtime/ctime */ 45 | #endif 46 | /* 47 | * NFS fs-specific mount option flags 48 | * 49 | * MS_DUMMY is assigned to mount options that are not to be 50 | * passed to the kernel via the "flags" argument. These are 51 | * generally ignored or handled entirely in user space. 52 | */ 53 | #define MS_DUMMY 0x00000000 54 | #define MS_USERS 0x40000000 55 | #define MS_USER 0x80000000 56 | 57 | /* 58 | * Magic mount flag number. Had to be or-ed to the flag values. 59 | */ 60 | #ifndef MS_MGC_VAL 61 | #define MS_MGC_VAL 0xC0ED0000 /* magic flag number to indicate "new" flags */ 62 | #endif 63 | #ifndef MS_MGC_MSK 64 | #define MS_MGC_MSK 0xffff0000 /* magic flag number mask */ 65 | #endif 66 | 67 | /* Generic options that are prevented from appearing 68 | * in the options field in /etc/mtab. */ 69 | #define MS_NOMTAB (MS_REMOUNT) 70 | 71 | #endif /* _NFS_UTILS_MOUNT_CONSTANTS_H */ 72 | -------------------------------------------------------------------------------- /utils/mount/nfs4_mount.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_NFS4_MOUNT_H 2 | #define _LINUX_NFS4_MOUNT_H 3 | 4 | /* 5 | * linux/include/linux/nfs4_mount.h 6 | * 7 | * Copyright (C) 2002 Trond Myklebust 8 | * 9 | * structure passed from user-space to kernel-space during an nfsv4 mount 10 | */ 11 | 12 | /* 13 | * WARNING! Do not delete or change the order of these fields. If 14 | * a new field is required then add it to the end. The version field 15 | * tracks which fields are present. This will ensure some measure of 16 | * mount-to-kernel version compatibility. Some of these aren't used yet 17 | * but here they are anyway. 18 | */ 19 | #define NFS4_MOUNT_VERSION 1 20 | 21 | struct nfs_string { 22 | unsigned int len; 23 | const char* data; 24 | }; 25 | 26 | struct nfs4_mount_data { 27 | int version; /* 1 */ 28 | int flags; /* 1 */ 29 | int rsize; /* 1 */ 30 | int wsize; /* 1 */ 31 | int timeo; /* 1 */ 32 | int retrans; /* 1 */ 33 | int acregmin; /* 1 */ 34 | int acregmax; /* 1 */ 35 | int acdirmin; /* 1 */ 36 | int acdirmax; /* 1 */ 37 | 38 | /* see the definition of 'struct clientaddr4' in RFC3010 */ 39 | struct nfs_string client_addr; /* 1 */ 40 | 41 | /* Mount path */ 42 | struct nfs_string mnt_path; /* 1 */ 43 | 44 | /* Server details */ 45 | struct nfs_string hostname; /* 1 */ 46 | /* Server IP address */ 47 | unsigned int host_addrlen; /* 1 */ 48 | struct sockaddr* host_addr; /* 1 */ 49 | 50 | /* Transport protocol to use */ 51 | int proto; /* 1 */ 52 | 53 | /* Pseudo-flavours to use for authentication. See RFC2623 */ 54 | int auth_flavourlen; /* 1 */ 55 | int *auth_flavours; /* 1 */ 56 | }; 57 | 58 | /* bits in the flags field */ 59 | /* Note: the fields that correspond to existing NFSv2/v3 mount options 60 | * should mirror the values from include/linux/nfs_mount.h 61 | */ 62 | 63 | #define NFS4_MOUNT_SOFT 0x0001 /* 1 */ 64 | #define NFS4_MOUNT_INTR 0x0002 /* 1 */ 65 | #define NFS4_MOUNT_NOCTO 0x0010 /* 1 */ 66 | #define NFS4_MOUNT_NOAC 0x0020 /* 1 */ 67 | #define NFS4_MOUNT_STRICTLOCK 0x1000 /* 1 */ 68 | #define NFS4_MOUNT_UNSHARED 0x8000 /* 5 */ 69 | #define NFS4_MOUNT_FLAGMASK 0xFFFF 70 | 71 | int nfs4mount(const char *, const char *, int, char **, int, int); 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /utils/mount/nfs_mount.h: -------------------------------------------------------------------------------- 1 | /* 2 | * We want to be able to compile mount on old kernels in such a way 3 | * that the binary will work well on more recent kernels. 4 | * Thus, if necessary we teach nfsmount.c the structure of new fields 5 | * that will come later. 6 | * 7 | * Moreover, the new kernel includes conflict with glibc includes 8 | * so it is easiest to ignore the kernel altogether (at compile time). 9 | */ 10 | 11 | #ifndef _NFS_UTILS_MOUNT_NFS_MOUNT_H 12 | #define _NFS_UTILS_MOUNT_NFS_MOUNT_H 13 | 14 | #include 15 | #include 16 | 17 | #define NFS_MOUNT_VERSION 6 18 | #define NFS_MAX_CONTEXT_LEN 256 19 | 20 | struct nfs2_fh { 21 | char data[32]; 22 | }; 23 | struct nfs3_fh { 24 | unsigned short size; 25 | unsigned char data[64]; 26 | }; 27 | 28 | struct nfs_mount_data { 29 | int version; /* 1 */ 30 | int fd; /* 1 */ 31 | struct nfs2_fh old_root; /* 1 */ 32 | int flags; /* 1 */ 33 | int rsize; /* 1 */ 34 | int wsize; /* 1 */ 35 | int timeo; /* 1 */ 36 | int retrans; /* 1 */ 37 | int acregmin; /* 1 */ 38 | int acregmax; /* 1 */ 39 | int acdirmin; /* 1 */ 40 | int acdirmax; /* 1 */ 41 | struct sockaddr_in addr; /* 1 */ 42 | char hostname[256]; /* 1 */ 43 | int namlen; /* 2 */ 44 | unsigned int bsize; /* 3 */ 45 | struct nfs3_fh root; /* 4 */ 46 | int pseudoflavor; /* 5 */ 47 | char context[NFS_MAX_CONTEXT_LEN + 1]; /* 6 */ 48 | 49 | }; 50 | 51 | /* bits in the flags field */ 52 | 53 | #define NFS_MOUNT_SOFT 0x0001 /* 1 */ 54 | #define NFS_MOUNT_INTR 0x0002 /* 1 */ 55 | #define NFS_MOUNT_SECURE 0x0004 /* 1 */ 56 | #define NFS_MOUNT_POSIX 0x0008 /* 1 */ 57 | #define NFS_MOUNT_NOCTO 0x0010 /* 1 */ 58 | #define NFS_MOUNT_NOAC 0x0020 /* 1 */ 59 | #define NFS_MOUNT_TCP 0x0040 /* 2 */ 60 | #define NFS_MOUNT_VER3 0x0080 /* 3 */ 61 | #define NFS_MOUNT_KERBEROS 0x0100 /* 3 */ 62 | #define NFS_MOUNT_NONLM 0x0200 /* 3 */ 63 | #define NFS_MOUNT_BROKEN_SUID 0x0400 /* 4 */ 64 | #define NFS_MOUNT_NOACL 0x0800 /* 4 */ 65 | #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */ 66 | #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */ 67 | #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */ 68 | 69 | /* security pseudoflavors */ 70 | 71 | #ifndef AUTH_GSS_KRB5 72 | #define AUTH_GSS_KRB5 390003 73 | #define AUTH_GSS_KRB5I 390004 74 | #define AUTH_GSS_KRB5P 390005 75 | #define AUTH_GSS_LKEY 390006 76 | #define AUTH_GSS_LKEYI 390007 77 | #define AUTH_GSS_LKEYP 390008 78 | #endif 79 | 80 | int nfsmount(const char *, const char *, int , char **, int, int); 81 | int nfsumount(int, char **); 82 | 83 | #endif /* _NFS_UTILS_MOUNT_NFS_MOUNT_H */ 84 | -------------------------------------------------------------------------------- /utils/mount/nfsmount.conf.man: -------------------------------------------------------------------------------- 1 | .\"@(#)nfsmount.conf.5" 2 | .TH NFSMOUNT.CONF 5 "9 October 2012" 3 | .SH NAME 4 | nfsmount.conf - Configuration file for NFS mounts 5 | .SH SYNOPSIS 6 | Configuration file for NFS mounts that allows options 7 | to be set globally, per server or per mount point. 8 | .SH DESCRIPTION 9 | The configuration file is made up of multiple sections 10 | followed by variables associated with that section. 11 | A section is defined by a string enclosed by 12 | .BR [ 13 | and 14 | .BR ] 15 | branches. 16 | Variables are assignment statements that assign values 17 | to particular variables using the 18 | .BR = 19 | operator, as in 20 | .BR Proto=Tcp . 21 | The variables that can be assigned are exactly the set of NFS specific 22 | mount options listed in 23 | .BR nfs (5). 24 | .PP 25 | Sections are broken up into three basic categories: 26 | Global options, Server options and Mount Point options. 27 | .HP 28 | .B [ NFSMount_Global_Options ] 29 | - This statically named section 30 | defines all of the global mount options that can be 31 | applied to every NFS mount. 32 | .HP 33 | .B [ Server \(lqServer_Name\(rq ] 34 | - This section defines all the mount options that should 35 | be used on mounts to a particular NFS server. The 36 | .I \(lqServer_Name\(rq 37 | strings needs to be surrounded by '\(lq' and 38 | be an exact match of the server name used in the 39 | .B mount 40 | command. 41 | .HP 42 | .B [ MountPoint \(lqMount_Point\(rq ] 43 | - This section defines all the mount options that 44 | should be used on a particular mount point. 45 | The 46 | .I \(lqMount_Point\(rq 47 | string needs to be surrounded by '\(lq' and be an 48 | exact match of the mount point used in the 49 | .BR mount 50 | command. 51 | .SH EXAMPLES 52 | .PP 53 | These are some example lines of how sections and variables 54 | are defined in the configuration file. 55 | .PP 56 | [ NFSMount_Global_Options ] 57 | .br 58 | Proto=Tcp 59 | .RS 60 | .HP 61 | The TCP/IPv4 protocol will be used on every NFS mount. 62 | .HP 63 | .RE 64 | [ Server \(lqnfsserver.foo.com\(rq ] 65 | .br 66 | rsize=32k 67 | .br 68 | wsize=32k 69 | .br 70 | proto=udp6 71 | .HP 72 | .RS 73 | A 32k (32768 bytes) block size will be used as the read and write 74 | size on all mounts to the 'nfsserver.foo.com' server. UDP/IPv6 75 | is the protocol to be used. 76 | .HP 77 | .RE 78 | .BR 79 | [ MountPoint \(lq/export/home\(rq ] 80 | .br 81 | Background=True 82 | .RS 83 | .HP 84 | All mounts to the '/export/home' export will be performed in 85 | the background (i.e. done asynchronously). 86 | .HP 87 | .SH FILES 88 | .TP 10n 89 | .I /etc/nfsmount.conf 90 | Default NFS mount configuration file 91 | .PD 92 | .SH SEE ALSO 93 | .BR nfs (5), 94 | .BR mount (8), 95 | -------------------------------------------------------------------------------- /utils/mount/parse_dev.h: -------------------------------------------------------------------------------- 1 | /* 2 | * parse_dev.c -- parse device name into hostname and export path 3 | * 4 | * Copyright (C) 2008 Oracle. All rights reserved. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public 17 | * License along with this program; if not, write to the 18 | * Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA 20 | * 21 | */ 22 | 23 | #ifndef __NFS_UTILS_PARSE_DEV_HEADER 24 | #define __NFS_UTILS_PARSE_DEV_HEADER 25 | 26 | extern int nfs_parse_devname(const char *, char **, char **); 27 | 28 | #endif /* __NFS_UTILS_PARSE_DEV */ 29 | -------------------------------------------------------------------------------- /utils/mount/parse_opt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * parse_opt.h -- mount option string parsing helpers 3 | * 4 | * Copyright (C) 2007 Oracle. All rights reserved. 5 | * Copyright (C) 2007 Chuck Lever 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public 18 | * License along with this program; if not, write to the 19 | * Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA 21 | * 22 | */ 23 | 24 | #ifndef _NFS_UTILS_PARSE_OPT_H 25 | #define _NFS_UTILS_PARSE_OPT_H 26 | 27 | typedef enum { 28 | PO_FAILED = 0, 29 | PO_SUCCEEDED = 1, 30 | } po_return_t; 31 | 32 | typedef enum { 33 | PO_NOT_FOUND = 0, 34 | PO_FOUND = 1, 35 | PO_BAD_VALUE = 2, 36 | } po_found_t; 37 | 38 | struct mount_options; 39 | 40 | struct mount_options * po_split(char *); 41 | struct mount_options * po_dup(struct mount_options *); 42 | void po_replace(struct mount_options *, 43 | struct mount_options *); 44 | po_return_t po_join(struct mount_options *, char **); 45 | 46 | po_return_t po_append(struct mount_options *, char *); 47 | po_found_t po_contains(struct mount_options *, char *); 48 | po_found_t po_contains_prefix(struct mount_options *options, 49 | const char *prefix, char **keyword); 50 | char * po_get(struct mount_options *, char *); 51 | po_found_t po_get_numeric(struct mount_options *, 52 | char *, long *); 53 | int po_rightmost(struct mount_options *, 54 | const char *keys[]); 55 | po_found_t po_remove_all(struct mount_options *, char *); 56 | void po_destroy(struct mount_options *); 57 | 58 | #endif /* _NFS_UTILS_PARSE_OPT_H */ 59 | -------------------------------------------------------------------------------- /utils/mount/stropts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * stropts.h -- Provide common network functions for NFS mount/umount 3 | * 4 | * Copyright (C) 2007 Oracle. All rights reserved. 5 | * Copyright (C) 2007 Chuck Lever 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public 18 | * License along with this program; if not, write to the 19 | * Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA 21 | * 22 | */ 23 | 24 | #ifndef _NFS_UTILS_MOUNT_STROPTS_H 25 | #define _NFS_UTILS_MOUNT_STROPTS_H 26 | 27 | int nfsmount_string(const char *, const char *, const char *, int, 28 | char **, int, int); 29 | 30 | #endif /* _NFS_UTILS_MOUNT_STROPTS_H */ 31 | -------------------------------------------------------------------------------- /utils/mount/token.h: -------------------------------------------------------------------------------- 1 | /* 2 | * token.h -- tokenize strings, a la strtok(3) 3 | * 4 | * Copyright (C) 2007 Oracle. All rights reserved. 5 | * Copyright (C) 2007 Chuck Lever 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public 18 | * License along with this program; if not, write to the 19 | * Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA 21 | * 22 | */ 23 | 24 | #ifndef _NFS_UTILS_MOUNT_TOKEN_H 25 | #define _NFS_UTILS_MOUNT_TOKEN_H 26 | 27 | struct tokenizer_state; 28 | 29 | char *next_token(struct tokenizer_state *); 30 | struct tokenizer_state *init_tokenizer(char *, char); 31 | int tokenizer_error(struct tokenizer_state *); 32 | void end_tokenizer(struct tokenizer_state *); 33 | 34 | #endif /* _NFS_UTILS_MOUNT_TOKEN_H */ 35 | -------------------------------------------------------------------------------- /utils/mount/umount.nfs.man: -------------------------------------------------------------------------------- 1 | .\"@(#)umount.nfs.8" 2 | .TH UMOUNT.NFS 8 "6 Jun 2006" 3 | .SH NAME 4 | umount.nfs, umount.nfs4 \- unmount a Network File System 5 | .SH SYNOPSIS 6 | .BI "umount.nfs" " dir" " [\-fvnrlh ]" 7 | .SH DESCRIPTION 8 | .BR umount.nfs 9 | and 10 | .BR umount.nfs4 11 | are a part of 12 | .BR nfs (5) 13 | utilities package, which provides NFS client functionality. 14 | 15 | .BR umount.nfs4 16 | and 17 | .BR umount.nfs 18 | are meant to be used by the 19 | .BR umount (8) 20 | command for unmounting NFS shares. This subcommand, however, can also be used as a standalone command with limited functionality. 21 | 22 | .I dir 23 | is the directory on which the file system is mounted. 24 | 25 | .SH OPTIONS 26 | .TP 27 | .BI "\-f" 28 | Force unmount the file system in case of unreachable NFS system. 29 | .TP 30 | .BI "\-v" 31 | Be verbose. 32 | .TP 33 | .BI "\-n" 34 | Do not update 35 | .I /etc/mtab. 36 | By default, an entry is created in 37 | .I /etc/mtab 38 | for every mounted file system. Use this option to skip deleting an entry. 39 | .TP 40 | .BI "\-r" 41 | In case unmounting fails, try to mount read-only. 42 | .TP 43 | .BI "\-l" 44 | Lazy unmount. Detach the file system from the file system hierarchy now, and cleanup all references to the file system as soon as it is not busy anymore. 45 | .TP 46 | .BI "\-h" 47 | Print help message. 48 | 49 | .SH NOTE 50 | For further information please refer 51 | .BR nfs (5) 52 | and 53 | .BR umount (8) 54 | manual pages. 55 | 56 | .SH FILES 57 | .TP 18n 58 | .I /etc/fstab 59 | file system table 60 | .TP 61 | .I /etc/mtab 62 | table of mounted file systems 63 | 64 | .PD 65 | .SH "SEE ALSO" 66 | .BR nfs (5), 67 | .BR umount (8), 68 | 69 | .SH "AUTHOR" 70 | Amit Gud 71 | -------------------------------------------------------------------------------- /utils/mount/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * utils.h -- misc utils for mount and umount 3 | * 4 | * Copyright (C) 2010 Karel Zak 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public 17 | * License along with this program; if not, write to the 18 | * Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA 20 | * 21 | */ 22 | 23 | #ifndef _NFS_UTILS_MOUNT_UTILS_H 24 | #define _NFS_UTILS_MOUNT_UTILS_H 25 | 26 | #include "parse_opt.h" 27 | 28 | int discover_nfs_mount_data_version(int *string_ver); 29 | void print_one(char *spec, char *node, char *type, char *opts); 30 | void mount_usage(void); 31 | void umount_usage(void); 32 | int chk_mountpoint(const char *mount_point); 33 | 34 | int nfs_umount23(const char *devname, char *string); 35 | 36 | #endif /* !_NFS_UTILS_MOUNT_UTILS_H */ 37 | -------------------------------------------------------------------------------- /utils/mount/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * version.h -- get running kernel version 3 | * 4 | * Copyright (C) 2008 Oracle. All rights reserved. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public 17 | * License along with this program; if not, write to the 18 | * Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA 20 | * 21 | */ 22 | 23 | #ifndef _NFS_UTILS_MOUNT_VERSION_H 24 | #define _NFS_UTILS_MOUNT_VERSION_H 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | static inline unsigned int MAKE_VERSION(unsigned int p, unsigned int q, 32 | unsigned int r) 33 | { 34 | return (65536 * p) + (256 * q) + r; 35 | } 36 | 37 | static inline unsigned int linux_version_code(void) 38 | { 39 | struct utsname my_utsname; 40 | unsigned int p, q = 0, r = 0; 41 | 42 | /* UINT_MAX as backward compatibility code should not be run */ 43 | if (uname(&my_utsname)) 44 | return UINT_MAX; 45 | 46 | /* UINT_MAX as future versions might not start with an integer */ 47 | if (sscanf(my_utsname.release, "%u.%u.%u", &p, &q, &r) < 1) 48 | return UINT_MAX; 49 | 50 | return MAKE_VERSION(p, q, r); 51 | } 52 | 53 | #endif /* _NFS_UTILS_MOUNT_VERSION_H */ 54 | -------------------------------------------------------------------------------- /utils/mountd/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | man8_MANS = mountd.man 4 | EXTRA_DIST = $(man8_MANS) 5 | 6 | RPCPREFIX = rpc. 7 | KPREFIX = @kprefix@ 8 | sbin_PROGRAMS = mountd 9 | 10 | noinst_HEADERS = fsloc.h 11 | mountd_SOURCES = mountd.c mount_dispatch.c auth.c rmtab.c cache.c \ 12 | svc_run.c fsloc.c v4root.c mountd.h 13 | mountd_LDADD = ../../support/export/libexport.a \ 14 | ../../support/nfs/libnfs.a \ 15 | ../../support/misc/libmisc.a \ 16 | $(LIBBSD) $(LIBWRAP) $(LIBNSL) $(LIBBLKID) $(LIBDL) $(LIBTIRPC) 17 | mountd_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS) \ 18 | -I$(top_builddir)/support/include \ 19 | -I$(top_srcdir)/support/export 20 | 21 | MAINTAINERCLEANFILES = Makefile.in 22 | 23 | ####################################################################### 24 | # The following allows the current practice of having 25 | # daemons renamed during the install to include RPCPREFIX 26 | # and the KPREFIX 27 | # This could all be done much easier with program_transform_name 28 | # ( program_transform_name = s/^/$(RPCPREFIX)$(KPREFIX)/ ) 29 | # but that also renames the man pages, which the current 30 | # practice does not do. 31 | install-exec-hook: 32 | (cd $(DESTDIR)$(sbindir) && \ 33 | for p in $(sbin_PROGRAMS); do \ 34 | mv -f $$p$(EXEEXT) $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ 35 | done) 36 | uninstall-hook: 37 | (cd $(DESTDIR)$(sbindir) && \ 38 | for p in $(sbin_PROGRAMS); do \ 39 | rm -f $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ 40 | done) 41 | 42 | 43 | # XXX This makes some assumptions about what automake does. 44 | # XXX But there is no install-man-hook or install-man-local. 45 | install-man: install-man8 install-man-links 46 | uninstall-man: uninstall-man8 uninstall-man-links 47 | 48 | install-man-links: 49 | (cd $(DESTDIR)$(man8dir) && \ 50 | for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ 51 | inst=`echo $$m | sed -e 's/man$$/8/'`; \ 52 | rm -f $(RPCPREFIX)$$inst ; \ 53 | $(LN_S) $$inst $(RPCPREFIX)$$inst ; \ 54 | done) 55 | 56 | uninstall-man-links: 57 | (cd $(DESTDIR)$(man8dir) && \ 58 | for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ 59 | inst=`echo $$m | sed -e 's/man$$/8/'`; \ 60 | rm -f $(RPCPREFIX)$$inst ; \ 61 | done) 62 | 63 | -------------------------------------------------------------------------------- /utils/mountd/fsloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT (c) 2006 3 | * THE REGENTS OF THE UNIVERSITY OF MICHIGAN 4 | * ALL RIGHTS RESERVED 5 | * 6 | * Permission is granted to use, copy, create derivative works 7 | * and redistribute this software and such derivative works 8 | * for any purpose, so long as the name of The University of 9 | * Michigan is not used in any advertising or publicity 10 | * pertaining to the use of distribution of this software 11 | * without specific, written prior authorization. If the 12 | * above copyright notice or any other identification of the 13 | * University of Michigan is included in any copy of any 14 | * portion of this software, then the disclaimer below must 15 | * also be included. 16 | * 17 | * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION 18 | * FROM THE UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY 19 | * PURPOSE, AND WITHOUT WARRANTY BY THE UNIVERSITY OF 20 | * MICHIGAN OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING 21 | * WITHOUT LIMITATION THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE 23 | * REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE 24 | * FOR ANY DAMAGES, INCLUDING SPECIAL, INDIRECT, INCIDENTAL, OR 25 | * CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM ARISING 26 | * OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN 27 | * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGES. 29 | */ 30 | 31 | #ifndef FSLOC_H 32 | #define FSLOC_H 33 | 34 | #define FSLOC_MAX_LIST 40 35 | 36 | struct mount_point { 37 | char *h_host; 38 | char *h_path; 39 | }; 40 | 41 | struct servers { 42 | int h_num; 43 | struct mount_point *h_mp[FSLOC_MAX_LIST]; 44 | int h_referral; /* 0=replica, 1=referral */ 45 | }; 46 | 47 | struct servers *replicas_lookup(int method, char *data); 48 | void release_replicas(struct servers *server); 49 | 50 | #endif /* FSLOC_H */ 51 | -------------------------------------------------------------------------------- /utils/mountd/mount_dispatch.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mount_dispatch This file contains the function dispatch table. 3 | * 4 | * Copyright (C) 1995 Olaf Kirch 5 | */ 6 | 7 | #ifdef HAVE_CONFIG_H 8 | #include 9 | #endif 10 | 11 | #ifdef HAVE_TCP_WRAPPER 12 | #include "tcpwrapper.h" 13 | #endif 14 | 15 | #include "mountd.h" 16 | #include "rpcmisc.h" 17 | 18 | /* 19 | * Procedures for MNTv1 20 | */ 21 | static struct rpc_dentry mnt_1_dtable[] = { 22 | dtable_ent(mount_null,1,void,void), /* NULL */ 23 | dtable_ent(mount_mnt,1,dirpath,fhstatus), /* MNT */ 24 | dtable_ent(mount_dump,1,void,mountlist), /* DUMP */ 25 | dtable_ent(mount_umnt,1,dirpath,void), /* UMNT */ 26 | dtable_ent(mount_umntall,1,void,void), /* UMNTALL */ 27 | dtable_ent(mount_export,1,void,exports), /* EXPORT */ 28 | dtable_ent(mount_exportall,1,void,exports), /* EXPORTALL */ 29 | }; 30 | 31 | /* 32 | * Procedures for MNTv2 33 | */ 34 | static struct rpc_dentry mnt_2_dtable[] = { 35 | dtable_ent(mount_null,1,void,void), /* NULL */ 36 | dtable_ent(mount_mnt,1,dirpath,fhstatus), /* MNT */ 37 | dtable_ent(mount_dump,1,void,mountlist), /* DUMP */ 38 | dtable_ent(mount_umnt,1,dirpath,void), /* UMNT */ 39 | dtable_ent(mount_umntall,1,void,void), /* UMNTALL */ 40 | dtable_ent(mount_export,1,void,exports), /* EXPORT */ 41 | dtable_ent(mount_exportall,1,void,exports), /* EXPORTALL */ 42 | dtable_ent(mount_pathconf,2,dirpath,ppathcnf), /* PATHCONF */ 43 | }; 44 | 45 | /* 46 | * Procedures for MNTv3 47 | */ 48 | static struct rpc_dentry mnt_3_dtable[] = { 49 | dtable_ent(mount_null,1,void,void), /* NULL */ 50 | dtable_ent(mount_mnt,3,dirpath,mountres3), /* MNT */ 51 | dtable_ent(mount_dump,1,void,mountlist), /* DUMP */ 52 | dtable_ent(mount_umnt,1,dirpath,void), /* UMNT */ 53 | dtable_ent(mount_umntall,1,void,void), /* UMNTALL */ 54 | dtable_ent(mount_export,1,void,exports), /* EXPORT */ 55 | }; 56 | 57 | #define number_of(x) (sizeof(x)/sizeof(x[0])) 58 | 59 | static struct rpc_dtable dtable[] = { 60 | { mnt_1_dtable, number_of(mnt_1_dtable) }, 61 | { mnt_2_dtable, number_of(mnt_2_dtable) }, 62 | { mnt_3_dtable, number_of(mnt_3_dtable) }, 63 | }; 64 | 65 | /* 66 | * The main dispatch routine. 67 | */ 68 | void 69 | mount_dispatch(struct svc_req *rqstp, SVCXPRT *transp) 70 | { 71 | union mountd_arguments argument; 72 | union mountd_results result; 73 | 74 | #ifdef HAVE_TCP_WRAPPER 75 | /* remote host authorization check */ 76 | if (!check_default("mountd", nfs_getrpccaller(transp), MOUNTPROG)) { 77 | svcerr_auth (transp, AUTH_FAILED); 78 | return; 79 | } 80 | #endif 81 | 82 | rpc_dispatch(rqstp, transp, dtable, number_of(dtable), 83 | &argument, &result); 84 | } 85 | -------------------------------------------------------------------------------- /utils/mountd/mountd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * utils/mountd/mountd.h 3 | * 4 | * Declarations for mountd. 5 | * 6 | * Copyright (C) 1996, Olaf Kirch 7 | */ 8 | 9 | #ifndef MOUNTD_H 10 | #define MOUNTD_H 11 | 12 | #include 13 | #include 14 | #include "nfslib.h" 15 | #include "exportfs.h" 16 | #include "mount.h" 17 | 18 | union mountd_arguments { 19 | dirpath dirpath; 20 | }; 21 | 22 | union mountd_results { 23 | fhstatus fstatus; 24 | mountlist mountlist; 25 | exports exports; 26 | }; 27 | 28 | /* 29 | * Global Function prototypes. 30 | */ 31 | bool_t mount_null_1_svc(struct svc_req *, void *, void *); 32 | bool_t mount_mnt_1_svc(struct svc_req *, dirpath *, fhstatus *); 33 | bool_t mount_dump_1_svc(struct svc_req *, void *, mountlist *); 34 | bool_t mount_umnt_1_svc(struct svc_req *, dirpath *, void *); 35 | bool_t mount_umntall_1_svc(struct svc_req *, void *, void *); 36 | bool_t mount_export_1_svc(struct svc_req *, void *, exports *); 37 | bool_t mount_exportall_1_svc(struct svc_req *, void *, exports *); 38 | bool_t mount_pathconf_2_svc(struct svc_req *, dirpath *, ppathcnf *); 39 | bool_t mount_mnt_3_svc(struct svc_req *, dirpath *, mountres3 *); 40 | 41 | void mount_dispatch(struct svc_req *, SVCXPRT *); 42 | void auth_init(void); 43 | unsigned int auth_reload(void); 44 | nfs_export * auth_authenticate(const char *what, 45 | const struct sockaddr *caller, 46 | const char *path); 47 | void auth_export(nfs_export *exp); 48 | 49 | void mountlist_add(char *host, const char *path); 50 | void mountlist_del(char *host, const char *path); 51 | void mountlist_del_all(const struct sockaddr *sap); 52 | mountlist mountlist_list(void); 53 | 54 | void cache_open(void); 55 | struct nfs_fh_len * 56 | cache_get_filehandle(nfs_export *exp, int len, char *p); 57 | int cache_export(nfs_export *exp, char *path); 58 | 59 | bool ipaddr_client_matches(nfs_export *exp, struct addrinfo *ai); 60 | bool namelist_client_matches(nfs_export *exp, char *dom); 61 | bool client_matches(nfs_export *exp, char *dom, struct addrinfo *ai); 62 | 63 | static inline bool is_ipaddr_client(char *dom) 64 | { 65 | return dom[0] == '$'; 66 | } 67 | 68 | #endif /* MOUNTD_H */ 69 | -------------------------------------------------------------------------------- /utils/nfsd/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | man8_MANS = nfsd.man 4 | EXTRA_DIST = $(man8_MANS) 5 | 6 | RPCPREFIX = rpc. 7 | KPREFIX = @kprefix@ 8 | sbin_PROGRAMS = nfsd 9 | 10 | noinst_HEADERS = nfssvc.h 11 | nfsd_SOURCES = nfsd.c nfssvc.c 12 | nfsd_LDADD = ../../support/nfs/libnfs.a $(LIBTIRPC) 13 | 14 | MAINTAINERCLEANFILES = Makefile.in 15 | 16 | ####################################################################### 17 | # The following allows the current practice of having 18 | # daemons renamed during the install to include RPCPREFIX 19 | # and the KPREFIX 20 | # This could all be done much easier with program_transform_name 21 | # ( program_transform_name = s/^/$(RPCPREFIX)$(KPREFIX)/ ) 22 | # but that also renames the man pages, which the current 23 | # practice does not do. 24 | install-exec-hook: 25 | (cd $(DESTDIR)$(sbindir) && \ 26 | for p in $(sbin_PROGRAMS); do \ 27 | mv -f $$p$(EXEEXT) $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ 28 | done) 29 | uninstall-hook: 30 | (cd $(DESTDIR)$(sbindir) && \ 31 | for p in $(sbin_PROGRAMS); do \ 32 | rm -f $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ 33 | done) 34 | 35 | 36 | # XXX This makes some assumptions about what automake does. 37 | # XXX But there is no install-man-hook or install-man-local. 38 | install-man: install-man8 install-man-links 39 | uninstall-man: uninstall-man8 uninstall-man-links 40 | 41 | install-man-links: 42 | (cd $(DESTDIR)$(man8dir) && \ 43 | for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ 44 | inst=`echo $$m | sed -e 's/man$$/8/'`; \ 45 | rm -f $(RPCPREFIX)$$inst ; \ 46 | $(LN_S) $$inst $(RPCPREFIX)$$inst ; \ 47 | done) 48 | 49 | uninstall-man-links: 50 | (cd $(DESTDIR)$(man8dir) && \ 51 | for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ 52 | inst=`echo $$m | sed -e 's/man$$/8/'`; \ 53 | rm -f $(RPCPREFIX)$$inst ; \ 54 | done) 55 | 56 | -------------------------------------------------------------------------------- /utils/nfsd/nfssvc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * utils/nfsd/nfssvc.h -- nfs service control routines for rpc.nfsd 3 | * 4 | * Copyright (C) 2009 Red Hat, Inc . 5 | * Copyright (C) 2009 Jeff Layton 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA 20 | * 21 | */ 22 | 23 | void nfssvc_mount_nfsdfs(char *progname); 24 | int nfssvc_inuse(void); 25 | int nfssvc_set_sockets(const unsigned int protobits, 26 | const char *host, const char *port); 27 | void nfssvc_set_time(const char *type, const int seconds); 28 | int nfssvc_set_rdmaport(const char *port); 29 | void nfssvc_setvers(unsigned int ctlbits, unsigned int minorvers4, unsigned int minorvers4set); 30 | int nfssvc_threads(unsigned short port, int nrservs); 31 | -------------------------------------------------------------------------------- /utils/nfsdcltrack/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | # These binaries go in /sbin (not /usr/sbin), and that cannot be 4 | # overridden at config time. The kernel "knows" the /sbin name. 5 | sbindir = /sbin 6 | 7 | man8_MANS = nfsdcltrack.man 8 | EXTRA_DIST = $(man8_MANS) 9 | 10 | AM_CFLAGS += -D_LARGEFILE64_SOURCE 11 | sbin_PROGRAMS = nfsdcltrack 12 | 13 | noinst_HEADERS = sqlite.h 14 | 15 | nfsdcltrack_SOURCES = nfsdcltrack.c sqlite.c 16 | nfsdcltrack_LDADD = ../../support/nfs/libnfs.a $(LIBSQLITE) $(LIBCAP) 17 | 18 | MAINTAINERCLEANFILES = Makefile.in 19 | 20 | -------------------------------------------------------------------------------- /utils/nfsdcltrack/sqlite.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Red Hat, Jeff Layton 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef _SQLITE_H_ 21 | #define _SQLITE_H_ 22 | 23 | int sqlite_prepare_dbh(const char *topdir); 24 | int sqlite_insert_client(const unsigned char *clname, const size_t namelen, 25 | const bool has_session, const bool zerotime); 26 | int sqlite_remove_client(const unsigned char *clname, const size_t namelen); 27 | int sqlite_check_client(const unsigned char *clname, const size_t namelen, 28 | const bool has_session); 29 | int sqlite_remove_unreclaimed(const time_t grace_start); 30 | int sqlite_query_reclaiming(const time_t grace_start); 31 | 32 | #endif /* _SQLITE_H */ 33 | -------------------------------------------------------------------------------- /utils/nfsidmap/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | man8_MANS = nfsidmap.man 4 | sbin_PROGRAMS = nfsidmap 5 | 6 | nfsidmap_SOURCES = nfsidmap.c 7 | nfsidmap_LDADD = $(LIBNFSIDMAP) -lkeyutils ../../support/nfs/libnfs.a 8 | 9 | MAINTAINERCLEANFILES = Makefile.in 10 | EXTRA_DIST = id_resolver.conf $(man8_MANS) 11 | -------------------------------------------------------------------------------- /utils/nfsidmap/id_resolver.conf: -------------------------------------------------------------------------------- 1 | create id_resolver * * /usr/sbin/nfsidmap -t 600 %k %d 2 | -------------------------------------------------------------------------------- /utils/nfsstat/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | man8_MANS = nfsstat.man 4 | EXTRA_DIST = $(man8_MANS) 5 | 6 | sbin_PROGRAMS = nfsstat 7 | nfsstat_SOURCES = nfsstat.c 8 | nfsstat_LDADD = ../../support/export/libexport.a \ 9 | ../../support/nfs/libnfs.a \ 10 | ../../support/misc/libmisc.a 11 | 12 | MAINTAINERCLEANFILES = Makefile.in 13 | -------------------------------------------------------------------------------- /utils/osd_login/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | # These binaries go in /sbin (not /usr/sbin), and that cannot be 4 | # overridden at config time. 5 | sbindir = /sbin 6 | 7 | dist_sbin_SCRIPTS = osd_login 8 | 9 | MAINTAINERCLEANFILES = Makefile.in 10 | -------------------------------------------------------------------------------- /utils/osd_login/osd_login: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # osd_login : This script is part of the autologin feature 4 | # mandated by the pnfs-objects standard. 5 | # It is called from objlayoutdriver.ko in the kernel. 6 | 7 | # Copyright (C) 2012, Sachin Bhamare 8 | # Copyright (C) 2012, Boaz Harrosh 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 as 12 | # published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 22 | # MA 02110-1301 USA 23 | 24 | umask 022 25 | 26 | PATH="/sbin:/usr/sbin:/bin:/usr/bin" 27 | 28 | iscsiadm=/sbin/iscsiadm 29 | 30 | PARENT_PID=$BASHPID 31 | WATCHDOG_TIMEOUT=15 32 | 33 | protocol="" 34 | portal="" 35 | uri="" 36 | osdname="" 37 | systemid="" 38 | 39 | usage() 40 | { 41 | echo "Usage: $0 -u -o -s " 42 | echo "Options:" 43 | echo "-u target uri e.g. iscsi://:" 44 | echo "-o osdname of the target OSD" 45 | echo "-s systemid of the target OSD" 46 | } 47 | 48 | parse_cmdline() 49 | { 50 | argc=$# 51 | if [ $# -lt 3 ]; then 52 | usage 53 | exit 1 54 | fi 55 | 56 | # parse the input arguments 57 | while getopts "u:o:s:" options; do 58 | case $options in 59 | u ) uri=$OPTARG;; 60 | o ) osdname=$OPTARG;; 61 | s ) systemid=$OPTARG;; 62 | \? ) usage 63 | exit 1;; 64 | * ) usage 65 | exit 1;; 66 | esac 67 | done 68 | 69 | echo "-u : $uri" 70 | echo "-o : $osdname" 71 | echo "-s : $systemid" 72 | 73 | protocol=`echo $uri | awk -F ':' '{print $1}'` 74 | portal=`echo $uri | awk -F '//' '{print $2}'` 75 | } 76 | 77 | watchdog() 78 | { 79 | timeout=$1 80 | portal=$2 81 | 82 | sleep $timeout 83 | if kill -9 $PARENT_PID; then 84 | echo "watchdog : Timed out (>$timeout seconds) while login into $portal" | logger -t "osd_login" 85 | fi 86 | echo "watchdog: exiting .." 87 | exit 2 88 | } 89 | 90 | login_iscsi_osd() 91 | { 92 | echo "login into: $1" 93 | if ! $iscsiadm -m discovery -o nonpersistent -t sendtargets -p $1 --login; then 94 | echo "$iscsiadm -m discovery -t sendtargets -p $1 --login returned error $? !" 95 | sleep 1; 96 | fi 97 | } 98 | 99 | echo "============= osd_login =========" 100 | echo "progname : $0" 101 | parse_cmdline "$@" 102 | echo "protocol: $protocol" 103 | echo "portal: $portal" 104 | 105 | watchdog $WATCHDOG_TIMEOUT $portal & 106 | watchdog_pid=$! 107 | 108 | case $protocol in 109 | iscsi) 110 | login_iscsi_osd $portal |& logger -t "osd_login" 111 | ;; 112 | *) 113 | echo "Error: protocol $protocol not supported !" | logger -t "osd_login" 114 | ;; 115 | esac 116 | 117 | kill -9 $watchdog_pid 118 | exit 0 119 | -------------------------------------------------------------------------------- /utils/showmount/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | man8_MANS = showmount.man 4 | EXTRA_DIST = $(man8_MANS) 5 | 6 | sbin_PROGRAMS = showmount 7 | showmount_SOURCES = showmount.c 8 | showmount_LDADD = ../../support/export/libexport.a \ 9 | ../../support/nfs/libnfs.a \ 10 | ../../support/misc/libmisc.a \ 11 | $(LIBTIRPC) 12 | showmount_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS) \ 13 | -I$(top_builddir)/support/export 14 | 15 | MAINTAINERCLEANFILES = Makefile.in 16 | -------------------------------------------------------------------------------- /utils/showmount/showmount.man: -------------------------------------------------------------------------------- 1 | .\" Copyright 1993 Rick Sladkey 2 | .\" May be distributed under the GNU General Public License 3 | .TH SHOWMOUNT 8 "6 October 1993" 4 | .SH NAME 5 | showmount \- show mount information for an NFS server 6 | .SH SYNOPSIS 7 | .B showmount 8 | .B "[\ \-adehv\ ]" 9 | .B "[\ \-\-all\ ]" 10 | .B "[\ \-\-directories\ ]" 11 | .B "[\ \-\-exports\ ]" 12 | .B "[\ \-\-help\ ]" 13 | .B "[\ \-\-version\ ]" 14 | .B "[\ host\ ]" 15 | .SH DESCRIPTION 16 | .B showmount 17 | queries the mount daemon on a remote host for information about 18 | the state of the NFS server on that machine. With no options 19 | .B showmount 20 | lists the set of clients who are mounting from that host. 21 | The output from 22 | .B showmount 23 | is designed to 24 | appear as though it were processed through ``sort \-u''. 25 | .SH OPTIONS 26 | .TP 27 | .BR \-a " or " \-\-all 28 | List both the client hostname or IP address and mounted directory in 29 | host:dir format. This info should not be considered reliable. See the notes 30 | on rmtab in 31 | .BR rpc.mountd (8). 32 | .TP 33 | .BR \-d " or " \-\-directories 34 | List only the directories mounted by some client. 35 | .TP 36 | .BR \-e " or " \-\-exports 37 | Show the NFS server's export list. 38 | .TP 39 | .BR \-h " or " \-\-help 40 | Provide a short help summary. 41 | .TP 42 | .BR \-v " or " \-\-version 43 | Report the current version number of the program. 44 | .TP 45 | .B \-\-no\-headers 46 | Suppress the descriptive headings from the output. 47 | .SH "SEE ALSO" 48 | .BR rpc.mountd (8), 49 | .BR rpc.nfsd (8) 50 | .SH BUGS 51 | The completeness and accuracy of the information that 52 | .B showmount 53 | displays varies according to the NFS server's implementation. 54 | .P 55 | Because 56 | .B showmount 57 | sorts and uniqs the output, it is impossible to determine from 58 | the output whether a client is mounting the same directory more than once. 59 | .SH AUTHOR 60 | Rick Sladkey 61 | -------------------------------------------------------------------------------- /utils/statd/.gitignore: -------------------------------------------------------------------------------- 1 | sm-notify 2 | -------------------------------------------------------------------------------- /utils/statd/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | man8_MANS = statd.man sm-notify.man 4 | 5 | RPCPREFIX = rpc. 6 | KPREFIX = @kprefix@ 7 | sbin_PROGRAMS = statd sm-notify 8 | dist_sbin_SCRIPTS = start-statd 9 | statd_SOURCES = callback.c notlist.c misc.c monitor.c hostname.c \ 10 | simu.c stat.c statd.c svc_run.c rmtcall.c \ 11 | notlist.h statd.h system.h 12 | sm_notify_SOURCES = sm-notify.c 13 | 14 | BUILT_SOURCES = $(GENFILES) 15 | statd_LDADD = ../../support/nsm/libnsm.a \ 16 | ../../support/nfs/libnfs.a \ 17 | ../../support/misc/libmisc.a \ 18 | $(LIBWRAP) $(LIBNSL) $(LIBCAP) $(LIBTIRPC) 19 | sm_notify_LDADD = ../../support/nsm/libnsm.a \ 20 | ../../support/nfs/libnfs.a \ 21 | $(LIBNSL) $(LIBCAP) $(LIBTIRPC) 22 | 23 | EXTRA_DIST = sim_sm_inter.x $(man8_MANS) simulate.c 24 | 25 | if CONFIG_RPCGEN 26 | RPCGEN = $(top_builddir)/tools/rpcgen/rpcgen 27 | $(RPCGEN): 28 | make -C ../../tools/rpcgen all 29 | else 30 | RPCGEN = @RPCGEN_PATH@ 31 | endif 32 | 33 | $(GENFILES_CLNT): %_clnt.c: %.x $(RPCGEN) 34 | test -f $@ && rm -rf $@ || true 35 | $(RPCGEN) -l -o $@ $< 36 | 37 | $(GENFILES_SVC): %_svc.c: %.x $(RPCGEN) 38 | test -f $@ && rm -rf $@ || true 39 | $(RPCGEN) -m -o $@ $< 40 | 41 | $(GENFILES_XDR): %_xdr.c: %.x $(RPCGEN) 42 | test -f $@ && rm -rf $@ || true 43 | $(RPCGEN) -c -o $@ $< 44 | 45 | $(GENFILES_H): %.h: %.x $(RPCGEN) 46 | test -f $@ && rm -rf $@ || true 47 | $(RPCGEN) -h -o $@ $< 48 | 49 | MAINTAINERCLEANFILES = Makefile.in 50 | 51 | CLEANFILES = $(GENFILES) 52 | 53 | ####################################################################### 54 | # The following allows the current practice of having 55 | # daemons renamed during the install to include RPCPREFIX 56 | # and the KPREFIX 57 | # This could all be done much easier with program_transform_name 58 | # ( program_transform_name = s/^/$(RPCPREFIX)$(KPREFIX)/ ) 59 | # but that also renames the man pages, which the current 60 | # practice does not do. 61 | install-exec-hook: 62 | (cd $(DESTDIR)$(sbindir) && \ 63 | for p in $(sbin_PROGRAMS); do \ 64 | [ $$p = sm-notify ] || mv -f $$p$(EXEEXT) $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ 65 | done) 66 | uninstall-hook: 67 | (cd $(DESTDIR)$(sbindir) && \ 68 | for p in $(sbin_PROGRAMS); do \ 69 | [ $$p = sm-notify ] || rm -f $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ 70 | done) 71 | 72 | 73 | # XXX This makes some assumptions about what automake does. 74 | # XXX But there is no install-man-hook or install-man-local. 75 | install-man: install-man8 install-man-links 76 | uninstall-man: uninstall-man8 uninstall-man-links 77 | 78 | install-man-links: 79 | (cd $(DESTDIR)$(man8dir) && \ 80 | for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ 81 | inst=`echo $$m | sed -e 's/man$$/8/'`; \ 82 | rm -f $(RPCPREFIX)$$inst ; \ 83 | $(LN_S) $$inst $(RPCPREFIX)$$inst ; \ 84 | done) 85 | 86 | uninstall-man-links: 87 | (cd $(DESTDIR)$(man8dir) && \ 88 | for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ 89 | inst=`echo $$m | sed -e 's/man$$/8/'`; \ 90 | rm -f $(RPCPREFIX)$$inst ; \ 91 | done) 92 | 93 | -------------------------------------------------------------------------------- /utils/statd/TODO: -------------------------------------------------------------------------------- 1 | Some things still left to do (not a comprehensive list): 2 | 3 | * Go through Olaf's extensive changes (especially the list and callback 4 | handling, which is the meat of the server) and understand everything 5 | that he's done. 6 | 7 | * Continue checking for security holes. 8 | 9 | * Handle multiple SM_MON requests that are identical save for the "priv" 10 | information. How should I do this? No spec's...(it's not really 11 | supposed to happen). [Did Olaf already address this?] 12 | 13 | * BETTER CODE COMMENTS! 14 | -------------------------------------------------------------------------------- /utils/statd/misc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1995-1999 Jeffrey A. Uphoff 3 | * Modified by Olaf Kirch, 1996. 4 | * Modified by H.J. Lu, 1998. 5 | * 6 | * NSM for Linux. 7 | */ 8 | 9 | #ifdef HAVE_CONFIG_H 10 | #include 11 | #endif 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include "statd.h" 18 | #include "notlist.h" 19 | 20 | /* 21 | * Error-checking malloc() wrapper. 22 | */ 23 | void * 24 | xmalloc (size_t size) 25 | { 26 | void *ptr; 27 | 28 | if (size == 0) 29 | return ((void *)NULL); 30 | 31 | if (!(ptr = malloc (size))) 32 | xlog_err ("malloc failed"); 33 | 34 | return (ptr); 35 | } 36 | 37 | 38 | /* 39 | * Error-checking strdup() wrapper. 40 | */ 41 | char * 42 | xstrdup (const char *string) 43 | { 44 | char *result; 45 | 46 | /* Will only fail if underlying malloc() fails (ENOMEM). */ 47 | if (!(result = strdup (string))) 48 | xlog_err ("strdup failed"); 49 | 50 | return (result); 51 | } 52 | -------------------------------------------------------------------------------- /utils/statd/notlist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1995, 1997-1999, 2002 Jeffrey A. Uphoff 3 | * Major rewrite by Olaf Kirch, Dec. 1996. 4 | * 5 | * NSM for Linux. 6 | */ 7 | 8 | #include 9 | 10 | /* 11 | * Primary information structure. 12 | */ 13 | struct notify_list { 14 | mon mon; /* Big honkin' NSM structure. */ 15 | in_port_t port; /* port number for callback */ 16 | short int times; /* Counter used for various things. */ 17 | int state; /* For storing notified state for callbacks. */ 18 | char *dns_name; /* used for matching incoming 19 | * NOTIFY requests */ 20 | struct notify_list *next; /* Linked list forward pointer. */ 21 | struct notify_list *prev; /* Linked list backward pointer. */ 22 | uint32_t xid; /* XID of MS_NOTIFY RPC call */ 23 | time_t when; /* notify: timeout for re-xmit */ 24 | }; 25 | 26 | typedef struct notify_list notify_list; 27 | 28 | /* 29 | * Global Variables 30 | */ 31 | extern notify_list * rtnl; /* Run-time notify list */ 32 | extern notify_list * notify; /* Pending RPC calls */ 33 | 34 | /* 35 | * List-handling functions 36 | */ 37 | extern notify_list * nlist_new(char *, char *, int); 38 | extern void nlist_insert(notify_list **, notify_list *); 39 | extern void nlist_remove(notify_list **, notify_list *); 40 | extern void nlist_insert_timer(notify_list **, notify_list *); 41 | extern notify_list * nlist_clone(notify_list *); 42 | extern void nlist_free(notify_list **, notify_list *); 43 | extern void nlist_kill(notify_list **); 44 | extern notify_list * nlist_gethost(notify_list *, char *, int); 45 | 46 | /* 47 | * List-handling macros. 48 | * THESE INHERIT INFORMATION FROM PREVIOUSLY-DEFINED MACROS. 49 | * (So don't change their order unless you study them first!) 50 | */ 51 | #define NL_NEXT(L) ((L)->next) 52 | #define NL_FIRST NL_NEXT 53 | #define NL_PREV(L) ((L)->prev) 54 | #define NL_DATA(L) ((L)->mon) 55 | #define NL_STATE(L) ((L)->state) 56 | #define NL_TIMES(L) ((L)->times) 57 | #define NL_MON_ID(L) (NL_DATA((L)).mon_id) 58 | #define NL_PRIV(L) (NL_DATA((L)).priv) 59 | #define NL_MON_NAME(L) (NL_MON_ID((L)).mon_name) 60 | #define NL_MY_ID(L) (NL_MON_ID((L)).my_id) 61 | #define NL_MY_NAME(L) (NL_MY_ID((L)).my_name) 62 | #define NL_MY_PROC(L) (NL_MY_ID((L)).my_proc) 63 | #define NL_MY_PROG(L) (NL_MY_ID((L)).my_prog) 64 | #define NL_MY_VERS(L) (NL_MY_ID((L)).my_vers) 65 | #define NL_WHEN(L) ((L)->when) 66 | -------------------------------------------------------------------------------- /utils/statd/sim_sm_inter.x: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1995, 1997-1999 Jeffrey A. Uphoff 3 | * Modified by Olaf Kirch, 1996. 4 | * Modified by H.J. Lu, 1998. 5 | * 6 | * NSM for Linux. 7 | */ 8 | 9 | #ifdef RPC_CLNT 10 | %#include 11 | #endif 12 | 13 | program SIM_SM_PROG { 14 | version SIM_SM_VERS { 15 | void SIM_SM_MON(struct status) = 1; 16 | } = 1; 17 | } = 200048; 18 | 19 | const SM_MAXSTRLEN = 1024; 20 | const SM_PRIV_SIZE = 16; 21 | 22 | /* 23 | * structure of the status message sent back by the status monitor 24 | * when monitor site status changes 25 | */ 26 | %#ifndef SM_INTER_X 27 | struct status { 28 | string mon_name; 29 | int state; 30 | opaque priv[SM_PRIV_SIZE]; /* stored private information */ 31 | }; 32 | %#endif /* SM_INTER_X */ 33 | -------------------------------------------------------------------------------- /utils/statd/simu.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1995, 1997-1999 Jeffrey A. Uphoff 3 | * 4 | * NSM for Linux. 5 | */ 6 | 7 | #ifdef HAVE_CONFIG_H 8 | #include 9 | #endif 10 | 11 | #include 12 | #include 13 | 14 | #include "sockaddr.h" 15 | #include "rpcmisc.h" 16 | #include "statd.h" 17 | #include "notlist.h" 18 | 19 | extern void my_svc_exit (void); 20 | 21 | 22 | /* 23 | * Services SM_SIMU_CRASH requests. 24 | * 25 | * Although the kernel contacts the statd service via only IPv4 26 | * transports, the statd service can receive other requests, such 27 | * as SM_NOTIFY, from remote peers via IPv6. 28 | */ 29 | void * 30 | sm_simu_crash_1_svc (__attribute__ ((unused)) void *argp, struct svc_req *rqstp) 31 | { 32 | struct sockaddr *sap = nfs_getrpccaller(rqstp->rq_xprt); 33 | char buf[INET6_ADDRSTRLEN]; 34 | static char *result = NULL; 35 | 36 | xlog(D_CALL, "Received SM_SIMU_CRASH"); 37 | 38 | if (!nfs_is_v4_loopback(sap)) 39 | goto out_nonlocal; 40 | 41 | if ((int)nfs_get_port(sap) >= IPPORT_RESERVED) { 42 | xlog_warn("SM_SIMU_CRASH call from unprivileged port"); 43 | goto failure; 44 | } 45 | 46 | my_svc_exit (); 47 | 48 | if (rtnl) 49 | nlist_kill (&rtnl); 50 | 51 | failure: 52 | return ((void *)&result); 53 | 54 | out_nonlocal: 55 | if (!statd_present_address(sap, buf, sizeof(buf))) 56 | buf[0] = '\0'; 57 | xlog_warn("SM_SIMU_CRASH call from non-local host %s", buf); 58 | goto failure; 59 | } 60 | -------------------------------------------------------------------------------- /utils/statd/start-statd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # nfsmount calls this script when mounting a filesystem with locking 3 | # enabled, but when statd does not seem to be running (based on 4 | # /var/run/rpc.statd.pid). 5 | # It should run statd with whatever flags are apropriate for this 6 | # site. 7 | PATH="/sbin:/usr/sbin:/bin:/usr/bin" 8 | 9 | # Use flock to serialize the running of this script 10 | exec 200> /var/run/rpc.statd.lock 11 | flock -e 200 12 | 13 | if [ -s /var/run/rpc.statd.pid ] && 14 | [ 1`cat /var/run/rpc.statd.pid` -gt 1 ] && 15 | kill -0 `cat /var/run/rpc.statd.pid` > /dev/null 2>&1 16 | then 17 | # statd already running - must have been slow to respond. 18 | exit 0 19 | fi 20 | # First try systemd if it's installed. 21 | if [ -d /run/systemd/system ]; then 22 | # Quit only if the call worked. 23 | systemctl start rpc-statd.service && exit 24 | fi 25 | 26 | cd / 27 | # Fall back to launching it ourselves. 28 | exec rpc.statd --no-notify 29 | -------------------------------------------------------------------------------- /utils/statd/stat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1995, 1997, 1999 Jeffrey A. Uphoff 3 | * Modified by Olaf Kirch, 1996. 4 | * 5 | * NSM for Linux. 6 | */ 7 | 8 | #ifdef HAVE_CONFIG_H 9 | #include 10 | #endif 11 | 12 | #include 13 | #include "statd.h" 14 | 15 | /* 16 | * Services SM_STAT requests. 17 | * 18 | * According the the X/Open spec's on this procedure: "Implementations 19 | * should not rely on this procedure being operative. In many current 20 | * implementations of the NSM it will always return a 'STAT_FAIL' 21 | * status." My implementation is operative; it returns 'STAT_SUCC' 22 | * whenever it can resolve the hostname that it's being asked to 23 | * monitor, and returns 'STAT_FAIL' otherwise. 24 | * 25 | * sm_inter.x says the 'state' returned should be 26 | * "state number of site sm_name". It is not clear how to get this. 27 | * X/Open says: 28 | * STAT_SUCC 29 | * The NSM will monitor the given host. "sm_stat_res.state" contains 30 | * the state of the NSM. 31 | * Which implies that 'state' is the state number of the *local* NSM. 32 | * href=http://www.opengroup.org/onlinepubs/9629799/SM_STAT.htm 33 | * 34 | * We return the *local* state as 35 | * 1/ We have easy access to it. 36 | * 2/ It might be useful to a remote client who needs it and has no 37 | * other way to get it. 38 | * 3/ That's what we always did in the past. 39 | */ 40 | struct sm_stat_res * 41 | sm_stat_1_svc(struct sm_name *argp, 42 | __attribute__ ((unused)) struct svc_req *rqstp) 43 | { 44 | static sm_stat_res result; 45 | char *name; 46 | 47 | xlog(D_CALL, "Received SM_STAT from %s", argp->mon_name); 48 | 49 | name = statd_canonical_name(argp->mon_name); 50 | if (name == NULL) { 51 | result.res_stat = STAT_FAIL; 52 | xlog (D_GENERAL, "STAT_FAIL for %s", argp->mon_name); 53 | } else { 54 | result.res_stat = STAT_SUCC; 55 | xlog (D_GENERAL, "STAT_SUCC for %s", argp->mon_name); 56 | free(name); 57 | } 58 | result.state = MY_STATE; 59 | return(&result); 60 | } 61 | -------------------------------------------------------------------------------- /utils/statd/statd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1995-1997, 1999 Jeffrey A. Uphoff 3 | * Modified by Olaf Kirch, Dec. 1996. 4 | * 5 | * NSM for Linux. 6 | */ 7 | 8 | #ifdef HAVE_CONFIG_H 9 | #include 10 | #endif 11 | 12 | #include "sm_inter.h" 13 | #include "system.h" 14 | #include "xlog.h" 15 | 16 | /* 17 | * Status definitions. 18 | */ 19 | #define STAT_FAIL stat_fail 20 | #define STAT_SUCC stat_succ 21 | 22 | /* 23 | * Function prototypes. 24 | */ 25 | extern _Bool statd_matchhostname(const char *hostname1, const char *hostname2); 26 | extern _Bool statd_present_address(const struct sockaddr *sap, char *buf, 27 | const size_t buflen); 28 | __attribute__((__malloc__)) 29 | extern char * statd_canonical_name(const char *hostname); 30 | 31 | extern void my_svc_run(int); 32 | extern void notify_hosts(void); 33 | extern void shuffle_dirs(void); 34 | extern int statd_get_socket(void); 35 | extern int process_notify_list(void); 36 | extern int process_reply(FD_SET_TYPE *); 37 | extern char * xstrdup(const char *); 38 | extern void * xmalloc(size_t); 39 | extern void load_state(void); 40 | 41 | /* 42 | * Host status structure and macros. 43 | */ 44 | stat_chge SM_stat_chge; 45 | #define MY_NAME SM_stat_chge.mon_name 46 | #define MY_STATE SM_stat_chge.state 47 | 48 | /* 49 | * Some timeout values. (Timeout values are in whole seconds.) 50 | */ 51 | #define CALLBACK_TIMEOUT 3 /* For client call-backs. */ 52 | #define NOTIFY_TIMEOUT 5 /* For status-change notifications. */ 53 | #define SELECT_TIMEOUT 10 /* Max select() timeout when work to do. */ 54 | #define MAX_TRIES 5 /* Max number of tries for any host. */ 55 | 56 | /* 57 | * Modes of operation - Lon 58 | */ 59 | extern int run_mode; 60 | #define MODE_NODAEMON 1 /* No-daemon/foreground mode. */ 61 | #define MODE_LOG_STDERR 2 /* in foreground mode, log to stderr */ 62 | #define MODE_NOTIFY_ONLY 4 /* Send SM_NOTIFY to everyone monitored on 63 | a single interface/alias */ 64 | /* LH - notify_only mode would be for notifying hosts on an IP alias 65 | * that just came back up, for ex, when failing over a HA service to 66 | * another host.... */ 67 | #define STATIC_HOSTNAME 8 /* Always use the hostname set by -n */ 68 | #define MODE_NO_NOTIFY 16 /* Don't notify peers of a reboot */ 69 | -------------------------------------------------------------------------------- /utils/statd/system.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1996 Olaf Kirch 3 | * Modified by Jeffrey A. Uphoff, 1997, 1999. 4 | * 5 | * NSM for Linux. 6 | */ 7 | 8 | /* 9 | * System-dependent declarations 10 | */ 11 | 12 | #ifdef FD_SETSIZE 13 | # define FD_SET_TYPE fd_set 14 | # define SVC_FDSET svc_fdset 15 | #else 16 | # define FD_SET_TYPE int 17 | # define SVC_FDSET svc_fds 18 | #endif 19 | --------------------------------------------------------------------------------