Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3495962pxf; Mon, 29 Mar 2021 04:01:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxURSMryNzCBjtCgkHl2kucJV4gOFhitrgZ82wzIEvtx90JxVFsoUo50VM3LNKHhzuAVAF X-Received: by 2002:aa7:c94b:: with SMTP id h11mr2472311edt.160.1617015703273; Mon, 29 Mar 2021 04:01:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617015703; cv=none; d=google.com; s=arc-20160816; b=yX7iSI91clr3EzzsAinfLGS/sPB7atu0/PKBKQTpyaiiMmb388q9sCAPPXV3g6m5n8 Hviym7KLEZL3CXNTSXbyD3KXb4G/g4SDDM0HFbsz4ELFklRpvR+lUXjkZ/ibdZ30PFdE Y+dlLCCSq+44P2FDDLdh1LZScME9dMkLmStVSQbaViNOCosGpjE72jQRG6rHI3gu/RzS HDobLIwQasPSlojtKXQ/xxbKncc+fIDC1IqXQtzQmwzTYacJim9KCAn7OGd9n4I7j8zI K9Wsa5ZXncXp2PWWHhsspdeAsF2FCSwi007dPT+ZRQQuTAQG4nVFxiOmnTRLQfcD659/ rvGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=lyuNER0tnmAWlz8o0UjdsaE81EyYtAWD8vYhYdwCO4U=; b=eafVi+gU4rmjaRyqpaadif0Kxt070iZrYewuwRoN1jl1SOXjnme0vWqL3de5K4Avbz /dlP6VxCbFRxVwpvwoXyrp6oNifWrLIOfRYx2IScj9MLDOJ1Hq8NPEdaUXTBPPsCSgWV gYHCaAv0R2l0LTmNp5i9k/pvYOYYp4SHCYTWT70d17ixmYkLtqOC5IAJ4Woy0EFzgRa/ B3cFdqbLxGDlQ4Zbr+5uhjJ0ap8/AWF9bW2+vsfnDfVx9gHUzDfeA4qCBYisqalagiNG 1eJf2NPB4t2CoKOszrHHUSND7zBxHSxoPcIx72e28bB441V4FdGD/3cVjPaPMMPQYQyU Z/4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=blQI2w+4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ko14si12257650ejc.419.2021.03.29.04.01.10; Mon, 29 Mar 2021 04:01:43 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=blQI2w+4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232955AbhC2Ky6 (ORCPT + 99 others); Mon, 29 Mar 2021 06:54:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33915 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232732AbhC2Kyl (ORCPT ); Mon, 29 Mar 2021 06:54:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617015281; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=lyuNER0tnmAWlz8o0UjdsaE81EyYtAWD8vYhYdwCO4U=; b=blQI2w+4gflA5xMfgCxMHKkuqmpGlno2+Fg8ZWnK5CPulE7UF8JvJGKwExKm3MEDyszHoq Ok80yhM4kNUBgPrvsAGBm7HXbMYrIABTSU0MlVZy1Wm0POqi4ehzouG6RZOfdensre5nx2 Nu0QlApYKI5E75ocx7/Sylk7TJApEuM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-262-gCpNfFXbP6C81hy0Rmv0iQ-1; Mon, 29 Mar 2021 06:54:39 -0400 X-MC-Unique: gCpNfFXbP6C81hy0Rmv0iQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D6A47501F8 for ; Mon, 29 Mar 2021 10:54:38 +0000 (UTC) Received: from idlethread.redhat.com (ovpn-113-30.ams2.redhat.com [10.36.113.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id E35A619706; Mon, 29 Mar 2021 10:54:37 +0000 (UTC) From: Roberto Bergantinos Corpas To: steved@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH] exportfs: make root unexportable Date: Mon, 29 Mar 2021 12:54:35 +0200 Message-Id: <20210329105435.17431-1-rbergant@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If root of the filesystem is exported, it cannot be explicitly unexported, since unexportfs_parsed, in order to deal with trailing '/', will leave nlen at 0 for root exported case Signed-off-by: Roberto Bergantinos Corpas --- utils/exportfs/exportfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c index 9fcae0b3..9b6f4f5a 100644 --- a/utils/exportfs/exportfs.c +++ b/utils/exportfs/exportfs.c @@ -372,7 +372,7 @@ unexportfs_parsed(char *hname, char *path, int verbose) * so need to deal with it. */ size_t nlen = strlen(path); - while (path[nlen - 1] == '/') + while ((path[nlen - 1] == '/') && (nlen > 1)) nlen--; for (exp = exportlist[htype].p_head; exp; exp = exp->m_next) { -- 2.21.0