mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
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.
This commit is contained in:
parent
bb7852e34b
commit
48e0af0157
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user