Skip to contentSkip to conversation

nfs4_setfacl: Skip comment field while reading ACE(s).

PATCH Applied Kenneth D'souza 2 participants 3 messages Mar 26, 2019 – Apr 10, 2019

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

PATCH 1/1 nfs4_setfacl: Skip comment field while reading ACE(s).

With commit 6630629bb661a7f48fb9856f7fd9616ce1499efa an additional field for filename was added due to which nfs4_setfacl failed to handle comments while reading ACE(s) from nfs4_getfacl output.
This patch resolves the issue by skipping comment header.

With fix:

 $ nfs4_setfacl --test -s "$(nfs4_getfacl  file1)" file2
 Skipping comment # file: file1
 ## Test mode only - the resulting ACL for "/test/file2":
 A::OWNER@:rwatTcCy
 A:g:GROUP@:rtcy
 A::EVERYONE@:rtcy

Without fix:

 $ nfs4_setfacl --test -s "$(nfs4_getfacl  file1)" file2
 Failed while inserting ACE(s).
---
 libnfs4acl/nfs4_insert_string_aces.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
libnfs4acl/nfs4_insert_string_aces.c +10 -6
index 5a482d5..50b7bbf 100644
@@ -45,21 +45,25 @@ int nfs4_insert_string_aces(struct nfs4_acl *acl, const char *acl_spec, unsigned
 	if ((s = sp = strdup(acl_spec)) == NULL)
 		goto out_failed;
 
+
 	while ((ssp = strsep(&sp, ",\t\n\r")) != NULL) {
 		if (!strlen(ssp))
 			continue;
 
-		if ((ace = nfs4_ace_from_string(ssp, acl->is_directory)) == NULL)
-			goto out_failed;
+		if(*ssp == '#')
+			printf("Skipping comment %s\n", ssp);
+		else {
+			if ((ace = nfs4_ace_from_string(ssp, acl->is_directory)) == NULL)
+				goto out_failed;
 
-		if (nfs4_insert_ace_at(acl, ace, index++)) {
-			free(ace);
-			goto out_failed;
+			if (nfs4_insert_ace_at(acl, ace, index++)) {
+				free(ace);
+				goto out_failed;
+			}
 		}
 	}
 	if (acl->naces == 0)
 		goto out_failed;
-
 out:
 	if (s)
 		free(s);
Signature · 1 line
2.20.1
#1 lore raw

Applied, with some fixes:

Quoted 9 lines · Kenneth D'souza

With commit 6630629bb661a7f48fb9856f7fd9616ce1499efa an additional field for filename was added due to which nfs4_setfacl failed to handle comments while reading ACE(s) from nfs4_getfacl output.
This patch resolves the issue by skipping comment header.

With fix:

 $ nfs4_setfacl --test -s "$(nfs4_getfacl  file1)" file2
 Skipping comment # file: file1

Just skip it silently, there's not need to print anything.

Quoted 22 lines

## Test mode only - the resulting ACL for "/test/file2":
A::OWNER@:rwatTcCy
A:g:GROUP@:rtcy
A::EVERYONE@:rtcy

Without fix:

 $ nfs4_setfacl --test -s "$(nfs4_getfacl  file1)" file2
 Failed while inserting ACE(s).
---
 libnfs4acl/nfs4_insert_string_aces.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
libnfs4acl/nfs4_insert_string_aces.c +0 -0
index 5a482d5..50b7bbf 100644
@@ -45,21 +45,25 @@ int nfs4_insert_string_aces(struct nfs4_acl *acl, const char *acl_spec, unsigned
 	if ((s = sp = strdup(acl_spec)) == NULL)
 		goto out_failed;

libnfs4acl/nfs4_insert_string_aces.c int nfs4_insert_string_aces(struct nfs4_acl *acl, const char *acl_spec, unsigned · line 54

Quoted 10 lines
libnfs4acl/nfs4_insert_string_aces.c +3 -2
 
+
 	while ((ssp = strsep(&sp, ",\t\n\r")) != NULL) {
 		if (!strlen(ssp))
 			continue;
 
-		if ((ace = nfs4_ace_from_string(ssp, acl->is_directory)) == NULL)
-			goto out_failed;
+		if(*ssp == '#')
+			printf("Skipping comment %s\n", ssp);

So let's just do a "continue" here, as above. Also notice we usually leave a space after "if".

--b.

Quoted 21 lines
libnfs4acl/nfs4_insert_string_aces.c +7 -4
+		else {
+			if ((ace = nfs4_ace_from_string(ssp, acl->is_directory)) == NULL)
+				goto out_failed;
 
-		if (nfs4_insert_ace_at(acl, ace, index++)) {
-			free(ace);
-			goto out_failed;
+			if (nfs4_insert_ace_at(acl, ace, index++)) {
+				free(ace);
+				goto out_failed;
+			}
 		}
 	}
 	if (acl->naces == 0)
 		goto out_failed;
-
 out:
 	if (s)
 		free(s);
Signature · 1 line
2.20.1
#2 lore raw

Thanks for taking care of this.

Quoted 75 lines · J. Bruce Fields

Applied, with some fixes:

Quoted 9 lines · Kenneth D'souza

With commit 6630629bb661a7f48fb9856f7fd9616ce1499efa an additional field for filename was added due to which nfs4_setfacl failed to handle comments while reading ACE(s) from nfs4_getfacl output.
This patch resolves the issue by skipping comment header.

With fix:

 $ nfs4_setfacl --test -s "$(nfs4_getfacl  file1)" file2
 Skipping comment # file: file1

Just skip it silently, there's not need to print anything.

Quoted 22 lines

## Test mode only - the resulting ACL for "/test/file2":
A::OWNER@:rwatTcCy
A:g:GROUP@:rtcy
A::EVERYONE@:rtcy

Without fix:

 $ nfs4_setfacl --test -s "$(nfs4_getfacl  file1)" file2
 Failed while inserting ACE(s).
---
 libnfs4acl/nfs4_insert_string_aces.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
libnfs4acl/nfs4_insert_string_aces.c +0 -0
index 5a482d5..50b7bbf 100644
@@ -45,21 +45,25 @@ int nfs4_insert_string_aces(struct nfs4_acl *acl, const char *acl_spec, unsigned
      if ((s = sp = strdup(acl_spec)) == NULL)
              goto out_failed;

libnfs4acl/nfs4_insert_string_aces.c int nfs4_insert_string_aces(struct nfs4_acl *acl, const char *acl_spec, unsigned · line 54

Quoted 10 lines
libnfs4acl/nfs4_insert_string_aces.c +3 -2
 
+
      while ((ssp = strsep(&sp, ",\t\n\r")) != NULL) {
              if (!strlen(ssp))
                      continue;
 
-             if ((ace = nfs4_ace_from_string(ssp, acl->is_directory)) == NULL)
-                     goto out_failed;
+             if(*ssp == '#')
+                     printf("Skipping comment %s\n", ssp);

So let's just do a "continue" here, as above. Also notice we usually leave a space after "if".

--b.

Quoted 21 lines
libnfs4acl/nfs4_insert_string_aces.c +7 -5
+             else {
+                     if ((ace = nfs4_ace_from_string(ssp, acl->is_directory)) == NULL)
+                             goto out_failed;
 
-             if (nfs4_insert_ace_at(acl, ace, index++)) {
-                     free(ace);
-                     goto out_failed;
+                     if (nfs4_insert_ace_at(acl, ace, index++)) {
+                             free(ace);
+                             goto out_failed;
+                     }
              }
      }
      if (acl->naces == 0)
              goto out_failed;
-
 out:
      if (s)
              free(s);
--

2.20.1