Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp804713ybn; Tue, 24 Sep 2019 09:45:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/3FKEZ/Lg/g5lnfmaLRdKDdU+lyjPyJd3x3vrppT2W0Ox+cFJ8W6shTAvoN+mDcNEzs5r X-Received: by 2002:a5d:4f11:: with SMTP id c17mr3507181wru.227.1569343555210; Tue, 24 Sep 2019 09:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569343555; cv=none; d=google.com; s=arc-20160816; b=irZn1qE00s/6+XqX2Qro0WJRMkCzgQiyz99QnRP7O2NnJpUpcG4IwXhnsFIjwvwlcS /r6pRMTg5qR8Ns+F5sh2ACBxhvADe9rZ22ySImjDPC8IwdP00xAcoitU6keHoSt8rM0y PS2zod+ciWDrrr7jcb6ATuGi7SagyNNY0V7VftpyTcEhuzN5MKGYQvufu93FLBBfmP5o gvtdHXF5p4q4Se5l2hRGpyWm3bxuzf/23OA9J4CvArsRmLnW568dSgF2QvYPcMA/n0Gs WYqbqbEZPwgn4xZmi6RqnmFdJPl+1zwQKv7ld3vVBVJQG5MyvWjzwhZoD4MW1SnnjJas m1Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:cc:subject:date:to :from; bh=8vOKvWtPGHmgsMicQ0KxyNKTkwxrS/S2/PhUquwwQPA=; b=EL2QCFi/wvcGGg+kqeWZAXB5nE7mR2+3Ua/MnMuR0eveA4BFyeFmYcquhKFfW58Ngw AG2ZR/CsftpSqkNXlYqIhIjI5LN4p9O1Cr+KS/aJOIE5PuJT+CcAHya77Erc7Fv7HDdy i/iac9lIJRdphl++nmZ2CveBYXs+sJUYbNw7dvNt4q9EFm/NthqDNyUK9Zr/7SlMwejp vIHuDb+cyU/GWAmiUuLQcps9dpU5aBrv8MvTA6AuEquWi+yzoQNiDZgkRskkk/+ceXN9 E0fVEC/RXCs7C0QhGqoLqxyq25dqFOSE9MRwbdeya9buBkOVJHJRT8MaDw92NteSseG9 3X8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i56si1516460eda.19.2019.09.24.09.45.22; Tue, 24 Sep 2019 09:45:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406614AbfIWE1e (ORCPT + 99 others); Mon, 23 Sep 2019 00:27:34 -0400 Received: from mx2.suse.de ([195.135.220.15]:47318 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2405826AbfIWE1e (ORCPT ); Mon, 23 Sep 2019 00:27:34 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0241DAFA4; Mon, 23 Sep 2019 04:27:33 +0000 (UTC) From: NeilBrown To: Steve Dickson Date: Mon, 23 Sep 2019 14:26:58 +1000 Subject: [PATCH 1/3] mountd: Initialize logging early. Cc: linux-nfs@vger.kernel.org Message-ID: <156921281804.27519.8558488144520627125.stgit@noble.brown> In-Reply-To: <156921267783.27519.2402857390317412450.stgit@noble.brown> References: <156921267783.27519.2402857390317412450.stgit@noble.brown> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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 --- 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,