[gvfs/gnome-3-12] fuse: Set permissions from UNIX mode when available
- From: Ross Lagerwall <rossl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/gnome-3-12] fuse: Set permissions from UNIX mode when available
- Date: Fri, 11 Apr 2014 16:52:20 +0000 (UTC)
commit 9cadf28df7d2476a155ed79a37de73587cb65c69
Author: Ross Lagerwall <rosslagerwall gmail com>
Date: Thu Apr 10 21:35:25 2014 +0100
fuse: Set permissions from UNIX mode when available
If the GFileInfo has a UNIX mode available, use that for setting
permissions. This prevents programs like vim from losing permissions
when saving a file.
https://bugzilla.gnome.org/show_bug.cgi?id=727996
client/gvfsfusedaemon.c | 31 ++++++++++++++++++++-----------
1 files changed, 20 insertions(+), 11 deletions(-)
---
diff --git a/client/gvfsfusedaemon.c b/client/gvfsfusedaemon.c
index 2b3b639..82e7c30 100644
--- a/client/gvfsfusedaemon.c
+++ b/client/gvfsfusedaemon.c
@@ -708,17 +708,26 @@ file_info_get_stat_mode (GFileInfo *file_info)
break;
}
- if (file_type == G_FILE_TYPE_DIRECTORY ||
- !g_file_info_has_attribute (file_info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ) ||
- g_file_info_get_attribute_boolean (file_info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ))
- unix_mode |= S_IRUSR;
- if (!g_file_info_has_attribute (file_info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE) ||
- g_file_info_get_attribute_boolean (file_info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE))
- unix_mode |= S_IWUSR;
- if (file_type == G_FILE_TYPE_DIRECTORY ||
- !g_file_info_has_attribute (file_info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE) ||
- g_file_info_get_attribute_boolean (file_info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE))
- unix_mode |= S_IXUSR;
+ if (g_file_info_has_attribute (file_info, G_FILE_ATTRIBUTE_UNIX_MODE))
+ {
+ mode_t mode = g_file_info_get_attribute_uint32 (file_info,
+ G_FILE_ATTRIBUTE_UNIX_MODE);
+ unix_mode |= mode & (S_IRWXU | S_IRWXG | S_IRWXO);
+ }
+ else
+ {
+ if (file_type == G_FILE_TYPE_DIRECTORY ||
+ !g_file_info_has_attribute (file_info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ) ||
+ g_file_info_get_attribute_boolean (file_info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ))
+ unix_mode |= S_IRUSR;
+ if (!g_file_info_has_attribute (file_info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE) ||
+ g_file_info_get_attribute_boolean (file_info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE))
+ unix_mode |= S_IWUSR;
+ if (file_type == G_FILE_TYPE_DIRECTORY ||
+ !g_file_info_has_attribute (file_info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE) ||
+ g_file_info_get_attribute_boolean (file_info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE))
+ unix_mode |= S_IXUSR;
+ }
return unix_mode;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]