Blame SOURCES/nfs-utils-2.3.3-exportfs-root.patch

8f2508
commit ac266e2edc4f40eef810d52c72657b645e4010db
8f2508
Author: Ondrej Mosnacek <omosnace@redhat.com>
8f2508
Date:   Tue Apr 6 15:57:37 2021 -0400
8f2508
8f2508
    exportfs: fix unexporting of '/'
8f2508
    
8f2508
    The code that has been added to strip trailing slashes from path in
8f2508
    unexportfs_parsed() forgot to account for the case of the root
8f2508
    directory, which is simply '/'. In that case it accesses path[-1] and
8f2508
    reduces the path to an empty string, which then fails to match any
8f2508
    export.
8f2508
    
8f2508
    Fix it by stopping the stripping when the path is just a single
8f2508
    character - it doesn't matter if it's a '/' or not, we want to keep it
8f2508
    either way in that case.
8f2508
    
8f2508
    Reproducer:
8f2508
    
8f2508
        exportfs localhost:/
8f2508
        exportfs -u localhost:/
8f2508
    
8f2508
    Without this patch, the unexport step fails with "exportfs: Could not
8f2508
    find 'localhost:/' to unexport."
8f2508
    
8f2508
    Fixes: a9a7728d8743 ("exportfs: Deal with path's trailing "/" in unexportfs_parsed()")
8f2508
    Link: https://bugzilla.redhat.com/show_bug.cgi?id=1941171
8f2508
    
8f2508
    Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
8f2508
    Signed-off-by: Steve Dickson <steved@redhat.com>
8f2508
8f2508
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
8f2508
index 262dd19a..25d757d8 100644
8f2508
--- a/utils/exportfs/exportfs.c
8f2508
+++ b/utils/exportfs/exportfs.c
8f2508
@@ -383,7 +383,7 @@ unexportfs_parsed(char *hname, char *path, int verbose)
8f2508
 	 * so need to deal with it.
8f2508
 	*/
8f2508
 	size_t nlen = strlen(path);
8f2508
-	while (path[nlen - 1] == '/')
8f2508
+	while ((nlen > 1) && (path[nlen - 1] == '/'))
8f2508
 		nlen--;
8f2508
 
8f2508
 	for (exp = exportlist[htype].p_head; exp; exp = exp->m_next) {