1

I want to change umask value from 022 to 002 for a particular user jboss. Right now it is set as follows in /etc/profile:

if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
umask 002
 else
umask 022
fi

If I change /etc/profile , it will impact all users but I want to change the setting for jboss user only. For this I can edit .basrhrc/.bash_profile under user's home directory . But the issue for me is that the user does not have a shell . Any way to set umask for users without shell .

0

1 Answer 1

3

The umask is a property of a process, not a user.

It is inherited by children and preserved across execution of commands even setuid ones.

It is set with the umask() system call. The shell interface to that umask() system call is the umask builtin command.

There is no magical way to have the umask be changed whenever a process changes uid, but some programs that are typically used to change uids can be configured to. That's the case of those using the PAM stack on Linux at least (typically login programs), using the pam_umask module, or sudo.

But here, given that that user doesn't have a shell, I suppose it's not one that logs in, and you actually want one particular software run as that user to have that umask. Then, that should be just a matter of starting that software with:

(umask 002; exec that-software)

In a shell script.

2
  • It is a java process for me with a Web interface. When we try to upload an image using this process of creates a new directory without write permission for group owner. We want to change the umask so that every new directory is created with write permission for group.
    – Zama Ques
    Nov 5, 2017 at 8:23
  • @ZamaQues, yes, sounds like you just need to start that java command as umask 002; java ... Nov 5, 2017 at 8:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .