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

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