Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor image for ocm toi must run as root #359

Closed
dee0 opened this issue Jan 4, 2025 · 9 comments
Closed

executor image for ocm toi must run as root #359

dee0 opened this issue Jan 4, 2025 · 9 comments
Assignees
Labels
area/ipcei Important Project of Common European Interest kind/bugfix Bug

Comments

@dee0
Copy link

dee0 commented Jan 4, 2025

What happened:

I found with the USER statement in the dockerfile below my executor could not run.

FROM docker.io/bitnami/kubectl:1.31.4 

USER root
RUN mkdir -p /toi/outputs; mkdir -p /toi/inputs; chown -R 1001:1001 /toi

USER 1001
COPY ./scripts/entrypoint.sh /toi/run

ENTRYPOINT [ "/bin/bash", "/toi/run" ]

Running a command like

ocm toi bootstrap package -c ../ocm/credentials.yaml actionOne 'directory::../ocm/component-archive//example.com/ocm/toi/helloworld:1.0.0'

will fail with an error like

{"msg":"exec container process `/bin/bash`: Permission denied","level":"error","time":"2024-12-30T02:46:03.822858Z"}

The problem is when ocm copies the inputs into the container it messes up the permissions on root. The screenshot below shows the change. On the left are the permissions after ocm copied the input into place and the right are the default permissions. You can see that afterwards the permissions on root only let the owner work with it.

Image

What you expected to happen:

I should be able to have the container run as non-root.
Copying of inputs into the container should only modify the contents of under /toi/inputs.
The contents of /toi/inputs must be readable by whatever user the container is running as

How to reproduce it (as minimally and precisely as possible):

See above command and dockerfile.

Anything else we need to know:

Nope

Environment:

ocm 0.19.0

@dee0 dee0 added the kind/bugfix Bug label Jan 4, 2025
@github-actions github-actions bot added the area/ipcei Important Project of Common European Interest label Jan 4, 2025
dee0 pushed a commit to dee0/ocm-toi-helloworld that referenced this issue Jan 4, 2025
@Skarlso
Copy link
Contributor

Skarlso commented Jan 6, 2025

As a sidenote, I would stop using FROM docker.io/bitnami/kubectl:1.31.4 because of bitnami/containers#75671.

@Skarlso
Copy link
Contributor

Skarlso commented Jan 6, 2025

Hey Dan. Can you try with this PR please? open-component-model/ocm#1224

@Skarlso
Copy link
Contributor

Skarlso commented Jan 6, 2025

I actually run your project Dan and I didn't get your error. My output:

