! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Thunar breaks umask after Create Folder operation
Status:
RESOLVED: DUPLICATE
Product:
Thunar-vfs
Component:
General

Comments

Description Richard Garnish 2009-05-19 18:10:21 CEST
Created attachment 2360 
Prevent folder creation from clobbering umask

The patch in revision 29653 (bug #3532) clobbers Thunar's umask after a folder is created, so future files and folders are created with wide open permissions.  It appears that the testing of this patch was limited to creating one folder, or possibly only files.  I can imagine security issues related to unwittingly creating world-writable files and folders.

To reproduce:
- File/Create Document/Empty File => file is created with correct permissions
- File/Create Folder => folder is created with correct permissions
- File/Create Folder => folder is created with 0777 permissions
- File/Create Document/Empty File => file is created with 0666 permissions

The patch in revision 29653 is trying to be too clever, by calling umask() to get the process' umask.  But since umask() also sets the process umask, that call affects any future file operations for the duration of the process.  To read the umask correctly, one needs to reset the umask afterwards, with a construct such as:

mode_t dmask;

umask ((dmask = umask (0)));
/* dmask now holds the process' umask, and the umask is kept the same */

However, there is no need to even call umask() in this instance, since mkdir() already honours the process umask in the same way as open().  Therefore I propose the attached patch, which simply removes the umask() call.  My own testing indicates that Thunar behaves correctly wrt. file and folder creation permissions when this patch is applied.
Comment 1 Kamchybek Jusupov 2009-07-09 04:53:51 CEST
Hi all,

Environment details:
OS: Gentoo
Kernel: 2.6.29-gentoo-r5 (i686)
xfce4: 4.6.1
Thunar: 1.0.1

I've got below situation:

xxx@server ~ $ umask 
0007


xxx@server ~ $ ls -lrt
total 12
drwxr-x--- 2 xxx claims 4096 Jul  8 14:08 Drives
drwx------ 2 xxx claims 4096 Jul  8 14:09 Desktop
-rw-rw---- 1 xxx claims    0 Jul  9 12:37 xxx
drwxrwx--- 2 xxx claims 4096 Jul  9 12:38 xx

xxx@server ~ $ ls -lrt xx/
total 0
-rw-rw-rw- 1 xxx claims 0 Jul  9 12:38 aa
-rw-rw---- 1 xxx claims 0 Jul  9 12:38 bb
-rw-rw---- 1 xxx claims 0 Jul  9 12:38 cc

Sequence of events:
1. Create a new folder "xx"
2. Create a new file "aa" <-- permissions rw-rw-rw-
3. Create a new file "bb" [OK]
4. Create a new file "cc" [OK]
Comment 2 Richard Garnish 2009-07-09 14:05:49 CEST
Kamchybek, did you try applying the patch I attached? It fixed the problem for us.
Comment 3 Jannis Pohlmann editbugs 2009-10-03 10:51:48 CEST
Just fixed this one properly. Richard, you're right, umask should not be fiddled with. System calls already apply it for us.

*** This bug has been marked as a duplicate of bug 3532 ***

Bug #5376

Reported by:
Richard Garnish
Reported on: 2009-05-19
Last modified on: 2010-11-07

People

Assignee:
Jannis Pohlmann
CC List:
3 users

Version

Version:
unspecified

Attachments

Additional information