[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] acl_extended_file(): add basic support for NFSv4
From: |
Ondrej Valousek |
Subject: |
[PATCH] acl_extended_file(): add basic support for NFSv4 |
Date: |
Thu, 3 Nov 2022 09:52:47 +0100 |
Hi Andreas/all
I am wondering if there is a chance to accept the patch below?
I want to make the acl_extended_file() function NFSv4 aware so that we can
(re-)use it in GNULIB's file-has-acl() function.
The reasoning for this is I really want to see the (+) sign long list (ls -l)
for files/directories that have
either Posix or NFSv4 style ACLs on them
So this is 1st step to make this library NFSv4 ACLs aware.
---
libacl/__acl_extended_file.c | 37 ++++++++++++++++++++++++++++++++++--
1 file changed, 35 insertions(+), 2 deletions(-)
diff --git a/libacl/__acl_extended_file.c b/libacl/__acl_extended_file.c
index f10beec..6f9a666 100644
--- a/libacl/__acl_extended_file.c
+++ b/libacl/__acl_extended_file.c
@@ -22,12 +22,44 @@
#include "config.h"
#include <unistd.h>
#include <sys/xattr.h>
+#include <arpa/inet.h>
+#ifndef XATTR_NAME_NFSV4_ACL
+#define XATTR_NAME_NFSV4_ACL "system.nfs4_acl"
+#endif
+
#include "libacl.h"
#include "byteorder.h"
#include "acl_ea.h"
#include "__acl_extended_file.h"
+int __nfs4_acls_exists(const char *name,
+ ssize_t (*fun)(const char *, const char *,
+ void *, size_t))
+{
+ int ret;
+
+ ret = fun (name, XATTR_NAME_NFSV4_ACL, NULL, 0);
+ if (ret < 0 && errno == ENODATA)
+ ret = 0;
+ else if (ret > 0) {
+ char *xattr = malloc(ret);
+ if (!xattr) {
+ ret = -1;
+ } else {
+ ret = fun (name, XATTR_NAME_NFSV4_ACL, xattr, ret);
+ if (ret < 0) ret = -1;
+ else {
+ u_int32_t num_aces =
(u_int32_t)ntohl(*((u_int32_t*)(xattr))); /* Grab the number of aces in the acl
*/
+ ret = num_aces > 3;
+ }
+ free(xattr);
+ }
+ }
+
+ return ret;
+}
+
int
__acl_extended_file(const char *path_p,
ssize_t (*fun)(const char *, const char *,
@@ -37,8 +69,9 @@ __acl_extended_file(const char *path_p,
int retval;
retval = fun(path_p, ACL_EA_ACCESS, NULL, 0);
- if (retval < 0 && errno != ENOATTR && errno != ENODATA)
- return -1;
+ if (retval < 0 && errno != ENOATTR && errno != ENODATA){ /* we might be
on NFS, so try to check NFSv4 ACLs too */
+ return __nfs4_acls_exists(path_p,fun);
+ }
if (retval > base_size)
return 1;
retval = fun(path_p, ACL_EA_DEFAULT, NULL, 0);
--
2.37.3
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] acl_extended_file(): add basic support for NFSv4,
Ondrej Valousek <=