From nobody Wed Feb 22 22:10:23 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PMVhb4ZSBz3sH2h; Wed, 22 Feb 2023 22:10:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PMVhb45cnz3kt6; Wed, 22 Feb 2023 22:10:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677103823; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eOmFlQ7peqyNYfJtpXY2gvgB4j3X9aqJFB1bZ0t+m80=; b=LjfFSM/IbFv6QZqQtE0d0Yi/WSYDq2GZxiCGOo4xZaNERN0HClQ/rGALjFIh0QvNMkuxSz F81K/Ey+wm7NEhyXQGliMG/Ev+odXyvOmChlB58UHiHMHpC0OeoGlupHLZudfMUbWr8b9T qlD6njwpteO7N7m/Db1YDH+rR++4gTukI/1D0Go1uJy/TfMwlODkFPX9ehCQ5mydQR6You kNdq8I9nzozt6LWyX0VPU4NLf+swEVnKZ06NUqbiAsnJ61LhaemF3GXiMkO6ve59aaEo7/ eEX2ysm/kuK/L5Eiqhy4Djm5XAMCjLbu1PPRUf+PpoxX05g72A46Faplh9kyIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677103823; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eOmFlQ7peqyNYfJtpXY2gvgB4j3X9aqJFB1bZ0t+m80=; b=Rj/he8I5EzWAU6zZcye+K4o3iquCFnJks2Fg/rKk0o052W/89Se4a6B5wOYirx9AXeBMnl xAALi07nA96AneMLvEUxabhdMNxwscCUzkcMUyEZ31WWvxA61ScwDYA9uxF0P1gtrZ/l6/ AKk+jZW8jrE3idXlLfeoAcy8WxkHw6kIJWmdL5pbIfIGNpipyI1p7fltKYDdQanV4l7z8P 4WsOTZOTqlKQpoBpXsSK5OdOx4PhChw607NImH8moUJvZPtpetvbpeZdHOAgBHwMWg7FpE 4iAjjwyEdg1waFvIpSISlNSCqxNhXRklaUPBRFEJ6MU5dP58WDEjkmvVJME/9Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1677103823; a=rsa-sha256; cv=none; b=Pld1YEIZRuFXwTAPK98y3a1E9hv6On5/cPuHmmbbilkH0pMIz6G2imkNUfla9UYMFeAOfo rcH4LL2FncUA7XyvkjSLr+ptQSmjwD0UbuHeVOiLExIweQlA7Lkxx9DTdqcHX/8sccOMtg gBQLo8fZHsQUnlp9Si6SdyrldT6fJgEoR5py6exfZhEeFEInntE4nVEEjAAb+dDYUppCbs lEZ2vdI541JzWqGZFfw2oeiMGcgKKt2U+pKgBoKLClGEm+2N+uvuNOhH9cKgT04dSXFgZq BxU2oFJ+d8bhdkYTfE9j+Nv7bUekVwvMQKsk0zQN2KvSwi5edegGf8bqpH0ueA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PMVhb32QwzJ2V; Wed, 22 Feb 2023 22:10:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 31MMANCW081920; Wed, 22 Feb 2023 22:10:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31MMANLQ081919; Wed, 22 Feb 2023 22:10:23 GMT (envelope-from git) Date: Wed, 22 Feb 2023 22:10:23 GMT Message-Id: <202302222210.31MMANLQ081919@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: fe5c211ba873 - main - nfsd.c: Log a more meaningful failure message List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fe5c211ba87315b098769a7e6d50b41f00f6fed4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=fe5c211ba87315b098769a7e6d50b41f00f6fed4 commit fe5c211ba87315b098769a7e6d50b41f00f6fed4 Author: Rick Macklem AuthorDate: 2023-02-22 22:09:15 +0000 Commit: Rick Macklem CommitDate: 2023-02-22 22:09:15 +0000 nfsd.c: Log a more meaningful failure message For the cases where the nfsd(8) daemon is already running or has failed to start within a prison due to an incorrect prison configuration, the failure message logged is: Can't read stable storage file: operation not permitted This patch replaces the above with more meaningful messages. It depends on commit 10dff9da9748 to differentiate between the above two cases, however even without this commit, the messages should be an improvement. MFC after: 3 months --- usr.sbin/nfsd/nfsd.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/usr.sbin/nfsd/nfsd.c b/usr.sbin/nfsd/nfsd.c index 0222d23f2312..3a7f58c7b4e5 100644 --- a/usr.sbin/nfsd/nfsd.c +++ b/usr.sbin/nfsd/nfsd.c @@ -170,8 +170,8 @@ main(int argc, char **argv) int udpflag, ecode, error, s; int bindhostc, bindanyflag, rpcbreg, rpcbregcnt; int nfssvc_addsock; - int longindex = 0; - size_t nfs_minvers_size; + int jailed, longindex = 0; + size_t jailed_size, nfs_minvers_size; const char *lopt; char **bindhost = NULL; pid_t pid; @@ -465,7 +465,21 @@ main(int argc, char **argv) /* This system call will fail for old kernels, but that's ok. */ nfssvc(NFSSVC_BACKUPSTABLE, NULL); if (nfssvc(NFSSVC_STABLERESTART, (caddr_t)&stablefd) < 0) { - syslog(LOG_ERR, "Can't read stable storage file: %m\n"); + if (errno == EPERM) { + jailed = 0; + jailed_size = sizeof(jailed); + sysctlbyname("security.jail.jailed", &jailed, + &jailed_size, NULL, 0); + if (jailed != 0) + syslog(LOG_ERR, "nfssvc stablerestart failed: " + "allow.nfsd might not be configured"); + else + syslog(LOG_ERR, "nfssvc stablerestart failed"); + } else if (errno == ENXIO) + syslog(LOG_ERR, "nfssvc stablerestart failed: is nfsd " + "already running?"); + else + syslog(LOG_ERR, "Can't read stable storage file: %m\n"); exit(1); } nfssvc_addsock = NFSSVC_NFSDADDSOCK;