ocm toi bootstrap package -c ./userInput/credentials.yaml -p ./userInput/parametersFromCLI.yaml actionOne 'directory::./ocm/component-archive//example.com/ocm/toi/helloworld:1.0.0'
...
using executor image ghcr.io/skarlso/toi:v0.1.1[["name"="toi-executor-one"]] with credentials [myPackageOCI->myExecutorOCI]
start
+ echo start
+ cp -r /toi/inputs/. /toi/outputs/inputs
+ cp /proc/1/cmdline /toi/outputs
+ cp /proc/1/environ /toi/outputs
+ echo end
+ exit 0
+ printError
+ ec=0
+ : Exiting with exit code 0
+ exit 0
end
Provided outputs:
outputs:
  cmdline:
    binary: L2Jpbi9iYXNoAC90b2kvcnVuAGFjdGlvbk9uZQBleGFtcGxlLmNvbS9vY20vdG9pL2hlbGxvd29ybGQ6MS4wLjAA
  config:
    toiExecutorConfig:
      data: toiExecutorConfigData
      fromToiPackageExecutorConfig:
        data: toiPackageExecutorConfigData
        fromLibraryOne:
          data: toiExecutorTemplateLibraryOneData
          fromLibraryTwo:
            data: toiExecutorTemplateLibraryTwoData
        fromLibraryTwo:
          data: toiExecutorTemplateLibraryTwoData
  environ:
    binary: UEFUSD0vb3B0L2JpdG5hbWkvY29tbW9uL2Jpbjovb3B0L2JpdG5hbWkva3ViZWN0bC9iaW46L3Vzci9sb2NhbC9zYmluOi91c3IvbG9jYWwvYmluOi91c3Ivc2JpbjovdXNyL2Jpbjovc2JpbjovYmluAEhPU1ROQU1FPWI0YzYyMDhhNGJjMwBIT01FPS8AT1NfQVJDSD1hbWQ2NABPU19GTEFWT1VSPWRlYmlhbi0xMgBPU19OQU1FPWxpbnV4AEFQUF9WRVJTSU9OPTEuMzEuNABCSVROQU1JX0FQUF9OQU1FPWt1YmVjdGwA
  ocmconfig:
    configurations:
    - credentials:
      - credentials:
          password: somehardcoded-password
          username: somehardcoded-username
        credentialsName: myExecutorOCI
      repoName: default
      type: memory.credentials.config.ocm.software
    - consumers:
      - credentials:
        - credentialsName: myExecutorOCI
          repoName: default
          type: Memory
        identity:
          type: OCIRegistry
      type: credentials.config.ocm.software
    - contextType: default
      settings:
        defaultLevel: Warn
      type: logging.config.ocm.software
    type: generic.config.ocm.software
  ocmrepo:
    binary: H4sIAAAJbogA/+w9TXPbuJI5q2r+A4o5bFJjyQBI8Os263mzz1WZzauMaw+b5ICPhsUXilCRkB1vKv99CxQpUrLsyKEjP7+wL7YJoInuRjcajW6alzbTXNppVij4PPtnZYoXjw0YYxwGQf0TY7z7E/sEvyABCf2IBKF7TnzssxcI95H8KFhVlpcv8OB37RDVb/pXhi9eJeew4P8DZZWZwkvJideuicpL33/xSliaKrOmvPFST5rF0hRQ2KmCSpbZ0pqyOoXPfLHMYSbN4tTIxak12ekc8txcmzJX3oln+aWXemSGZ9g78VR2CZX1Uq+ac8rCNFRcYxaHvqIaWEiwT0WgOOESAwk00yIRPglBJBBoiBLBpJA+lUEcR2HEAu/rx689kkZ4AIjciKr3948ApxERY7dUpPnbwY7+YxrhF4h1KH4c/OT6X8v/dK2IM6K4kAH4UggVchyTWKggxNrnoUxixoSGhCmGQxkFEQ2FxJqCEpiDFEQH0MP7EPuPCdmWP6WRT0f7fwz7r41JkeDlpPdshJ8HtvSf4TjhIaaJH4cqUjoRiYgp0ERzLESY8MgPY6Gx5ComhOmARVIrLhj1ORYSf5//FwW7/h+lvo9H/T+G/rduXGaKFGVFZXme/4PLT/wS3hYwgc8gV87HS9FLdDEH1D5AqwoUus7yHAlAdg5IZ2Vl0XVm56gwiEuHskKm7DXyonmOFtzKeVZcous5t+iaV6hagsx0BgqJm3rIqoISmaL+/ezN+Qyhc+0w10Pd0wJBWZpyMm1flk4Qav9wk+/+urg2E4RKqMyqlPAOtCPndyNRxW8qZOdZhbKqnl5Z8hskVhZl1j0qgef5jWsxNY94jnQGuXKzqaoVoPe+n3x8Nbd2WaWnp5eZna/E2g9eQjHt3O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EhcC5LzBzPlbsx0kUUR36ERAGVJAgxnzn0LObc+daS1hHqhxzrQsr5JMuV8vI7HzTs8nUT1HLnF3O5kbyvMfZpsBjaClpw5JNeUmK7iqqaHquBVbP5j9zIx5LXJdQQJlJh/IOcT0KpbfPIabYFVVNW09Onb+1Lam6ZuJwSQ290H0+knoUSm9LygUPjiKpoUev5yOpR6F0j6T2hYvuF10Tn/9+9RpaW/x8hPYolB4gtG/r22ChDa2Efj5CexRKbwttb/10F7u/W3TuWDFoOxtF9yNE18XGf7T8huaXPh/VexRKD1O95gOm94tusNUcWsb/fET3KJR2omtvRg9z+tu790FqNrSM7/nI6lEo3SOrg9z+R5HV0JLr5yOrR6F0n6yewPEf+mWH5yO1R6H0EKkN8fzb4OA6Vrkj1AVY7pi09Z27FF3R8eLpKS+eRhhhhCeHrfvfoV/Y7NA+4P7X/f/vW///1Wdj/c9R6n++dP/Suy3VN+Ub92nU7/uM61N9GHX8LNT3fRZqW/8HRnk7tA/I/8CY4GhX/wM/GPX/GPp/Z2KXK5k6IP/r4tq4/K8exhGeE2zp/9DDXg/v4flf7t+/39r/CRvr/49S/39vvc+2Abi732gBnrEFGGGEEX5W+H8AAAD//wMAZi6+4gCMAAA=
  parameters:
    toiPackageExecutorParameterMapping:
      data: toiPackageExecutorParameterMapData
      fromCredentials:
        name: somehardcoded-username
        password: somehardcoded-password
      fromToiPackageConfigTemplate:
        data: toiPackageConfigTemplateData
        fromLibraryOne:
          data: toiPackageTemplateLibraryOneData
          fromLibrary2:
            data: toiPackageTemplateLibraryTwoData
        fromLibraryTwo:
          data: toiPackageTemplateLibraryTwoData
        fromParamsFromCLI:
          data: paramsFromCLIData
          fromLibraryOne:
            data: toiPackageTemplateLibraryOneData
            fromLibrary2:
              data: toiPackageTemplateLibraryTwoData
          fromLibraryTwo:
            data: toiPackageTemplateLibraryTwoData

