diff options
author | chip <chip> | 2001-10-11 20:11:44 +0000 |
---|---|---|
committer | chip <chip> | 2001-10-11 20:11:44 +0000 |
commit | 9743207017ccface520f839fb573ddef22e464ed (patch) | |
tree | cb8ab39dbb1491028b2e09396988900b13dff24b /utils/mountd | |
parent | 47e5725d85dc2fed09c584d5de16afbe1b434887 (diff) | |
download | nfs-utils-9743207017ccface520f839fb573ddef22e464ed.tar.gz nfs-utils-9743207017ccface520f839fb573ddef22e464ed.tar.xz nfs-utils-9743207017ccface520f839fb573ddef22e464ed.zip |
2001-10-11 Chip Salzenberg <chip@pobox.com>
* utils/mountd/mountd.c (main): Close fds > 2 _before_ RPC init.
* debian/changelog: Version 0.3.3-2.
Diffstat (limited to 'utils/mountd')
-rw-r--r-- | utils/mountd/mountd.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c index e93f0ba..73f9f66 100644 --- a/utils/mountd/mountd.c +++ b/utils/mountd/mountd.c @@ -484,6 +484,13 @@ main(int argc, char **argv) /* WARNING: the following works on Linux and SysV, but not BSD! */ sigaction(SIGCHLD, &sa, NULL); + /* Daemons should close all extra filehandles ... *before* RPC init. */ + if (!foreground) { + int fd = sysconf (_SC_OPEN_MAX); + while (--fd > 2) + (void) close(fd); + } + if (nfs_version & 0x1) rpc_init("mountd", MOUNTPROG, MOUNTVERS, mount_dispatch, port); @@ -512,17 +519,11 @@ main(int argc, char **argv) /* Now we remove ourselves from the foreground. Redirect stdin/stdout/stderr first. */ { - int fd, fdmax; - - fd = open("/dev/null", O_RDWR); + int fd = open("/dev/null", O_RDWR); (void) dup2(fd, 0); (void) dup2(fd, 1); (void) dup2(fd, 2); - - fdmax = sysconf (_SC_OPEN_MAX); - for (fd = 3; fd < fdmax; fd++) { - close (fd); - } + if (fd > 2) (void) close(fd); } setsid(); xlog_background(); |