mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
Don't succeed with trash if newly created trash dir has the wrong owner.
2008-02-06 Alexander Larsson <alexl@redhat.com> * glocalfile.c (g_local_file_trash): Don't succeed with trash if newly created trash dir has the wrong owner. (#514696) svn path=/trunk/; revision=6459
This commit is contained in:
parent
ebfd091263
commit
2185733235
@ -1,3 +1,9 @@
|
|||||||
|
2008-02-06 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
|
* glocalfile.c (g_local_file_trash):
|
||||||
|
Don't succeed with trash if newly created
|
||||||
|
trash dir has the wrong owner. (#514696)
|
||||||
|
|
||||||
2008-02-05 Alexander Larsson <alexl@redhat.com>
|
2008-02-05 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
* glocalfile.c (g_local_file_move):
|
* glocalfile.c (g_local_file_move):
|
||||||
|
@ -1546,27 +1546,47 @@ g_local_file_trash (GFile *file,
|
|||||||
|
|
||||||
if (trashdir == NULL)
|
if (trashdir == NULL)
|
||||||
{
|
{
|
||||||
|
gboolean tried_create;
|
||||||
|
|
||||||
/* No global trash dir, or it failed the tests, fall back to $topdir/.Trash-$uid */
|
/* No global trash dir, or it failed the tests, fall back to $topdir/.Trash-$uid */
|
||||||
dirname = g_strdup_printf (".Trash-%s", uid_str);
|
dirname = g_strdup_printf (".Trash-%s", uid_str);
|
||||||
trashdir = g_build_filename (topdir, dirname, NULL);
|
trashdir = g_build_filename (topdir, dirname, NULL);
|
||||||
g_free (dirname);
|
g_free (dirname);
|
||||||
|
|
||||||
|
tried_create = FALSE;
|
||||||
|
|
||||||
|
retry:
|
||||||
if (g_lstat (trashdir, &trash_stat) == 0)
|
if (g_lstat (trashdir, &trash_stat) == 0)
|
||||||
{
|
{
|
||||||
if (!S_ISDIR (trash_stat.st_mode) ||
|
if (!S_ISDIR (trash_stat.st_mode) ||
|
||||||
trash_stat.st_uid != uid)
|
trash_stat.st_uid != uid)
|
||||||
{
|
{
|
||||||
|
/* Remove the failed directory */
|
||||||
|
if (tried_create)
|
||||||
|
g_remove (trashdir);
|
||||||
|
|
||||||
/* Not a directory or not owned by user, ignore */
|
/* Not a directory or not owned by user, ignore */
|
||||||
g_free (trashdir);
|
g_free (trashdir);
|
||||||
trashdir = NULL;
|
trashdir = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (g_mkdir (trashdir, 0700) == -1)
|
else
|
||||||
|
{
|
||||||
|
if (!tried_create &&
|
||||||
|
g_mkdir (trashdir, 0700) != -1)
|
||||||
|
{
|
||||||
|
/* Ensure that the created dir has the right uid etc.
|
||||||
|
This might fail on e.g. a FAT dir */
|
||||||
|
tried_create = TRUE;
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
g_free (trashdir);
|
g_free (trashdir);
|
||||||
trashdir = NULL;
|
trashdir = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (trashdir == NULL)
|
if (trashdir == NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user