From nobody Mon Jun 12 01:24:32 2023 X-Original-To: dev-commits-src-all@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 4QfYrK1qdjz4cjQP; Mon, 12 Jun 2023 01:24:33 +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 4QfYrK0qQgz4LP5; Mon, 12 Jun 2023 01:24:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686533073; 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=NrTPowjegZR2012uZBfVkrL5YxnnQ2PWHkrs73vjm4E=; b=N7RDweaZYZjgWFjKq85pRz9yBZ/zILKhlAZ8JziDHKsWg/rneSBQbT9zRp+jgyeNzZDerh oAkUyNQ2oQUSbxsuQKDXKcfFZaLVfO8Xk4btrNtrkmYob/rOl8UMp2DhPB37aB/Ra64cz5 cRDehEthcAJWpcoSO4p2rdGJss1EmG/+SAaT8NwSRZ7148Yp6ZabywV/ciQCkn0SfWjbw5 dCgLmR/pNZXIMA8G4p4ybzFgUF2osTISBcdGY/JvxR5pE4azIBu/bFuYJKGnBPF8Tr0BZr q/g69wdyx/15d00qQpYFp4n+JZsoAKowAjU0R9+n2X/QColyp+uK7XzNldRNjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686533073; 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=NrTPowjegZR2012uZBfVkrL5YxnnQ2PWHkrs73vjm4E=; b=npd51qqPSj0cO1qc1R6C9xqhzmGCMKxYlesEc/6VNcbpNX7/MdlCD9CSPdKBJ4cLM2Klg2 0aGwHvJqEDHt6KIHThBRBRpXdK9blL+46vJN28ItNc9zFHf6pvUo5MmaR4uY+3IbLwNykA s87CroXGL+A5JKvK3cDbPw9WsaThdr1oxn4lM5p8nbA5W6QfQMTV3BRYQ849zaqhTY+2GK KOkkB8e8efMw/wwhQOmEUM31p/GV3ljidTyw+g7QsofHa1f+wY0AQrwDQi7npjQztS0BNg XvtxWMSlJ1ab+xjyW/ecgjNuvqljWQNxbM+vBnCTX3A2fL53/KvmA1HEh1dQyA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686533073; a=rsa-sha256; cv=none; b=W3RlFhKGwRSejLjjRj1MKO7B4Q0+FO/W9C0sWabblxVW7Gu2A+FTwgZx7z1Yh/gACk2v8Z czoYBh8H1WMGSSYPEPublmd5MtH5zNV4cTFcv2EIuovmjG/czEXqPryJoHTghqbQ/BJnBD 6GBy8KqdiRQw8S+OV5nPen7XwtJTQ1Smy5sY/KACFJE5h7hF7vEtCCkwI5xsoU742yuRmP vk+S7G1QQ0CEjCsPXM+2t285MHShpqQJX1cF40d6KxHjJJduD27zpm1+I8OfmR7L14yK3H j2rhXKE67Vg6Qd2/ax4802NPnNeEFyawl+4ta2JVHzyjnFdppOnhI0a3grNZ7Q== 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 4QfYrJ737bzLrT; Mon, 12 Jun 2023 01:24:32 +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 35C1OWOq059495; Mon, 12 Jun 2023 01:24:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35C1OW4U059494; Mon, 12 Jun 2023 01:24:32 GMT (envelope-from git) Date: Mon, 12 Jun 2023 01:24:32 GMT Message-Id: <202306120124.35C1OW4U059494@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 4eee1fcdfc77 - stable/13 - nfsuserd: Improve failure message when running in a jail List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 4eee1fcdfc778640b93d3ba897d3206fa04484ee Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=4eee1fcdfc778640b93d3ba897d3206fa04484ee commit 4eee1fcdfc778640b93d3ba897d3206fa04484ee Author: Rick Macklem AuthorDate: 2023-05-29 20:38:07 +0000 Commit: Rick Macklem CommitDate: 2023-06-12 01:23:37 +0000 nfsuserd: Improve failure message when running in a jail If a jail is not correctly configured to run nfsd(8) in the jail, nfsuserd(8) cannot run. This patch improves the failure message for this case. (cherry picked from commit a94018e2003b83c10e8fb814f7a8d47e2513da95) --- usr.sbin/nfsuserd/nfsuserd.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/usr.sbin/nfsuserd/nfsuserd.c b/usr.sbin/nfsuserd/nfsuserd.c index 1e99f806637d..3444b16fea78 100644 --- a/usr.sbin/nfsuserd/nfsuserd.c +++ b/usr.sbin/nfsuserd/nfsuserd.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -127,7 +128,8 @@ main(int argc, char *argv[]) #ifdef INET6 struct sockaddr_in6 *sin6; #endif - int s; + int jailed, s; + size_t jailed_size; if (modfind("nfscommon") < 0) { /* Not present in kernel, try loading it */ @@ -326,10 +328,19 @@ main(int argc, char *argv[]) #else if (nfssvc(NFSSVC_NFSUSERDPORT | NFSSVC_NEWSTRUCT, &nargs) < 0) { if (errno == EPERM) { - fprintf(stderr, - "Can't start nfsuserd when already running"); - fprintf(stderr, - " If not running, use the -force option.\n"); + jailed = 0; + jailed_size = sizeof(jailed); + sysctlbyname("security.jail.jailed", &jailed, + &jailed_size, NULL, 0); + if (jailed != 0) { + fprintf(stderr, "Cannot start nfsuserd. " + "allow.nfsd might not be configured\n"); + } else { + fprintf(stderr, "Cannot start nfsuserd " + "when already running."); + fprintf(stderr, " If not running, " + "use the -force option.\n"); + } } else { fprintf(stderr, "Can't do nfssvc() to add port\n"); }