Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp670327pxb; Fri, 14 Jan 2022 13:39:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9VoTLiUIkxR4HpMKzwDrao5P+X+W9HtrFz8k5cNPm/Yhmxzk1j177q5MTsHL1Jqto5CYZ X-Received: by 2002:a05:6a00:84e:b0:4c3:1693:7733 with SMTP id q14-20020a056a00084e00b004c316937733mr1510221pfk.13.1642196346440; Fri, 14 Jan 2022 13:39:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642196346; cv=none; d=google.com; s=arc-20160816; b=U6L5HUKlatMCk+DPy24hTEoCFCo2q/AicwAChylQDKjiMu8vAafoLXJNdLibgi89In QeysCElgEthtLV0deUvuQ+GQ1qJZdcKqdCxWgGPRAtubs66N8Oa/HEpV9bKEJhKcrviK YoUEYpzvgsnrpra9sQ0xWizAOgwf97RxQfQUIj2nCIs7/1sc5lvZKiDnl8Kh9LJ827Ur e+5kkLhJ62ldQ34dy5JRQ/ydR7Af/aWJC9/DN+GSA9eFRpGbrH1xaBzTvF7r61NvRz8H ekOzmDpLdm1EFCXSEBww0ffK6dDqORKjYaQyBpn4FcWT7X2wKuYdH14pEoTnRzEGUlZz o/ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:from:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:date :dkim-signature:dkim-filter; bh=FJcE37Wso4iNYs+zrkcrYh9bPFiGEB3Q7wWPx+X4qQQ=; b=p1/Oe5yoLS9i0bA+bXKbe9v8aSF4woynPJlY4rzRGiBZuzqSwULwWMwSkEY2fSXr3F VVOkWZ48ducd+ZnTifXX2ORLXFej5BXRsWUve1d+Mw/cgQEL2OE7qlbxmDJz+3Gr4+3X MngcmGwgHsGyKzZ8Oq2zgel4gqG9M27DvGLmPT6SDl/0gzKgl6AkjaZvxL32DWyQgXkf QigA5Ttn46OeluQnidsj+LzIo8qgEVAGlsL00jXzw0nxLplMqBX9Ez4rQt2EylA798Hz x/obo4VqgQKL6TsO6G9OosuzHBpa5/PtZA3O9GAYciX5b+LOcAcC+Z/7B8hmt8biPYG9 SqQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=FC+QSdxx; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v8si6066286pjs.11.2022.01.14.13.38.52; Fri, 14 Jan 2022 13:39:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=FC+QSdxx; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230491AbiANPKY (ORCPT + 99 others); Fri, 14 Jan 2022 10:10:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230165AbiANPKX (ORCPT ); Fri, 14 Jan 2022 10:10:23 -0500 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28327C061574 for ; Fri, 14 Jan 2022 07:10:23 -0800 (PST) Received: by fieldses.org (Postfix, from userid 2815) id 10ECA72FB; Fri, 14 Jan 2022 10:10:22 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 10ECA72FB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1642173022; bh=FJcE37Wso4iNYs+zrkcrYh9bPFiGEB3Q7wWPx+X4qQQ=; h=Date:To:Cc:Subject:References:In-Reply-To:From:From; b=FC+QSdxxA14yIVu0frKCmGn4hv+3COfNqA/Pz6oz2/WmjDCmWMPPYmKBVXkQT4UNq y6L3wYLbP4xt14CtOPT2KYRkJgdwYtaEnvEbHHlU2OdCWDmBmR2ak4Tq9tmng2L9gb L0/Q3K4+GjrPHuNrGogogK0XWC1UgaCSObr8W7X4= Date: Fri, 14 Jan 2022 10:10:22 -0500 To: Chris Chilvers Cc: linux-nfs@vger.kernel.org Subject: Re: [bug report] Resolving symlinks ignores rootdir setting Message-ID: <20220114151022.GA17563@fieldses.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) From: bfields@fieldses.org (J. Bruce Fields) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Fri, Jan 14, 2022 at 12:36:23PM +0000, Chris Chilvers wrote: > I was testing using the rootdir setting in nfs.config to allow using export > paths that would normally conflict with local systems directories with NFS v3. > > The idea was to support re-exporting a source NFS server such as NetApp that > might exports arbitrary paths such as /home without overwriting the /home > directory on the NFS server, and even support exporting a root directory similar > to NFS v4. > > While testing I ran into an issue where the NFS server would fail to start. > During start up, the NFS server would log the error: > > $ systemctl status nfs-server.service > systemd[1]: Starting NFS server and services... > exportfs[2307]: exportfs: Failed to stat /srv/nfs/usr/bin: No such > file or directory > systemd[1]: nfs-server.service: Control process exited, code=exited, > status=1/FAILURE > > $ cat nfs.config > [exports] > rootdir=/srv/nfs > > $ cat /etc/exports > / 10.0.0.0/8(rw,sync,wdelay,no_root_squash,no_all_squash,no_subtree_check,sec=sys,secure,fsid=0,nohide) > /assets 10.0.0.0/8(rw,sync,wdelay,no_root_squash,no_all_squash,no_subtree_check,sec=sys,secure,fsid=10,nohide) > /bin 10.0.0.0/8(rw,sync,wdelay,no_root_squash,no_all_squash,no_subtree_check,sec=sys,secure,fsid=30,nohide) > /software 10.0.0.0/8(rw,sync,wdelay,no_root_squash,no_all_squash,no_subtree_check,sec=sys,secure,fsid=40,nohide) > > If I create the directory /srv/nfs/usr/bin then the NFS server will start. > Listing the actual exports shows that a different path was exported compared to > the path from /etc/exports. > > $ exportfs -s > / 10.0.0.0/8(sync,wdelay,nohide,no_subtree_check,fsid=0,sec=sys,rw,secure,no_root_squash,no_all_squ> > /assets 10.0.0.0/8(sync,wdelay,nohide,no_subtree_check,fsid=10,sec=sys,rw,secure,no_root_squash,no_> > /usr/bin 10.0.0.0/8(sync,wdelay,nohide,no_subtree_check,fsid=30,sec=sys,rw,secure,no_root_squash,no> > /software 10.0.0.0/8(sync,wdelay,nohide,no_subtree_check,fsid=40,sec=sys,rw,secure,no_root_squash,n> > > To test this further I create a symlink from /software to /usr/lib. Once again > the server failed to start because it could not find /srv/nfs/usr/lib. I'm probably just reading too quickly, but I'm not seeing how this explains the problems with your original configuration. Is it that /sr/nfs/bin on you system is a symlink? (And what exactly is the content of that symlink?) (Also, for what it's worth, we don't recommend using fsid=0 any more. It should be unnecessary.) --b. > > Reading through the source, I think the issue is in the getexportent function in > support/nfs/exports.c. > > /* resolve symlinks */ > if (realpath(ee.e_path, rpath) != NULL) { > rpath[sizeof (rpath) - 1] = '\0'; > strncpy(ee.e_path, rpath, sizeof (ee.e_path) - 1); > ee.e_path[sizeof (ee.e_path) - 1] = '\0'; > } > > It appears this function does not take into account the rootdir property when > resolving e_path. > > This was tested on Ubuntu 20.04 with the 5.11.8-051108-generic kernel. nfs-utils > version is 2.5.3.