diff mbox series

exportfs: make root unexportable

Message ID 20210329105435.17431-1-rbergant@redhat.com (mailing list archive)
State New
Headers show
Series exportfs: make root unexportable | expand

Commit Message

Roberto Bergantinos Corpas March 29, 2021, 10:54 a.m. UTC
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

Signed-off-by: Roberto Bergantinos Corpas <rbergant@redhat.com>
---
 utils/exportfs/exportfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Yongcheng Yang March 30, 2021, 8:43 a.m. UTC | #1
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

On Mon, Mar 29, 2021 at 12:54:35PM +0200, Roberto Bergantinos Corpas wrote:
> 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
> 
> Signed-off-by: Roberto Bergantinos Corpas <rbergant@redhat.com>
> ---
>  utils/exportfs/exportfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
> index 9fcae0b3..9b6f4f5a 100644
> --- a/utils/exportfs/exportfs.c
> +++ b/utils/exportfs/exportfs.c
> @@ -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) {
> -- 
> 2.21.0
>
Steve Dickson April 7, 2021, 6:30 p.m. UTC | #2
Hello,

On 3/29/21 6:54 AM, Roberto Bergantinos Corpas wrote:
> 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
> 
> Signed-off-by: Roberto Bergantinos Corpas <rbergant@redhat.com>
> ---
>  utils/exportfs/exportfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
> index 9fcae0b3..9b6f4f5a 100644
> --- a/utils/exportfs/exportfs.c
> +++ b/utils/exportfs/exportfs.c
> @@ -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.
>  
>  	for (exp = exportlist[htype].p_head; exp; exp = exp->m_next) {
>
diff mbox series

Patch

diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index 9fcae0b3..9b6f4f5a 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -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) {