Setting The Umask of The Jenkins Process

Setting the umask of the jenkins process

Set the umask by configuring the daemon, just add --umask=002 to the daemon args in /etc/init.d/jenkins:

DAEMON_ARGS="--name=$NAME --inherit --env=JENKINS_HOME=$JENKINS_HOME --output=$JENKINS_LOG --pidfile=$PIDFILE --umask=002"

How to change default permissions of created jobs in Jenkins file system

You will have to change the umask value of the jenkins user. When ever jenkins creates a folder it will then create it with the value set in umask.

Say the jenkins is running as user juser then, in the bashrc of the juser you will have to add the value umask 002 to achieve the folder permission as 775

Also, check this post --- Setting the umask of the jenkins process

Setting the umask of the Apache user

Apache inherits its umask from its parent process (i.e. the process starting Apache); this should typically be the /etc/init.d/ script. So put a umask command in that script.

linux: getting umask of an already running process?

You can attach gdb to a running process and then call umask in the debugger:

(gdb) attach <your pid>
...
(gdb) call umask(0)
[Switching to Thread -1217489200 (LWP 11037)]
$1 = 18 # this is the umask
(gdb) call umask(18) # reset umask
$2 = 0
(gdb)

(note: 18 corresponds to a umask of O22 in this example)

This suggests that there may be a really ugly way to get the umask using ptrace.

How do you change the umask when building with rpmbuild?

You cannot change the umask from the shell because rpmbuild will always set a a fixed umask of 0022 before running %prep script.

Therefore, depending on what you're trying to achieve, you could try change the umask in the spec file, at the beginning the %prep section:

%prep
umask 077

But, if you're just trying to set the file permissions for the files in the RPM, the standard way is to use %defattr and %attr directives in the %files section:

  • %defattr sets the default attributes for files and folders:

    %defattr(<file mode>, <user>, <group>, <dir mode>)

some attributes may be omitted by replacing them with a dash (because the file is installed with those attributes properly set)

  • %attr sets the attributes for a single file or folder:

    %attr(<mode>, <user>, <group>) file/folder

As with %defattr if a particular attribute does not need to be specified, you can replace it with a dash (for example you can use it along with %defattr to keep the default value for that attribute)

A full example:

%files
# set default attributes for all files and folders:
%defattr(644, root, root, 755)
# make a file executable:
%attr(755, -, -) /usr/bin/myexec
# set a different owner for a file:
%attr(-, myuser, -) /var/log/mylog.log
# set different permissions, owner and group for a file:
%attr(600, myuser, mygroup) /home/myfile

For more details & examples you can take a look to:

http://www.rpm.org/max-rpm-snapshot/s1-rpm-specref-files-list-directives.html and

http://www.rpm.org/max-rpm/s1-rpm-anywhere-specifying-file-attributes.html



Related Topics



Leave a reply



Submit