[PATCH 1/3] mountd: Initialize logging early.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Reading the config file can generate log messages,
so we should initialize logging before reading the
config file.

If any log message are generated, syslog will leave
a file descriptor open (a socket), so calling
closeall(3) after this can cause problem.
Before this we initialize login we don't know if
Foreground (-F) has been selected, so closeall()
cannot be conditional on that.

closeall() isn't needed - daemon are almost always run
from a management daemon like systemd, and they are given
a clean environment.  It is really best if they just take
what they are given.

So remove the closeall() call.

Signed-off-by: NeilBrown <neilb@xxxxxxx>
---
 utils/mountd/mountd.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c
index 33571ecbd401..5a12d0bcd19e 100644
--- a/utils/mountd/mountd.c
+++ b/utils/mountd/mountd.c
@@ -681,6 +681,9 @@ main(int argc, char **argv)
 	else
 		progname = argv[0];
 
+	/* Initialize logging. */
+	xlog_open(progname);
+
 	conf_init_file(NFS_CONFFILE);
 	xlog_from_conffile("mountd");
 	manage_gids = conf_get_bool("mountd", "manage-gids", manage_gids);
@@ -820,9 +823,7 @@ main(int argc, char **argv)
 			}
 		}
 	}
-	/* Initialize logging. */
 	if (!foreground) xlog_stderr(0);
-	xlog_open(progname);
 
 	sa.sa_handler = SIG_IGN;
 	sa.sa_flags = 0;
@@ -834,10 +835,6 @@ 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)
-		closeall(3);
-
 	unregister_services();
 	if (version2()) {
 		listeners += nfs_svc_create("mountd", MOUNTPROG,





[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux