Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1975049

Summary: [RHEL-9.0] exportfs: unable to unexport root
Product: Red Hat Enterprise Linux 9 Reporter: Yongcheng Yang <yoyang>
Component: nfs-utilsAssignee: Steve Dickson <steved>
Status: CLOSED CURRENTRELEASE QA Contact: Yongcheng Yang <yoyang>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 9.0CC: ajmitchell, dwysocha, rbergant, ssahsrab, steved, xzhou, yieli, yoyang
Target Milestone: betaKeywords: Patch, Reproducer, Triaged
Target Release: ---   
Hardware: All   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1944119 Environment:
Last Closed: 2021-06-24 19:17:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Yongcheng Yang 2021-06-23 02:56:35 UTC
Looks like rhel9 nfs-utils doesn't have this patch yet:

[root@rhel-9-latest ~]# exportfs -ua && exportfs localhost:/
[root@rhel-9-latest ~]# exportfs -s
/  localhost(sync,wdelay,hide,no_subtree_check,sec=sys,ro,secure,root_squash,no_all_squash)
[root@rhel-9-latest ~]# exportfs -u localhost:/
exportfs: Could not find 'localhost:/' to unexport.   <<<<<<<<<<<<
[root@rhel-9-latest ~]# exportfs -s
/  localhost(sync,wdelay,hide,no_subtree_check,sec=sys,ro,secure,root_squash,no_all_squash)
[root@rhel-9-latest ~]# 
[root@rhel-9-latest ~]# rpm -q nfs-utils
nfs-utils-2.5.2-1.rc4.el9.x86_64
[root@rhel-9-latest ~]# 


+++ This bug was initially created as a clone of Bug #1944119 +++

Description of problem:

If root is exported, we're unable to unexport it individually :

[root@rhel8 ~]# exportfs -s
/opt/mydir  172.23.0.0/24(sync,wdelay,hide,no_subtree_check,sec=sys,ro,secure,root_squash,no_all_squash)
/opt/mydir/subdir  172.23.0.0/24(sync,wdelay,hide,no_subtree_check,sec=sys,ro,secure,root_squash,no_all_squash)
/opt/mydir  *(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)
/opt/mydir/subdir  *(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)

[root@rhel8 ~]# exportfs -i -o rw,sync 172.23.1.247:/ 

[root@rhel8 ~]# exportfs -s
/  172.23.1.247(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash)
/opt/mydir/subdir  172.23.0.0/24(sync,wdelay,hide,no_subtree_check,sec=sys,ro,secure,root_squash,no_all_squash)
/opt/mydir  172.23.0.0/24(sync,wdelay,hide,no_subtree_check,sec=sys,ro,secure,root_squash,no_all_squash)
/opt/mydir/subdir  *(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)
/opt/mydir  *(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)

[root@rhel8 ~]# exportfs -v -u 172.23.1.247:/
exportfs: Could not find '172.23.1.247:/' to unexport.

- exportfs -au works
- exporting a bind mount of root & unexport it works

I think problem is here :

355 static void
356 unexportfs_parsed(char *hname, char *path, int verbose)
357 {
...
369         /*
370          * It's possible the specified path ends with a '/'. But
371          * the entry from exportlist won't has the trailing '/',
372          * so need to deal with it.
373         */
374         size_t nlen = strlen(path);
375         while (path[nlen - 1] == '/')  <<--- [*]
376                 nlen--;                      
377 
378         for (exp = exportlist[htype].p_head; exp; exp = exp->m_next) {
379                 if (strlen(exp->m_export.e_path) != nlen)
380                         continue;
381                 if (path && strncmp(path, exp->m_export.e_path, nlen))
382                         continue;

while removing the trailing "/" from the path, for root case, we'll leave nlen at 0,
so we will loop through exportlist without finding "/".

quick patch :

diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index 262dd19a..40813fb8 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -383,7 +383,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) {

seems to work :

[root@f-rawhide exportfs]# ./exportfs -i -o rw,sync *:/
[root@f-rawhide exportfs]# ./exportfs -s
/  *(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash)
[root@f-rawhide exportfs]# ./exportfs -v -u *:/
unexporting *:/
[root@f-rawhide exportfs]# ./exportfs -s
[root@f-rawhide exportfs]#



Version-Release number of selected component (if applicable):


How reproducible: 100%


Steps to Reproduce:
1. see above
2.
3.

Actual results: not able to indivually unexport root


Expected results: able to indivually unexport root

Comment 2 Steve Dickson 2021-06-24 19:17:16 UTC
Fixed with bug 1971684