Skip to contentSkip to conversation

exportfs: make root unexportable

PATCH In review Roberto Bergantinos Corpas 3 participants 3 messages Mar 29, 2021 – Apr 7, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 exportfs: make root unexportable

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

---
 utils/exportfs/exportfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/exportfs/exportfs.c +1 -1
index 9fcae0b3..9b6f4f5a 100644
@@ -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) {
Signature · 1 line
2.21.0
#1 lore raw

Hi SteveD,

This is a real problem introduced by my previous update. Sorry for it.

How about also adding this tag:

Fixes a9a7728d (exportfs: Deal with path's trailing "/" in unexportfs_parsed())

Thanks,
Yongcheng

Quoted 25 lines · Roberto Bergantinos Corpas

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

---
 utils/exportfs/exportfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/exportfs/exportfs.c +1 -1
index 9fcae0b3..9b6f4f5a 100644
@@ -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) {
Signature · 1 line
2.21.0
#2 lore raw
In reply to Roberto Bergantinos Corpas

Hello,

Quoted 14 lines · Roberto Bergantinos Corpas

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

---
 utils/exportfs/exportfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/exportfs/exportfs.c +0 -0
index 9fcae0b3..9b6f4f5a 100644

utils/exportfs/exportfs.c unexportfs_parsed(char *hname, char *path, int verbose) · line 376

Quoted 6 lines
utils/exportfs/exportfs.c +1 -1
@@ -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--;

I decided to use Ondrej's version sine the nlen is tested first before the index into path was made.

steved.

Quoted 3 lines
utils/exportfs/exportfs.c +0 -0
 	for (exp = exportlist[htype].p_head; exp; exp = exp->m_next) {