@dee0
Copy link
Author

dee0 commented Jan 6, 2025

Hey @Skarlso

Thanks for the quick response! :)

I pulled down your change to apply CopyUIDGID and I got an error similar to what you mentioned here ( Btw, locally I am using podman --remote rather than docker daemon, hence the slight diff )

Locally, I tried backing out our change and putting in the one the below and that seemed to fix the problem. Basically in the loop I just make sure we don't try making a dir entry for either '/' or '.'. This should be safe since we shouldn't have any need to alter the permissions of any containers that are already existing in the container and those two at least should be pre-existing.

Image

@Skarlso
Copy link
Contributor

Skarlso commented Jan 7, 2025

Yah I was looking at that too. And did that fix your permission issue?

Just to be clear, I tried with latest OCM and NOT my PR because my pr was broken. :D And latest OCM worked with the output above.

Did I run the correct command?

Also, what is your ghcr.io/dee0/ocm/toi/helloworld:1.0.1?

For me, I just built the Dockerfile that you had there and pushed that and used it as is. Was that correct?

Skarlso added a commit to open-component-model/ocm that referenced this issue Jan 7, 2025
<!-- markdownlint-disable MD041 -->
#### What this PR does / why we need it

#### Which issue(s) this PR fixes

Related to
open-component-model/ocm-project#359

Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
@dee0sap
Copy link

dee0sap commented Jan 7, 2025

Hey @Skarlso

So with your PR I ran into the issue I you mentioned here

What I did after initially hitting that problem was :

  1. Backed out your change
  2. Reverted to my working docker image to make sure things could work
  3. Went back to my 'bad' image and tried reproducing the problem. I found that it failed differently. Instead of the permission denied error from before the error was from the docker client library and was about a failure to upgrade the http connection to the daemon. Also my output didn't get show up on my local filesystem. Checking the container contents I could see the problem with the root directory was still there.
  4. Put the change in my screenshot into place
  5. Re-tested with my 'bad' image, this time it worked

And of course in the meantime you put those changes in place. :)

Thanks!

@Skarlso
Copy link
Contributor

Skarlso commented Jan 7, 2025

So... It works now? 🤔

@dee0sap
Copy link

dee0sap commented Jan 7, 2025

Yep!

@Skarlso
Copy link
Contributor

Skarlso commented Jan 7, 2025

Nice yay 🎉👍🤩🍻

@Skarlso Skarlso closed this as completed Jan 8, 2025
@github-project-automation github-project-automation bot moved this from 🏗 In Progress to 🍺 Done in OCM Backlog Board Jan 8, 2025
@ocmbot ocmbot bot moved this from 🍺 Done to 🔒Closed in OCM Backlog Board Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ipcei Important Project of Common European Interest kind/bugfix Bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants