summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* gssd: Duplicate the upcall string for error messagesFrank Sorenson2017-02-151-4/+13
| | | | | | | | | | | strsep() modifies the input string, so error messages may output only part of the upcall string. Make a copy of the upcall string, and use that in any error messages. Signed-off-by: Frank Sorenson <sorenson@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* gssd: replace non-thread-safe strtok with strsepFrank Sorenson2017-02-151-1/+2
| | | | | | | | | | gssd uses the non-thread-safe strtok() function, which can lead to incorrect program behavior. Replace strtok() with the thread-safe strsep(). Signed-off-by: Frank Sorenson <sorenson@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs-server-generator: handle 'noauto' mounts correctlyNeilBrown2017-02-151-0/+26
| | | | | | | | | | | | | | | | | | | When this code was written, the systemd documentation stated that "RequiresMountsFor" ignored mountpoints marked as "noauto". Unfortunately this is incorrect. Consquently a filesystem marked as noauto that is also NFS exported will currently be mounted when the NFS server is started. This is not what people expect. So add a check for the noauto flag. If any ancestor of a given export point has the noauto flag, no RequiresMountsFor will be generated for that point. Also skip RequiresMountsFor for exports marked 'mountpoint', as their absence is, theoretically, already handled by mountd. URL: https://github.com/systemd/systemd/issues/5249 Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount: call setgroups() before setuid()NeilBrown2017-02-151-0/+2
| | | | | | | | | | | | | | | It is generally wise to call setgroups() (and setgid()) before calling setuid() to ensure no unexpected permission leaks happen. SUSE's build system checks all binaries for conformance with this and generates a warning for mountd. As we are setting the uid to 0, there is no risk that the group list will provide extra permissions, so there is no real risk here. But it is nice to silence warnings, and including a setgroups() call is probably a good practice to encourage. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* conffile: ignore empty environment variables.NeilBrown2017-02-151-1/+1
| | | | | | | | | | | | | | | | | conf_set() already refuses to set an empty value, so if foo= appears in the config file, it will be ignored. This patch extends the policy to environment variables, so empty environment variables are treated as though they didn't exist. This means that a separate environment file (e.g. /etc/sysconfig/nfs) will be treated the same way whether it is: - included in the [environment] section of /etc/nfs.conf - sourced by the shell before running code - sourced by the systemd EnvironmentFile directive. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* systemd: Fix nfs-mountd dependency on rpcbindRafael David Tinoco2017-02-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Following commit 91da135f - it replaced "rpcbind.target" by "rpcbind.socket" in some unit files - "rpcbind.socket" should also be added to "nfs-mountd.service" as a dependency to avoid race conditions. Usually "rpcbind.socket" is either started as a "sockets.target" dependency, or as a dependency for "nfs-server.service", when unit files include it in "BindsTo" or "After". Unfortunately there is a possilibility to have "nfs-mountd.service" started when the rpcbind socket is not yet created: systemd[1]: Starting NFS Mount Daemon... systemd[1]: nfs-mountd.service: Control process exited, code=exited status=1 systemd[1]: Failed to start NFS Mount Daemon. systemd[1]: nfs-mountd.service: Unit entered failed state. systemd[1]: nfs-mountd.service: Failed with result 'exit-code'. Nowadays "nfs-mountd.service" uses "BindTo" directive to "nfs-server.service". That, per se, doesn't guarantee ordering for NFS server to start rpcbind and for nfs-mountd to depend on it. https://bugs.launchpad.net/bugs/1590799 Reviewed-by: NeilBrown <neilb@suse.com> Signed-off-by: Rafael David Tinoco <rafael.tinoco@canonical.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd/exportfs: implement the -s/--state-directory-path optionScott Mayhew2017-02-1511-50/+188
| | | | | | Reviewed-by: NeilBrown <neilb@suse.com> Signed-off-by: Scott Mayhew <smayhew@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libnsm.a: refactor nsm_setup_pathnames() and nsm_make_pathname()Scott Mayhew2017-02-155-43/+119
| | | | | | | | | | Move the logic in nsm_setup_pathnames() and nsm_make_pathname() to similar generic functions in libmisc.a so that the exportfs and rpc.mountd programs can make use of them later. Reviewed-by: NeilBrown <neilb@suse.com> Signed-off-by: Scott Mayhew <smayhew@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount: fix mount fail that caused by uninitialized structJianhong Yin2017-02-023-11/+24
| | | | | | | | | | | | | From: "Jianhong.Yin" <yin-jianhong@163.com> recent changes of utils/mount cause a regression mount fail: https://bugzilla.redhat.com/show_bug.cgi?id=1415024 can not reproduce it on x86_64(gcc on x86_64 might do struct initialize by default, I'm not sure). but it can be reproduced always on platform ppc64le aarch64. Signed-off-by: Jianhong Yin <yin-jianhong@163.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Release: 2.1.1Steve Dickson2017-01-121-1/+1
| | | | Signed-off-by: Steve Dickson <steved@redhat.com>
* exportfs: support "security_label" export optionJ. Bruce Fields2017-01-124-1/+16
| | | | | | | | On recent kernels only exports with NFSEXP_SECURITY_LABEL set will export security labels. Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfsstats: fix some exit codes.NeilBrown2017-01-111-3/+3
| | | | | | | | | | | "nfsstat -m" always exits with "1" (unless there is an error opening /proc/mounts). It should exist "0". Also, a few usage errors cause an exit of "255" when it should probably be "1". Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Renamed nfs.config to nfs.confSteve Dickson2017-01-041-0/+0
| | | | Signed-off-by: Steve Dickson <steved@redhat.com>
* exportfs: Make sure pass all valid export flags to nfsdKinglong Mee2017-01-041-5/+7
| | | | | | | | | test_export pass a export flags only marks NFSEXP_FSID, nfsd may want other flags for export checking. This patch make sure exportfs pass all other flags to nfsd. Signed-off-by: Kinglong Mee <kinglongmee@gmail.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs-server-generator: avoid using syslogNeilBrown2017-01-041-0/+3
| | | | | | | | | | | | nfs-server-generator is run very early when a lot of services are not yet started, so it mustn't depend on them. It already avoids using DNS, but it should avoid syslog too. If it tries to log error to syslog, it can deadlock. So just let messages go to stderr. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: delay reading etab until first request arrives.NeilBrown2017-01-041-2/+0
| | | | | | | | | | | | | | | Reading etab may require hostname lookup, so it is not reliable until the network is active. But we want mountd to start before that so that it is ready when the very first NFS request arrives. So delay reading etab until that request arrives, by which time the network must be online so hopefully hostname look will be reliable. An alternate would be to delay starting mountd and nfsd until the network is on-line, but that will often be an unnecessary delay. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfsd: Do not permit manipulation of NFSv4.0, e.g. "-N 4.0"NeilBrown2017-01-042-4/+4
| | | | | | | | | The code maps this into "-4.32", which the kernel rejects. The kernel also rejects "-4.0" (when written to the 'versions' file). So require the minor number to be at least NFS4_MINMINOR, which is '1'. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfsd: fix setting of minor version from config fileNeilBrown2017-01-042-5/+17
| | | | | | | | | | | | | | Several problem here: - code didn't actually work, as it cleared a bit from minorversset when it should have cleared from minorvers - code did not allow minor versions to be enabled, which is useful when a new minor version is partially implemented in the kernel but not yet enabled by default - code allowed version 4.0 to be enabled/disabled, which the kernel does not support (as for 4.9 at least). Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs.conf: adding a reference file of /etc/nfs.configSteve Dickson2016-12-201-0/+70
| | | | Signed-off-by: Steve Dickson <steved@redhat.com>
* svcgssd: add /etc/nfs.conf supportNeilBrown2016-12-203-0/+40
| | | | | Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* gssd: add /etc/nfs.conf supportNeilBrown2016-12-203-0/+101
| | | | | Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* exportfs: allow debugging to be enabled in nfs.confNeilBrown2016-12-203-0/+19
| | | | | Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* xlog: Add common support for "debug=??" in /etc/nfs.confNeilBrown2016-12-208-1/+29
| | | | | | | | The value is from the list general, call, auth, parse, all. Most daemons recognise this in their dedicated section. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* conffile: fix striping of quotes from values.NeilBrown2016-12-201-8/+8
| | | | | | | There were being stripped from the name instead! Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* conffile: allow embedded spaces in values.NeilBrown2016-12-201-2/+6
| | | | | | | | | | | | | | | | The code that said "Skip trailing spaces" actually skipped everything after the first space. Change to to only skip trailing spaces, or comments that start after a space. This is useful for lists: Foo: a, b, c The list handling already allows for internal spaces. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfsd: add /etc/nfs.conf support for host=NeilBrown2016-12-203-0/+23
| | | | | | | | | A comma separate list of hosts can be given. If any host name is given with "--host" or "-H", then all hosts listed in nfs.conf are ignored. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfsd: add /etc/nfs.conf support for nfsd.port option.NeilBrown2016-12-203-2/+10
| | | | | Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfsd: remove pointless memory allocations.NeilBrown2016-12-201-9/+4
| | | | | | | | There is not need to e.g. strdup(optarg), and the value is constant. It can just be used directly. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfsd: move and improve test on valid portNeilBrown2016-12-201-7/+10
| | | | | | | | | | | | | | | nfssvc_set_sockets() access textual port numbers (by lookup in /etc/services). This uses getaddrinfo which reports errors, except for out-of-range numbers. So change the test on a valid port to only complain if the port given is purely numeric, but is out-of-range. Also move it so that any default value gets tested the same as any argument value. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Add nfs.systemd man pageNeilBrown2016-12-202-2/+169
| | | | | | | | | This discusses some of the behaviors of the various unit files, and how best to work with them to achieve various results. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* systemd: Remove the nfs-config.serviceNeilBrown2016-12-2012-66/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | Now that we have /etc/nfs.conf, a lot of configuration can be read directly. So nfs-config isn't really needed any more. Some distributions allow command-line arguments for various daemons to be set in an environment file (/etc/sysconfig, /etc/defaults). Passing these through /etc/nfs.conf is not possible. Instead, a distro that needs this functionality can create drop-in files which select the required value. As no commands are given default arguments by systemd unit files, the drop-in can just add distro-specific args. For example /lib/systemd/system/nfs-mountd.service.d/local.conf [Service] EnvironmentFile=/etc/sysconfig/nfs ExecStart= ExecStart=/usr/sbin/rpc.mountd $RPCMOUNTDOPTS Note the need for the empty assignment to remove existing definitions first. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* statd: allow --no-notify to be passed via environment variable.NeilBrown2016-12-203-1/+12
| | | | | | | | | | The significant value of allowing this is that it means that for default operation, systemd unit files do not need to pass any options to any programs. The purpose of this will become apparent in the next patch. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* conffile: allow $name expansion of tag values.NeilBrown2016-12-202-2/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the value for a tag starts with '$', then the remainder of the value is treated as an environment variable name. It is looked up in the environment (getenv) and if not found, it is looked for in the [environment] section of the config file. This lookup is formed as access time e.g. by conf_get_str(), not at parse time. The expected usage is that the config file can contain something like [environment] include = /etc/sysconfig/nfs [other-section] tag = $NAME and conf_get_str("other-section","tag") will report the value of "NAME" in the given file. As different distributions used different environment files, and different variable names with-in them, a distro could provide a static config file which maps from names in that environment file to config tags requires by NFS daemons. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* conffile: ignore setting of empty stringNeilBrown2016-12-202-1/+4
| | | | | | | | | | | | A value setting like foo = is now equivalent to not setting "foo" at all. This is likely to be least confusing. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* conffile: strip "quotes" from values in conf file.NeilBrown2016-12-202-9/+18
| | | | | | | | | When "include = " is used to read and "environment" file such as /etc/sysconfig/nfs, there might be quotes around values. Stripe those off, just like a 'shell' reading the file would. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* conffile: add support for include files.NeilBrown2016-12-202-2/+19
| | | | | | | | | | | | | | | | | | A tag include = filename will be replaced by the content of the file. This must appear after a section heading, and any assignments not in their own section will be included in the section that this directive is in. e.g [environment] include = /etc/sysconfig/nfs Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* conffile: split loading of file into a separate function.NeilBrown2016-12-201-21/+26
| | | | | | | This will make support of include files easier. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* conffile: free image of config file after parsingNeilBrown2016-12-201-11/+6
| | | | | | | | | | | | | | | | | | | | | conffile allocates memory and reads in the config file. It then parses the file, using strdup() to take a copy of any string that it uses, so after conf_parse() there are no references in to the allocated file image. conffile does not free this image. It keeps a pointer, but never uses it in an interesing way, and never frees it. This is a little clumsy and interfers with a future patch which will support the inclusion of subordinate config files. So free 'new_conf_addr' when finished with it, and discard the 'conf_addr' variable that stored it. This has an insignificant performance consequence in that we node always free everything in the hash table, even when we know it must be empty. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Add /etc/nfs.conf support for sm-notifyNeilBrown2016-12-203-0/+48
| | | | | Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Add /etc/nfs.conf support for statdNeilBrown2016-12-203-2/+78
| | | | | | | Some options appear in the [lockd] section. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Add /etc/nfs.conf support for mountd.NeilBrown2016-12-203-1/+91
| | | | | | | | Some values are taken from the [nfsd] section to ensure consistency. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Add /etc/nfs.conf support to rpc.nfsdNeilBrown2016-12-203-3/+106
| | | | | | | | I haven't added -H support, but everything else should be able to be set through /etc/nfs.conf. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* conffile: add bool supportNeilBrown2016-12-203-0/+50
| | | | | | | | conf_get_bool() interprets various strings as 'true' or 'false'. If no suitable value is found, the default is returned. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Add man-page describing /etc/nfs.confNeilBrown2016-12-202-1/+70
| | | | | | | | | It may seem a little odd placing this in the "systemd" directory, but it is a conveninent place, and /etc/nfs.conf was added in part to help with systemd integration. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* start-statd: script using incompatible file descriptorDaniel Pocock2016-12-201-2/+2
| | | | | | | | | | POSIX.1-2008 only specifies that file descriptor numbers from 0 to 9, inclusive, are supported. The number 200 works in the bash shell, but not in dash. This patch changes the file descriptor number from 200 to 9. Reported in Debian bug #848277 Signed-off-by: Daniel Pocock <daniel@pocock.pro> Signed-off-by: Steve Dickson <steved@redhat.com>
* exportfs: fix path comparison in unexportfs_parsed()Scott Mayhew2016-12-171-0/+2
| | | | | | | | | Passing a path like /export1 to unexportfs_parsed() matches not only /export1, but /export11, /export100, /export1forthemoney, etc. which can result in some nasty surprises when unexporting individual exports. Signed-off-by: Scott Mayhew <smayhew@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Fixed typo in usage stringSteve Dickson2016-12-071-1/+1
| | | | Signed-off-by: Steve Dickson <steved@redhat.com>
* Remove error messages on xstrdup failure.NeilBrown2016-12-064-43/+10
| | | | | | | | | | | | xstrdup() prints a messages and exits, except in statd where is prints a message and fails. So there is no point printing an extra message when xstrdup() fails, and except in statd, no point calling exit() as well. So remove some pointless code. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Remove all use of the nfsctl system call.NeilBrown2016-12-0621-961/+29
| | | | | | | | | | | | | | | | | | | | This systemcall was deprecated early in the 2.6 series as it was replaced by an in-kernel cache which was refilled using an upcall. All communication to kernel is now through the nfsd filesystem. The nfsctl systemcall itself was removed in 3.1. It is unlikely to have been used for over a decade. To remove all uses for the nfsctl systemcall, and call code that only runs when "new_cache" is false. We now assume "new_cache" is always true. This allows the removal of several files as well as assorted functions. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount: take history into account when assessing if an error is permanent.NeilBrown2016-12-061-5/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When attempting an NFSv3 mount request, it is possible to catch the server at an "awkward" moment while it is still starting up. In these cases it is possible to get an error that would otherwise indiciate a permanent error, but which should be considered temporary during the start-up window. In particular: ECONNREFUSED will be returned between the time the network interface is configured, and the time that rpcbind starts EOPNOTSUPP (representing RPC_PROGNOTREGISTERED) will be returned between the time that rpcbind starts and the time when nfsd registers, and ESTALE will be returned between the time nfsd starts and when filesystems are exported (this windown can be removed with correct configuration). So these errors only deserve a relatively small timeout. ECONNREFUSED needs a longer timeout than the others as the start-up window is longer. As we have long treated this as a temporary error, with no complaints, we will keep doing so for now. So change nfs_is_permanent_error() to record the previous error and the number of times the same error has been seen. If ESTALE or EOPNOTSUPP is seen 3 times (over 3 seconds or more) or ECONNREFUSED is seen 5 times (15 seconds), report a permanent error, others assume it could be temporary. A result of this is that if you try a UDP mount from a server which doesn't support UDP, you get an error without a few seconds, rather than a 2-minute timeout. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>