summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoss Lagerwall <rosslagerwall@gmail.com>2014-04-10 21:35:25 +0100
committerRoss Lagerwall <rosslagerwall@gmail.com>2014-04-11 17:40:28 +0100
commit9fe664597834114e8a42dbe09c3b2395affd272b (patch)
treedeae489343bd29d31afa5d1b7508b388e9b10ce5
parent43a9b93d925be2d12e988374d733d86a94191453 (diff)
downloadgvfs-9fe664597834114e8a42dbe09c3b2395affd272b.tar.gz
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
-rw-r--r--client/gvfsfusedaemon.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/client/gvfsfusedaemon.c b/client/gvfsfusedaemon.c
index 2b3b639f..82e7c309 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;
}