Prem Karat [Tue, 28 Jun 2011 15:53:40 +0000 (11:53 -0400)]
mount.nfs: Don't hard code source and destination
Currently souce and destination parameters should be passed as first and
second paramter while using mount.nfs. This patch allows them to be passed
anywhere while mounting.
Current functionality is
mount.nfs source destn -o <options>
This patch will allow to do this
mount.nfs -o <options> source destn
or
mount.nfs -o <options> source -o <options> destn
Signed-off-by: Prem Karat <prem.karat@linux.vnet.ibm.com> Signed-off-by: Steve Dickson <steved@redhat.com>
NeilBrown [Tue, 28 Jun 2011 15:36:31 +0000 (11:36 -0400)]
mount: improve signal management when locking mtab
As mount.nfs can run setuid it must be careful about how the user can
interact with in. In particular it needs to ensure it does not
respond badly to any signals that the user might be able to generate.
This is particularly an issue while updating /etc/mtab (when that is
not linked to /proc/mounts). If the user can generate a signal which
kills mount.nfs while /etc/mtab is locked, then it will leave the file
locked, and could possibly corrupt mtab (particularly if 'ulimit 1'
was previously issued).
Currently lock_mtab does set some handlers for signals, but not
enough. It arranges for every signal up to (but not including)
SIGCHLD to cause mount.nfs to unlock mdadm promptly exit ... even if
the default behaviour would be to ignore the signal. SIGALRM is
handled specially, and signals after SIGCHLD are left with their
default behaviour. This includes for example SIGXFSZ which can be
generated by the user running "ulimit 1".
So: change this so that some signals are left unchanged, SIGALRM is
handled as required, and all signals that the user can generate are
explicitly ignored.
The remainder still cause mount.nfs to print a message, unlock mtab, and
exit.
Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
J. Bruce Fields [Mon, 27 Jun 2011 16:30:36 +0000 (12:30 -0400)]
mountd: gather fsid information into one struct
A large part of nfsd_fh() is concerned with extracting
fsid-type-specific information from the fsid, then matching that
information with information from the export list and the filesystem.
Moving all that information into one struct will allow some further
simplifications.
Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
J. Bruce Fields [Mon, 27 Jun 2011 16:29:51 +0000 (12:29 -0400)]
mountd: prefer explicit subexports over crossmnt parents
If a parent is exported with crossmnt, and if a child is also explicitly
exported, then both exports could potentially produce matches in this
loop; that isn't a bug.
Instead of warning and ignoring the second match we find, we should
instead prefer whichever export is deeper in the tree, so that
children's options can override those of their parents.
Reported-by: Olga Kornievskaia <aglo@citi.umich.edu> Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
James Pearson [Wed, 22 Jun 2011 19:51:47 +0000 (15:51 -0400)]
nfs-utils: remove possibly false statement from exports.man
A very minor change suggested by J. Bruce Fields <bfields@fieldses.org>
to remove the statement that exporting to a single host or IP address is
the "most common format" - as it probably isn't.
Signed-off-by: James Pearson <james-p@moving-picture.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Jeff Layton [Wed, 22 Jun 2011 19:51:02 +0000 (15:51 -0400)]
manpage: add info about IPv6 configuration to exports(5)
The parts of the exports(5) manpage that discuss IP addressing neglect
IPv6 configuration. Update to include info on how to export to IPv6
subnets and addresses, and add a line demonstrating that to the EXAMPLE
section.
Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Jeff Layton [Wed, 22 Jun 2011 18:51:38 +0000 (14:51 -0400)]
nfs: fix host_reliable_addrinfo
According to Neil Brown:
The point of the word 'reliable' is to check that the name we get
really does belong to the host in question - ie that both the
forward and reverse maps agree.
But the new code doesn't do that check at all. Rather it simply
maps the address to a name, then discards the address and maps the
name back to a list of addresses and uses that list of addresses as
"where the request came from" for permission checking.
This bug is exploitable via the following scenario and could allow an
attacker access to data that they shouldn't be able to access.
Suppose you export a filesystem to some subnet or FQDN and also to a
wildcard or netgroup, and I know the details of this (maybe
showmount -e tells me) Suppose further that I can get IP packets to
your server..
Then I create a reverse mapping for my ipaddress to a domain that I
own, say "black.hat.org", and a forward mapping from that domain to
my IP address, and one of your IP addresses.
Then I try to mount your filesystem. The IP address gets correctly
mapped to "black.hat.org" and then mapped to both my IP address and
your IP address.
Then you search through all of your exports and find that one of the
addresses: yours - is allowed to access the filesystem.
So you create an export based on the addrinfo you have which allows
my IP address the same access as your IP address.
Fix this by instead using the forward lookup of the hostname just to
verify that the original address is in the list. Then do a numeric
lookup using the address and stick the hostname in the ai_canonname.
Reviewed-by: NeilBrown <neilb@suse.de> Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Pavel Shilovsky [Tue, 7 Jun 2011 17:18:13 +0000 (13:18 -0400)]
mountd: Fix missing varialble assignment in auth_unix_gid
When we get into auth_unix_gid at the second time, groups_len
is not 0 and ngroups variable leave as 0. Then we use ngroups
in getgrouplist that fails in this case. This patch fixes it.
Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru> Signed-off-by: Steve Dickson <steved@redhat.com>
NeilBrown [Mon, 23 May 2011 12:23:51 +0000 (08:23 -0400)]
supress socket error when address family is not supported
From: Suresh Jayaraman <sjayaraman@suse.de>
It was observed that when ipv6 module was not loaded and cannot be auto-loaded,
when starting NFS server, the following error occurs:
"rpc.nfsd: unable to create inet6 TCP socket: errno 97 (Address
family not supported by protocol)"
This is obviously a true message, but does not represent an "error" when ipv6
is not enabled. Rather, it is an expected condition. As such, it can be
confusing / misleading / distracting to display it in this scenario.
This patch instead of throwing error when a socket call fails with
EAFNOSUPPORT, makes it as a NOTICE.
Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de> Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
NeilBrown [Mon, 23 May 2011 12:19:57 +0000 (08:19 -0400)]
Remove risk of nfs_addmntent corrupting mtab
nfs_addmntent is used to append directly to /etc/mtab.
If the write partially fail, e.g. due to RLIMIT_FSIZE,
truncate back to original size and return an error.
See also https://bugzilla.redhat.com/show_bug.cgi?id=697975
(CVE-2011-1749) CVE-2011-1749 nfs-utils: mount.nfs fails to anticipate RLIMIT_FSIZE
Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
Ben Myers [Mon, 23 May 2011 12:07:00 +0000 (08:07 -0400)]
exportfs: getexportent interprets -test-client- as default options
With commit 1374c3861abdc66f3a1410e26cc85f86760b51dd Neil added a
-test-client- export to test the exportability of filesystems when exportfs
is run. When using the old cache controls (i.e. /proc/fs/nfsd is not
mounted) exportfs will read /proc/fs/nfs/exports to process existing
exports and find these test client entries. The dash at the beginning of
-test-client- will be cause getexportent to look for default options in the
rest of the string, which test-client- will not match:
This patch resolves that problem (as Steve suggested) by not processing any
default options if we are reading the list of existing exports from the
kernel. Default options are converted to individual exports by exportfs so
the kernel won't have any regardless.
Signed-off-by: Ben Myers <bpm@sgi.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Sean Finney [Tue, 19 Apr 2011 15:04:35 +0000 (11:04 -0400)]
nfs-utils: Increase the stdio file buffer size for procfs files
Previously, when writing to /proc/net/rpc/*/channel, if a cache line
were larger than the default buffer size (likely 1024 bytes), mountd
and svcgssd would split writes into a number of buffer-sized writes.
Each of these writes would get an EINVAL error back from the kernel
procfs handle (it expects line-oriented input and does not account for
multiple/split writes), and no cache update would occur.
When such behavior occurs, NFS clients depending on mountd to finish
the cache operation would block/hang, or receive EPERM, depending on
the context of the operation. This is likely to happen if a user is a
member of a large (~100-200) number of groups.
Instead, every fopen() on the procfs files in question is followed by
a call to setvbuf(), using a per-file dedicated buffer of
RPC_CHAN_BUF_SIZE length.
Really, mountd should not be using stdio-style buffered file operations
on files in /proc to begin with. A better solution would be to use
internally managed buffers and calls to write() instead of these stdio
calls, but that would be a more extensive change; so this is proposed
as a quick and not-so-dirty fix in the meantime.
Signed-off-by: Sean Finney <sean.finney@sonyericsson.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Sean Finney [Tue, 19 Apr 2011 15:05:47 +0000 (11:05 -0400)]
mountd: Use a dynamic buffer for storing lists of gid's
Previously, in auth_unix_gid, group lists were stored in an array of
hard-coded length 100, and in the situation that the group lists for a
particular call were too large, the array was swapped with a dynamically
allocated/freed buffer. For environments where users are commonly in
a large number of groups, this isn't an ideal approach.
Instead, use malloc/realloc to grow the list on an as-needed basis.
Signed-off-by: Sean Finney <sean.finney@sonyericsson.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Ben Hutchings [Fri, 8 Apr 2011 04:16:04 +0000 (05:16 +0100)]
Depend on rpcbind unconditionally (Closes: #619877)
libtirpc does not support the old portmapper protocol. (It does
implement the old portmap client library functions, but still uses
rpcbind protocol.) There's no easy way to add fallback support, and
it doesn't look like we can switch between libtirpc and the portmapper
client at run-time. So require use of rpcbind.
Karel Zak [Wed, 6 Apr 2011 16:39:21 +0000 (12:39 -0400)]
mount: add --enable-libmount-mount
This patch allows to link mount.nfs with libmount from util-linux >=
v2.19. The new libmount based code is enabled by CONFIG_LIBMOUNT and
is stored in mount_libmount.c. The old code is not affected by this
change.
The libmount does not have officially stable API yet, so the
--enable-libmount-mount is marked as experimental in the configure
help output.
The ./configure option is the same as we use in util-linux to enable
support for libmount in mount(8).
The addr= (and some other options necessary for remount/umount) are
stored to /etc/mtab or to /dev/.mount/utab. The utab file is *private*
libmount file. It's possible that some mount options (for example
user=) will be moved to kernel, so the utab will not be necessary.
About libmount:
* supports systems without and with regular /etc/mtab
* does not store VFS and FS mount options in userspace
* manages user= option and evaluate permissions
* parses VFS mount options and generate MS_* flags
* parses /etc/{fstab,mtab}, /proc/mounts or /proc/self/mountinfo
* long-term goal is to use the same code in all mount.<type> helpers
Note, use
LIBMOUNT_DEBUG=0xffff mount.nfs foo:/path /path
to debug the library.
On systems with util-linux v2.19 the findmnt(8) command uses libmount
to list all/selected mount points:
$ findmnt /path
$ findmnt --mtab /path
the --mtab appends userspace mount options (e.g. user=) to the output.
CC: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Kevin Coffman [Wed, 6 Apr 2011 15:25:03 +0000 (11:25 -0400)]
nfs-utils: Add support to svcgssd to limit the negotiated enctypes
Recent versions of Kerberos libraries negotiate and use
an "acceptor subkey". This negotiation does not consider
that a service may have limited the encryption keys in its
keytab. A patch (http://src.mit.edu/fisheye/changelog/krb5/?cs=24603)
has been added to the MIT Kerberos code to allow an application
to indicate that it wants to limit the encryption types negotiated.
(This functionality has been available on the client/initiator
side for a while. The new patch adds this support to the
server/acceptor side.)
This patch adds support to read a recently added nfsd
proc file to determine the encryption types supported by
the kernel and calls the function to limit encryption
types negotiated for the acceptor subkey.
Signed-off-by: Kevin Coffman <kwc@citi.umich.edu> Signed-off-by: Steve Dickson <steved@redhat.com>
Luk Claes [Sun, 20 Mar 2011 19:18:01 +0000 (20:18 +0100)]
- mountd: fix --manage-gids hang due to int/uint bug (0f05c8a)
(Closes: #528939,585085)
- mount.nfs: Don't do anything fancy if this is a remount (f11547f)
(Closes: #612933)
- mount: Mount should retry unreachable hosts (5a355f4)
(Closes: #560388)
- Try to use kernel function to determine supported Kerberos
enctypes (258f10f) (Closes: #474037)
Luk Claes [Sun, 13 Mar 2011 17:52:57 +0000 (18:52 +0100)]
nfs-common.init, nfs-kernel-server.init: Add warning when portmap is not running (Closes: #612002)
When portmap (or rpcbind) are not running, don't try to start statd, nfsd or mountd, but warn instead that portmap is not running. This means installing nfs-common or nfs-kernel-server would succeed even if the daemons are not started.
Masatake YAMATO [Mon, 7 Mar 2011 13:18:51 +0000 (08:18 -0500)]
Read /etc/exports.d/*.export as extra export files
This patch adding a capability to read /etc/exports.d/*.exports as
extra export files to exportfs.
If one wants to add or remove an export entry in a script, currently
one may have to use sed or something tool for adding or removing the
line for the entry in /etc/exports file.
With the patch, adding and removing an entry from a script is much
easier.
cat<<EOF... or mv can be used for adding. rm can be used for removing.
Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Chuck Lever [Thu, 3 Mar 2011 22:26:33 +0000 (17:26 -0500)]
mount: Recognize zero as a valid value for the port= option
While zero is not a valid IP port number, zero does represent a valid
value for "port=". It means "query rpcbind to discover the actual
non-zero port number to use". So the parsing functions that handle
"port=" should not flag zero as an invalid value.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Jason Gunthorpe [Wed, 9 Feb 2011 16:27:19 +0000 (11:27 -0500)]
Support AD style kerberos automatically in rpc.gss
An Active Directory KDC will only grant a TGT for UPNs, getting
a TGT for SPNs is not possible:
$ kinit -k host/ib5@ADS.ORCORP.CA
kinit: Client not found in Kerberos database while getting initial
credentials
The correct thing to do for machine credentials is to get a TGT
for the computer UPN <HOSTNAME>$@REALM:
$ kinit -k IB5\$
$ klist
12/22/10 11:43:47 12/22/10 21:43:47 krbtgt/ADS.ORCORP.CA@ADS.ORCORP.CA
Samba automatically creates /etc/krb5.keytab entry for the computer UPN,
this patch makes gssd_refresh_krb5_machine_credential prefer it above
the SPNs if it is present.
The net result is that nfs client works automatically out of the box
if samba has been used to setup kerberos via 'net ads join' 'net ads
keytab create'
Tested using Windows Server 2003 R2 as the AD server.
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Steve Dickson [Wed, 26 Jan 2011 12:49:19 +0000 (07:49 -0500)]
Fixed segfault in rpc.mountd
A unallocated piece of memory, instead of a NULL point, was being
used to initialize a ->next point in the mount link list which
caused a segfault after a few remote accesses via the showmount
command.
Steve Dickson [Fri, 14 Jan 2011 15:12:28 +0000 (10:12 -0500)]
Improve debugging in svcgssd
Added in gss_display_error() which translates the GSS error into the
actual GSS macro name. Currently only the translation of these errors
are logged. Since those translations are buried deep in the kerberos
library code, having the actual GSS macro name makes it easier to
follow the code.
Moved the nfs4_init_name_mapping() call into main() so if debug is
enabled the DNS name and realms will be logged during start up.
Chuck Lever [Mon, 13 Dec 2010 19:50:45 +0000 (14:50 -0500)]
libnsm.a: sm-notify sometimes ignores monitored hosts
Monitored host information is stored in files under /var/lib/nfs.
When visiting entries in the monitored hosts directory, libnsm.a
examines the value of dirent.d_type to determine if an entry is a
regular file.
According to readdir(3), the d_type field is not supported by all
file system types. My root file system happens to be one where d_type
isn't supported. Typical installations that use an ext-derived root
file system are not exposed to this issue, but those who use xfs, for
instance, are.
On such file systems, not only are remote peers not notified of
reboots, but the NSM state number is never incremented. A statd warm
restart would not re-monitor any hosts that were monitored before
the restart.
When writing support/nsm/file.c, I copied the use of d_type from the
original statd code, so this has likely been an issue for some time.
Replace the use of d_type in support/nsm/file.c with a call to
lstat(2). It's extra code, but is guaranteed to work on all file
system types.
Note there is a usage of d_type in gssd. I'll let gssd and rpcpipefs
experts decide whether that's worth changing.
Chuck Lever [Mon, 13 Dec 2010 19:47:42 +0000 (14:47 -0500)]
libnsm.a: Replace __attribute_noinline__
Replace the __attribute_noinline__ form with
__attribute__((__noinline__)).
Even though the compiler didn't complain about __attribute_malloc__,
also replace those in order to maintain consistent style throughout the
source file.
Chuck Lever [Mon, 13 Dec 2010 19:36:15 +0000 (14:36 -0500)]
sm-notify: Make use of AI_NUMERICSERV conditional
Gabor Papp reports nfs-utils-1.2.3 doesn't build on his system that
uses glibc-2.2.5:
make[3]: Entering directory
`/home/gzp/src/nfs-utils-1.2.3/utils/statd'
gcc -DHAVE_CONFIG_H -I. -I../../support/include -D_GNU_SOURCE -Wall
-Wextra -Wstrict-prototypes -pipe -g -O2 -MT sm-notify.o -MD
-MP -MF .deps/sm-notify.Tpo -c -o sm-notify.o sm-notify.c
sm-notify.c: In function 'smn_bind_address':
sm-notify.c:247: error: 'AI_NUMERICSERV' undeclared (first use in this
function)
sm-notify.c:247: error: (Each undeclared identifier is reported only
once
sm-notify.c:247: error: for each function it appears in.)
make[3]: *** [sm-notify.o] Error 1
According to the getaddrinfo(3) man page, AI_NUMERICSERV is available
only since glibc 2.3.4. getaddrinfo(3) seems to convert strings
containing a number to the right port value without the use of
AI_NUMERICSERV, so I think we can survive on older glibc's without it.
It will allow admins to specify service names as well as port numbers
on those versions.
There are uses of AI_NUMERICSERV in gssd and in nfs_svc_create(). The
one in nfs_svc_create() is behind HAVE_LIBTIRPC, and the other is a
issue only for those who want to deploy Kerberos -- likely in both
cases, a more modern glibc will be present. I'm going to leave those
two.
nfs-utils: nfsstat: has_stats() does not function correctly for NFSv4 client stats
The NFSv4 client procs/ops in "struct rpc_procinfo nfs4_procedures" is
used to generate the NFS client stats interface:
------------------------------------------------------------
net 0 0 0 0
rpc 15 0 0
proc2 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
proc3 22 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 0
proc4 42 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0
------------------------------------------------------------
Note, for proc4, the number 42. That is the number of stats that follow
on the same line. Currently nfsstat's has_stats() relies on this number
to be equal to CLTPROC4_SZ. Unfortunately this is not the case. I have
changed has_stats() not to rely on these two values being equal. This
should also allow nfsstat to work with different kernel versions that
expose a different number of NFS client ops.
* Fix has_stats()
* Stop print_clnt_list() printing server stats!
* Describe the option -3 and -4 completely in the nfsstat manpage.
Signed-off-by: Harshula Jayasuriya <harshula@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>