From 411aeb2398fe39e7e1d2bc7fe27ab92be22bca94 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Sat, 24 Oct 2020 10:28:29 -0500 Subject: [PATCH] server-Stored_ACLs: Restore some definitions for FreeBSD. --- ...file-security-attributes-with-extend.patch | 54 ++++++++++++++----- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/patches/server-Stored_ACLs/0007-server-Retrieve-file-security-attributes-with-extend.patch b/patches/server-Stored_ACLs/0007-server-Retrieve-file-security-attributes-with-extend.patch index 51a4ebe2..ffa738e8 100644 --- a/patches/server-Stored_ACLs/0007-server-Retrieve-file-security-attributes-with-extend.patch +++ b/patches/server-Stored_ACLs/0007-server-Retrieve-file-security-attributes-with-extend.patch @@ -1,19 +1,19 @@ -From f6264626e3a00195c740cd339043d48372005f17 Mon Sep 17 00:00:00 2001 +From 15413f95effeff3ffaa30097b7c71ac12a8870c9 Mon Sep 17 00:00:00 2001 From: "Erich E. Hoover" Date: Fri, 18 Apr 2014 14:01:35 -0600 Subject: [PATCH] server: Retrieve file security attributes with extended file attributes. (try 7) --- - dlls/advapi32/tests/security.c | 19 +++++++------- - server/file.c | 46 +++++++++++++++++++++++++++++++--- - 2 files changed, 52 insertions(+), 13 deletions(-) + dlls/advapi32/tests/security.c | 19 +++++------ + server/file.c | 62 ++++++++++++++++++++++++++++++++-- + 2 files changed, 68 insertions(+), 13 deletions(-) diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c -index b79ea481e64..849a6b0b032 100644 +index f0545f1871c..2006c9cd0a9 100644 --- a/dlls/advapi32/tests/security.c +++ b/dlls/advapi32/tests/security.c -@@ -3648,7 +3648,7 @@ static void test_CreateDirectoryA(void) +@@ -3645,7 +3645,7 @@ static void test_CreateDirectoryA(void) } ok(!error, "GetNamedSecurityInfo failed with error %d\n", error); test_inherited_dacl(pDacl, admin_sid, user_sid, OBJECT_INHERIT_ACE|CONTAINER_INHERIT_ACE, @@ -22,7 +22,7 @@ index b79ea481e64..849a6b0b032 100644 LocalFree(pSD); /* Test inheritance of ACLs in CreateFile without security descriptor */ -@@ -4102,21 +4102,20 @@ static void test_GetNamedSecurityInfoA(void) +@@ -4099,21 +4099,20 @@ static void test_GetNamedSecurityInfoA(void) bret = GetAce(pDacl, 0, (VOID **)&ace); ok(bret, "Failed to get Current User ACE.\n"); bret = EqualSid(&ace->SidStart, user_sid); @@ -50,7 +50,7 @@ index b79ea481e64..849a6b0b032 100644 ok(((ACE_HEADER *)ace)->AceFlags == 0, "Administators Group ACE has unexpected flags (0x%x != 0x0)\n", ((ACE_HEADER *)ace)->AceFlags); ok(ace->Mask == 0x1f01ff || broken(ace->Mask == GENERIC_ALL) /* win2k */, -@@ -4143,8 +4142,8 @@ static void test_GetNamedSecurityInfoA(void) +@@ -4140,8 +4139,8 @@ static void test_GetNamedSecurityInfoA(void) { bret = GetAce(pDacl, 0, (VOID **)&ace); ok(bret, "Failed to get ACE.\n"); @@ -62,13 +62,43 @@ index b79ea481e64..849a6b0b032 100644 LocalFree(pSD); diff --git a/server/file.c b/server/file.c -index a659b1c7872..19d04e050ed 100644 +index 48a2934aa0c..e81d32726f1 100644 --- a/server/file.c +++ b/server/file.c -@@ -225,6 +225,22 @@ int is_file_executable( const char *name ) +@@ -47,6 +47,7 @@ + #include + #endif + #ifdef HAVE_SYS_EXTATTR_H ++#undef XATTR_ADDITIONAL_OPTIONS + #include + #endif + +@@ -65,6 +66,9 @@ + #ifndef XATTR_USER_PREFIX + #define XATTR_USER_PREFIX "user." + #endif ++#ifndef XATTR_USER_PREFIX_LEN ++#define XATTR_USER_PREFIX_LEN (sizeof(XATTR_USER_PREFIX) - 1) ++#endif + #ifndef XATTR_SIZE_MAX + #define XATTR_SIZE_MAX 65536 + #endif +@@ -229,6 +233,34 @@ int is_file_executable( const char *name ) return len >= 4 && (!strcasecmp( name + len - 4, ".exe") || !strcasecmp( name + len - 4, ".com" )); } ++#ifdef HAVE_SYS_EXTATTR_H ++static inline int xattr_valid_namespace( const char *name ) ++{ ++ if (strncmp( XATTR_USER_PREFIX, name, XATTR_USER_PREFIX_LEN ) != 0) ++ { ++ errno = EPERM; ++ return 0; ++ } ++ return 1; ++} ++#endif ++ +static int xattr_fget( int filedes, const char *name, void *value, size_t size ) +{ +#if defined(XATTR_ADDITIONAL_OPTIONS) @@ -88,7 +118,7 @@ index a659b1c7872..19d04e050ed 100644 static int xattr_fset( int filedes, const char *name, void *value, size_t size ) { #if defined(XATTR_ADDITIONAL_OPTIONS) -@@ -523,6 +539,29 @@ static void convert_generic_sd( struct security_descriptor *sd ) +@@ -527,6 +559,29 @@ static void convert_generic_sd( struct security_descriptor *sd ) } } @@ -118,7 +148,7 @@ index a659b1c7872..19d04e050ed 100644 struct security_descriptor *get_file_sd( struct object *obj, struct fd *fd, mode_t *mode, uid_t *uid ) { -@@ -538,9 +577,10 @@ struct security_descriptor *get_file_sd( struct object *obj, struct fd *fd, mode +@@ -542,9 +597,10 @@ struct security_descriptor *get_file_sd( struct object *obj, struct fd *fd, mode (st.st_uid == *uid)) return obj->sd;