Gentoo Archives: gentoo-commits

From: "Samuli Suominen (ssuominen)" <ssuominen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in xfce-base/thunar/files: thunar-1.0.1-fix-umask-handling.patch
Date: Thu, 22 Apr 2010 16:18:11
Message-Id: 20100422154200.E2DFB28D3E@corvid.gentoo.org
1 ssuominen 10/04/22 15:42:00
2
3 Added: thunar-1.0.1-fix-umask-handling.patch
4 Log:
5 Fix umask handling after Create Folder operation wrt #316681 by Ivan Ponomarev.
6 (Portage version: 2.2_rc67/cvs/Linux x86_64)
7
8 Revision Changes Path
9 1.1 xfce-base/thunar/files/thunar-1.0.1-fix-umask-handling.patch
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/xfce-base/thunar/files/thunar-1.0.1-fix-umask-handling.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/xfce-base/thunar/files/thunar-1.0.1-fix-umask-handling.patch?rev=1.1&content-type=text/plain
13
14 Index: thunar-1.0.1-fix-umask-handling.patch
15 ===================================================================
16 commit eb58c6a6ba7f77c2c16016db064524df598ef421
17 Author: Jannis Pohlmann <jannis@××××.org>
18 Date: Sat Oct 3 11:49:41 2009 +0200
19
20 Fix bugs #3532 (umask < 0022 not honoured) and #5813 properly (I hope).
21
22 The previous patch applied in e53de71e6add9b28ba034111a1d19db7def8f7e7
23 made things worse than before: it used DEFFILEMODE which seems to be
24 BSD-specific for creating files. It also reset the umask to 0 when
25 creating the first directory with _thunar_vfs_io_jobs_mkdir().
26
27 What we really want is to use 0777 (dirs) and 0666 (files) and let the
28 standard C system calls like open() apply the umask value. This should
29 work on all POSIX-compliant systems.
30
31 Patch provided by Craig Ringer <craig@××××××××××××××××××.au>.
32
33 diff --git a/thunar-vfs/thunar-vfs-io-jobs.c b/thunar-vfs/thunar-vfs-io-jobs.c
34 index 8d70812..c94523a 100644
35 --- a/thunar-vfs/thunar-vfs-io-jobs.c
36 +++ b/thunar-vfs/thunar-vfs-io-jobs.c
37 @@ -432,8 +432,12 @@ _thunar_vfs_io_jobs_create (ThunarVfsJob *job,
38 absolute_path = thunar_vfs_path_dup_string (lp->data);
39
40 again:
41 - /* try to create the file at the given path */
42 - fd = g_open (absolute_path, O_CREAT | O_EXCL | O_WRONLY, DEFFILEMODE);
43 + /* Try to create the file at the given path.
44 + *
45 + * Note that despite the 0666 mask, we won't really create a world-writable
46 + * file unless the user's umask permits it (ie the umask is 0000).
47 + */
48 + fd = g_open (absolute_path, O_CREAT | O_EXCL | O_WRONLY, 0666);
49 if (G_UNLIKELY (fd < 0))
50 {
51 /* check if the file already exists */
52 @@ -707,8 +711,13 @@ _thunar_vfs_io_jobs_mkdir (ThunarVfsJob *job,
53 /* update the progress information */
54 _thunar_vfs_job_process_path (job, lp);
55
56 - /* try to create the target directory */
57 - if (!_thunar_vfs_io_ops_mkdir (lp->data, 0777 & ~umask(0), THUNAR_VFS_IO_OPS_NONE, error))
58 + /* try to create the target directory
59 + *
60 + * Note that the mode specified here is limited by the user's umask, so we will not
61 + * actually be creating a world writable directory unless the user's umask permits
62 + * it.
63 + */
64 + if (!_thunar_vfs_io_ops_mkdir (lp->data, 0777, THUNAR_VFS_IO_OPS_NONE, error))
65 return FALSE;
66 }