Add support for xattr/ACLs on FreeBSD

This commit is contained in:
Michael Müller 2014-06-01 22:10:22 +02:00
parent e5c7fe8c18
commit b4d53a7344
2 changed files with 81 additions and 1 deletions

View File

@ -0,0 +1,80 @@
From bfdf96dbe94a6b38aee3b5e2bf89b482612a6b2c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sun, 1 Jun 2014 22:06:35 +0200
Subject: server: Add support for ACLs/xattr on FreeBSD
---
configure.ac | 2 +-
server/file.c | 16 ++++++++++++++--
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index 0663893..c1ea0c9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -668,7 +668,7 @@ AC_CHECK_HEADERS([libprocstat.h],,,
if test "x$with_xattr" != "xno"
then
- AC_CHECK_HEADERS(attr/xattr.h,HAVE_XATTR=1)
+ AC_CHECK_HEADERS(attr/xattr.h sys/extattr.h,HAVE_XATTR=1)
fi
if test "x$with_xattr" == "xyes"
then
diff --git a/server/file.c b/server/file.c
index bf5b796..9bdf25c 100644
--- a/server/file.c
+++ b/server/file.c
@@ -43,6 +43,10 @@
#ifdef HAVE_ATTR_XATTR_H
#include <attr/xattr.h>
#endif
+#ifdef HAVE_SYS_EXTATTR_H
+#include <sys/extattr.h>
+#define XATTR_SIZE_MAX 65536
+#endif
#include "ntstatus.h"
#define WIN32_NO_STATUS
@@ -184,7 +188,7 @@ static struct object *create_file_obj( struct fd *fd, unsigned int access, mode_
void set_xattr_sd( int fd, const struct security_descriptor *sd, const SID *user, const SID *group )
{
-#ifdef HAVE_ATTR_XATTR_H
+#if defined(HAVE_ATTR_XATTR_H) || defined(HAVE_SYS_EXTATTR_H)
char buffer[XATTR_SIZE_MAX], *dst_ptr = &buffer[2], *src_ptr = (char *)sd;
int present, len, owner_len, group_len;
struct security_descriptor *dst_sd;
@@ -241,7 +245,11 @@ void set_xattr_sd( int fd, const struct security_descriptor *sd, const SID *user
memcpy( dst_ptr, src_ptr, sd->dacl_len );
src_ptr += sd->dacl_len;
dst_ptr += sd->dacl_len;
+#if defined(HAVE_ATTR_XATTR_H)
fsetxattr( fd, "user.wine.sd", buffer, len, 0 );
+#else
+ extattr_set_fd( fd, EXTATTR_NAMESPACE_USER, "wine.sd", buffer, len );
+#endif
#endif
}
@@ -732,12 +740,16 @@ struct security_descriptor *mode_to_sd( mode_t mode, const SID *user, const SID
struct security_descriptor *get_xattr_sd( int fd )
{
-#ifdef HAVE_ATTR_XATTR_H
+#if defined(HAVE_ATTR_XATTR_H) || defined(HAVE_SYS_EXTATTR_H)
struct security_descriptor *sd;
char buffer[XATTR_SIZE_MAX];
int n;
+#if defined(HAVE_ATTR_XATTR_H)
n = fgetxattr( fd, "user.wine.sd", buffer, sizeof(buffer) );
+#else
+ n = extattr_get_fd( fd, EXTATTR_NAMESPACE_USER, "wine.sd", buffer, sizeof(buffer) );
+#endif
if (n < 2 + sizeof(struct security_descriptor)) return NULL;
/* validate that we can handle the descriptor */
--
1.9.3

View File

@ -1,3 +1,3 @@
Revision: 5
Revision: 6
Author: Erich E. Hoover
Title: Store and return security attributes with extended file attributes.