umask - Create file with +x default

General support questions
Post Reply
Dominic
Posts: 9
Joined: 2014/07/28 07:15:23

umask - Create file with +x default

Post by Dominic » 2014/09/15 08:47:16

Hi All,

I'm not sure if umask is the right way. Anyway, here is my problem:
I have a folder where a Software will drop some files. Those files need to be created with the permissions 775 (+x for others).

Is there a way to do this? Normaly a file with a umask of "0000" will still have "-rw-rw-rw".

Thanks,
Dominic

vanecka
Posts: 45
Joined: 2010/01/28 21:05:11
Location: University of the Free State - South Africa
Contact:

Re: umask - Create file with +x default

Post by vanecka » 2014/10/21 12:10:46

Hi Dominic,

Unfortunately umask will not do what you want. It will only work for directories.
Nor will setfacl work. The problem is that the highest value for a new created file is going to be 666 and for a directory 777.

Code: Select all

#You would want to set umask to 002:
]$  umask 002
]$  mkdir aaa
]$  touch a
]$  ls -l
-rw-rw-r--. 1 vanecka vanecka 0 Oct 21 13:56 a
drwxrwxr-x. 2 vanecka vanecka 6 Oct 21 13:56 aaa
As you can see, new directories have the correct permission set to 775 but files only have 664.

The alternative would have been to use setfacl but the same limitation holds:

Code: Select all

]$  mkdir /data
]$  setfacl -m d:u::rwx,d:g::rwx,d:o::rx /data
]$  getfacl /data/
getfacl: Removing leading '/' from absolute path names
# file: data/
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
default:user::rwx
default:group::rwx
default:other::r-x


]$  cd /data
]$  mkdir aaa
]$  touch a
]$  ls -l
-rw-rw-r--. 1 root root 0 Oct 21 14:01 a
drwxrwxr-x+ 2 root root 6 Oct 21 14:01 aaa
The same permissions are given as above.

The only way I can think of is to do a find in the path (you can of course put it in a cron job):

Code: Select all

]$  find /data/ -type f -exec chmod 0775 {} \;
]$  ls -l /data
-rwxrwxr-x. 1 root root 0 Oct 21 14:01 a
In short, you'll have to set it using chmod specifically. Unless you create the files through a SAMBA share,
then SAMBA can set the specific permissions (executable) to files.

Sorry, no reasonable solution that I can think of.

Post Reply

Return to “CentOS 7 - General Support”