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