[JIRA] (JENKINS-60054) Wrong umask? Containers with non-root user don't have permissions to agent durable script folders

5 views
Skip to first unread message

llibicpep@gmail.com (JIRA)

unread,
Nov 5, 2019, 2:49:04 AM11/5/19
to jenkinsc...@googlegroups.com
Dmytro Kryvenko created an issue
 
Jenkins / Bug JENKINS-60054
Wrong umask? Containers with non-root user don't have permissions to agent durable script folders
Issue Type: Bug Bug
Assignee: Unassigned
Components: kubernetes-plugin
Created: 2019-11-05 07:48
Environment: Jenkins: 2.190.2
kubernetes-plugin: 1.21.1
jnlp slave: jenkins/jnlp-slave:3.35-5-alpine
Priority: Minor Minor
Reporter: Dmytro Kryvenko

This setup used to work in older versions, I suspect regression happened somewhere around changing working directory to `/home/jenkins/agent`.

When running container with non-root user (of course having `fsGroup`/`supplementalGroups` to `1000` to match jnlp slave GUID) getting the following error:

```
process apparently never started in /home/jenkins/agent/workspace/ure-xxx-terraform-module_PR-1@tmp/durable-79996fba
(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
```

Doing that reveals:

```
LAUNCHER: open /home/jenkins/agent/workspace/ure-xxx-terraform-module_PR-1@tmp/durable-cc0559df/jenkins-log.txt: permission denied
```

I know there's a lot of similar issues being reported recently, but this one is different and not related to the `workingDir` in `jnlp` slave. I am using `jenkins/jnlp-slave:3.35-5-alpine` image and have `workingDir` correctly defaulting to `/home/jenkins/agent`.

I've seen mainly two suggested workarounds to the issue - change user/group in the container and use `runAsUser` in pod definition. None of this is relevant. To build a flexible CICD you want users to have an ability to specify a dockerhub image (well, at least a tag to whitelisted images) so change of image is not viable. Adding `runAsUser: 1000` might work in some limited cases but in reality not viable either. A lot of stuff (let's start with git client) will complain the user for that UID doesn't exist and crash.

Just to summarize, expected behaviour would be: as long as

```
securityContext:
fsGroup: 1000
supplementalGroups:

  • 1000
    ```

is set on the pod, using containers with non-root and non-/home/jenkins home should work just fine like they used to.

I found another workaround, which is applying this on jnlp container:

```
command:

  • /bin/bash
    args:
  • "-c"
  • "umask 0002; jenkins-agent"
    ```

But I would imagine it wouldn't be secure? Or is it not?

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

llibicpep@gmail.com (JIRA)

unread,
Nov 5, 2019, 2:52:03 AM11/5/19
to jenkinsc...@googlegroups.com
Dmytro Kryvenko updated an issue
Change By: Dmytro Kryvenko
This setup used to work in older versions, I suspect regression happened somewhere around changing working directory to ` {{ /home/jenkins/agent ` }} .

When running container with non-root user (of course having
` {{ fsGroup ` }} / ` {{ supplementalGroups ` }} to ` {{ 1000 ` }} to match jnlp slave GUID) getting the following error:

``` {{code}}
process apparently never started in /home/jenkins/agent/workspace/ure-xxx-terraform-module_PR-1@tmp/durable-79996fba
(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
``` {{code}}

Doing that reveals:

``` {{code}}
LAUNCHER: open /home/jenkins/agent/workspace/ure-xxx-terraform-module_PR-1@tmp/durable-cc0559df/jenkins-log.txt: permission denied
``` {{code}}

I know there's a lot of similar issues being reported recently, but this one is different and not related to the
` {{ workingDir ` }} in ` {{ jnlp ` }} slave. I am using ` {{ jenkins/jnlp-slave:3.35-5-alpine ` }} image and have ` {{ workingDir ` }} correctly defaulting to ` {{ /home/jenkins/agent ` }} .


I've seen mainly two suggested workarounds to the issue - change user/group in the container and use
` {{ runAsUser ` }} in pod definition. None of this is relevant. To build a flexible CICD you want users to have an ability to specify a dockerhub image (well, at least a tag to whitelisted images) so change of image is not viable. Adding ` {{ runAsUser: 1000 ` }} might work in some limited cases but in reality not viable either. A lot of stuff (let's start with git client) will complain the user for that UID doesn't exist and crash.


Just to summarize, expected behaviour would be: as long as

``` {{code}}
  securityContext:
    fsGroup: 1000
    supplementalGroups:
    - 1000
``` {{code}}

is set on the pod, using containers with non-root and non-
{{ /home/jenkins }} home should work just fine like they used to.


I found another workaround, which is applying this on jnlp container:

``` {{code}}
  command:
  - /bin/bash
  args:
  - "-c"
  - "umask 0002; jenkins-agent"
``` {{code}}

But I would imagine it wouldn't be secure? Or is it not?

llibicpep@gmail.com (JIRA)

unread,
Nov 5, 2019, 2:52:03 AM11/5/19
to jenkinsc...@googlegroups.com

llibicpep@gmail.com (JIRA)

unread,
Nov 5, 2019, 2:59:03 AM11/5/19
to jenkinsc...@googlegroups.com
- "umask 0002 002 ; jenkins-agent"

{code}

But I would imagine it wouldn't be secure? Or is it not?

llibicpep@gmail.com (JIRA)

unread,
Nov 5, 2019, 3:01:02 AM11/5/19
to jenkinsc...@googlegroups.com
- "umask 002; jenkins-agent"

{code}

But I would imagine it wouldn't be secure? Or is it not?
Reply all
Reply to author
Forward
0 new messages