glib2.0/debian/patches/166960.patch

69 lines
2.2 KiB
Diff

From: Yue-Lan <lanyue@ubuntukylin.com>
Date: Mon, 12 Jun 2023 17:07:42 +0800
Subject: =?utf-8?b?IzE2Njk2MCDjgJDmlofku7bnrqHnkIblmajjgJHlnKjmnYPpmZDnu4Y=?=
=?utf-8?b?5YyW55WM6Z2i5re75Yqg5a6M5YW25LuW55So5oi35p2D6ZmQ5ZCO77yM5a+56K+l?=
=?utf-8?b?5paH5qGj6L+b6KGM57yW6L6R5L+d5a2Y5ZCO77yM57uG5YyW5p2D6ZmQ55WM6Z2i?=
=?utf-8?b?6ZyA6KaB6YeN5paw5re75Yqg5YW25LuW55So5oi35p2D6ZmQ?=
---
gio/glocalfileoutputstream.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/gio/glocalfileoutputstream.c b/gio/glocalfileoutputstream.c
index 6875811..da63d6e 100644
--- a/gio/glocalfileoutputstream.c
+++ b/gio/glocalfileoutputstream.c
@@ -46,6 +46,7 @@
#include <unistd.h>
#include "gfiledescriptorbased.h"
#include <sys/uio.h>
+#include <sys/xattr.h>
#endif
#include "glib-private.h"
@@ -860,6 +861,21 @@ handle_overwrite_open (const char *filename,
int errsv = 0;
gboolean replace_destination_set = (flags & G_FILE_CREATE_REPLACE_DESTINATION);
+ #ifdef G_OS_UNIX
+ char acl_buf[1024];
+ ssize_t acl_size = getxattr(filename, "system.posix_acl_access", acl_buf, sizeof(acl_buf));
+
+ gboolean has_acl_buf = FALSE;
+ if (acl_size == -1) {
+ g_debug("Error getting ACL with %s", filename);
+ } else if (acl_size == 0) {
+ g_debug("No ACL found with %s.\n", filename);
+ } else {
+ g_debug("%s ACL: %.*s\n", filename, (int)acl_size, acl_buf);
+ has_acl_buf = TRUE;
+ }
+#endif
+
mode = mode_from_flags_or_info (flags, reference_info);
/* We only need read access to the original file if we are creating a backup.
@@ -1038,6 +1054,7 @@ handle_overwrite_open (const char *filename,
dirname = g_path_get_dirname (filename);
tmp_filename = g_build_filename (dirname, ".goutputstream-XXXXXX", NULL);
+
g_free (dirname);
tmpfd = g_mkstemp_full (tmp_filename, (readable ? O_RDWR : O_WRONLY) | O_BINARY | O_CLOEXEC, mode);
@@ -1045,7 +1062,13 @@ handle_overwrite_open (const char *filename,
{
g_free (tmp_filename);
goto fallback_strategy;
- }
+ } else {
+#ifdef G_OS_UNIX
+ if (has_acl_buf) {
+ setxattr(tmp_filename, "system.posix_acl_access", acl_buf, acl_size, 0);
+ }
+#endif
+ }
/* try to keep permissions (unless replacing) */