summaryrefslogtreecommitdiff
path: root/gio/glocalfileinfo.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2009-09-01 21:26:08 +0200
committerBenjamin Otte <otte@gnome.org>2009-09-01 21:33:11 +0200
commit48e0af0157f52ac12b904bd92540432a18b139c7 (patch)
treed1a1f47fa74f595bc209d60de0654d46cbf4a2e8 /gio/glocalfileinfo.c
parentbb7852e34b1845e516290e1b45a960a345ee8a43 (diff)
downloadglib-48e0af0157f52ac12b904bd92540432a18b139c7.tar.gz
Bug 593406 - Permissions set to 777 after copying via Nautilus
Only fail to set the permissions when the actual file is a symlink. The previous fix failed for every file when NOFOLLOW_SYMLINKS was set.
Diffstat (limited to 'gio/glocalfileinfo.c')
-rw-r--r--gio/glocalfileinfo.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c
index b4e77d925..7182ec549 100644
--- a/gio/glocalfileinfo.c
+++ b/gio/glocalfileinfo.c
@@ -1874,20 +1874,31 @@ set_unix_mode (char *filename,
GError **error)
{
guint32 val;
+ int res = 0;
if (!get_uint32 (value, &val, error))
return FALSE;
#ifdef HAVE_SYMLINK
if (flags & G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS) {
- g_set_error_literal (error, G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Cannot set permissions on symlinks"));
- return FALSE;
+ struct stat statbuf;
+ /* Calling chmod on a symlink changes permissions on the symlink.
+ * We don't want to do this, so we need to check for a symlink */
+ res = g_lstat (filename, &statbuf);
+ if (res == 0 && S_ISLNK (statbuf.st_mode))
+ {
+ g_set_error_literal (error, G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ _("Cannot set permissions on symlinks"));
+ return FALSE;
+ }
}
#endif
- if (g_chmod (filename, val) == -1)
+ if (res == 0)
+ res = g_chmod (filename, val);
+
+ if (res == -1)
{
int errsv = errno;