1

So, I have followed this tutorial to migrate my already configured Jenkins inside a Docker container, this works quite well.

At the end of the tutorial, I launched the command:

 sudo chmod -R 777 ~/jenkins/

To avoid any user permission problems, which works well but seems to be a pretty nasty workaround and could maybe cause vulnerabilities in a production environment.

In the tutorial, Yuri Kushch wrote that I could instead

map folder to correct user

So this got me wondering to what user I should map the files/folder.

For this, I first looked the permission and owners in the original JENKINS_HOME directory:

$ ls -l /var/lib | grep jenkins
drwxr-xr-x 15 jenkins       jenkins       4096 Okt 30 09:01 jenkins
$ ls -l /var/lib/jenkins
total 104
-rw-r--r--  1 jenkins jenkins  1644 Okt 30 09:01 config.xml
-rw-r--r--  1 jenkins jenkins   156 Okt 30 09:01 hudson.model.UpdateCenter.xml
-rw-r--r--  1 jenkins jenkins   370 Okt 25 09:46 hudson.plugins.git.GitTool.xml
-rw-------  1 jenkins jenkins  1712 Okt 25 09:31 identity.key.enc
drwxr-xr-x  3 root    root     4096 Okt 29 11:40 jenkins
-rw-r--r--  1 jenkins jenkins    94 Okt 25 09:31 jenkins.CLI.xml
-rw-r--r--  1 jenkins jenkins     7 Okt 25 09:48 jenkins.install.InstallUtil.lastExecVersion
-rw-r--r--  1 jenkins jenkins     7 Okt 25 09:48 jenkins.install.UpgradeWizard.state
-rw-r--r--  1 jenkins jenkins   179 Okt 25 09:48 jenkins.model.JenkinsLocationConfiguration.xml
-rw-r--r--  1 jenkins jenkins   171 Okt 25 09:31 jenkins.telemetry.Correlator.xml
drwxr-xr-x  3 jenkins jenkins  4096 Okt 25 09:49 jobs
drwxr-xr-x  3 jenkins jenkins  4096 Okt 25 09:31 logs
-rw-r--r--  1 jenkins jenkins   907 Okt 30 09:01 nodeMonitors.xml
drwxr-xr-x  2 jenkins jenkins  4096 Okt 25 09:30 nodes
-rw-r--r--  1 jenkins jenkins    46 Okt 25 15:00 org.jenkinsci.plugins.workflow.flow.FlowExecutionList.xml
drwxr-xr-x 82 jenkins jenkins 12288 Okt 25 10:07 plugins
-rw-r--r--  1 jenkins jenkins   193 Okt 25 09:44 proxy.xml
-rw-r--r--  1 jenkins jenkins   129 Okt 29 14:54 queue.xml.bak
-rw-r--r--  1 jenkins jenkins    64 Okt 25 09:30 secret.key
-rw-r--r--  1 jenkins jenkins     0 Okt 25 09:30 secret.key.not-so-secret
drwx------  4 jenkins jenkins  4096 Okt 25 14:59 secrets
drwxr-xr-x  2 jenkins jenkins  4096 Okt 29 09:12 updates
drwxr-xr-x  2 jenkins jenkins  4096 Okt 25 09:31 userContent
drwxr-xr-x  3 jenkins jenkins  4096 Okt 25 09:48 users
drwxr-xr-x  2 jenkins jenkins  4096 Okt 25 09:46 workflow-libs

And then looked I what permissons/owners I had in my new JENKINS_HOME:

$ ls -l | grep jenkins
drwxrwxrwx 4 jenkins root   4096 Okt 30 09:44 jenkins
$ ls -l ~/jenkins/data
total 108
-rw-r--r--  1 root root  1644 Okt 30 09:45 config.xml
-rw-r--r--  1 root root   156 Okt 30 09:45 hudson.model.UpdateCenter.xml
-rw-r--r--  1 root root   370 Okt 30 09:45 hudson.plugins.git.GitTool.xml
-rw-------  1 root root  1712 Okt 30 09:45 identity.key.enc
drwxr-xr-x  3 root root  4096 Okt 30 09:45 jenkins
-rw-r--r--  1 root root    94 Okt 30 09:45 jenkins.CLI.xml
-rw-r--r--  1 root root     7 Okt 30 09:45 jenkins.install.InstallUtil.lastExecVersion
-rw-r--r--  1 root root     7 Okt 30 09:45 jenkins.install.UpgradeWizard.state
-rw-r--r--  1 root root   179 Okt 30 09:45 jenkins.model.JenkinsLocationConfiguration.xml
-rw-r--r--  1 root root   171 Okt 30 09:45 jenkins.telemetry.Correlator.xml
drwxr-xr-x  3 root root  4096 Okt 30 09:45 jobs
drwxr-xr-x  3 root root  4096 Okt 30 09:45 logs
-rw-r--r--  1 root root   907 Okt 30 09:45 nodeMonitors.xml
drwxr-xr-x  2 root root  4096 Okt 30 09:45 nodes
-rw-r--r--  1 root root    46 Okt 30 09:45 org.jenkinsci.plugins.workflow.flow.FlowExecutionList.xml
drwxr-xr-x 82 root root 12288 Okt 30 09:45 plugins
-rw-r--r--  1 root root   193 Okt 30 09:45 proxy.xml
-rw-r--r--  1 root root   129 Okt 30 09:45 queue.xml
-rw-r--r--  1 root root   129 Okt 30 09:45 queue.xml.bak
-rw-r--r--  1 root root    64 Okt 30 09:45 secret.key
-rw-r--r--  1 root root     0 Okt 30 09:45 secret.key.not-so-secret
drwx------  4 root root  4096 Okt 30 09:45 secrets
drwxr-xr-x  2 root root  4096 Okt 30 09:45 updates
drwxr-xr-x  2 root root  4096 Okt 30 09:45 userContent
drwxr-xr-x  3 root root  4096 Okt 30 09:45 users
drwxr-xr-x  2 root root  4096 Okt 30 09:45 workflow-libs

So I used this command to change the rights and have them as in the old directory:

sudo chown jenkins:jenkins -R $(ls | awk '{if($1 != "jenkins"){ print $1 }}')

It gave me the same output as my old JENKINS_HOME. But when connecting to the Jenkins port on my browser, I just had a blank page.

What did I miss in my permission change? Is there another proper way of setting the permissions/owner? Or is the first workaround secure enough?

Thanks for your help!

0

You must log in to answer this question.

Browse other questions tagged .