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

quadlet: do not reject RemapUsers=keep-id as root #24306

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

Luap99
Copy link
Member

@Luap99 Luap99 commented Oct 17, 2024

This is simply wrong, as of commit de63ad7 --userns=keep-id is also
allowed as root.

Also enable quadlet test to run as root/rootless

Does this PR introduce a user-facing change?

None

This seems to be a testing gap, we need to test both for full coverage.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This is simply wrong, as of commit de63ad7 --userns=keep-id is also
allowed as root.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
@openshift-ci openshift-ci bot added release-note-none approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 17, 2024
@Luap99
Copy link
Member Author

Luap99 commented Oct 17, 2024

@ygalblum PTAL, I noticed this while working on #24305

Copy link
Contributor

@ygalblum ygalblum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Another example why Quadlet should not do input validation (unless it needs to manipulate it)

@baude
Copy link
Member

baude commented Oct 17, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 17, 2024
Copy link
Member

@edsantiago edsantiago left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one just-curious question

Comment on lines +663 to +667
var args []string
if isRootless() {
args = append(args, "--user")
}
args = append(args, "--no-kmsg-log", generatedDir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style question: why not args := []string{"--no-kmsg-log", generatedDir} (initialize first) followed by prepending --user if rootless?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because generatedDir is a argument and quadlet does not seem to accept options/flag after the args

$ bin/quadlet --dryrun --no-kmsg-log --user /tmp 
quadlet-generator[162564]: Loading source unit file /home/pholzing/.config/containers/systemd/t1.container
...
$ bin/quadlet --dryrun --no-kmsg-log /tmp --user
quadlet-generator[162630]: No files parsed from [/run/containers/systemd /etc/containers/systemd /usr/share/containers/systemd]

The --user is ignored but I haven't looked into why, the systemd generator has a forced syntax defined by systemd so I just accepted it without thinking to long about it.

Copy link
Contributor

@ygalblum ygalblum Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW podman also has assumptions about the order between options and arguments - all options must come first, then the first argument being the image and everything after it goes into the command. So, maybe it's a cobra thing.
Having said that, as @edsantiago wrote, the --user parameter can be prepended. Not that critical I guess

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW podman also has assumptions about the order between options and arguments - all options must come first, then the first argument being the image and everything after it goes into the command. So, maybe it's a cobra thing.

quadlet does not use cobra, it used the std flag package. In cobra you control that via flags.SetInterspersed(true/false) and yes a command like podman run $IMAGE treats all options after $IMAGE as args to the container command but in other commands it is fine to mix them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't remember that. I guess the different package is the reason.
Also, AFAIK systemd does not pass any options only parameters. Quadlet uses argv[0] to set isUser (though it should do that using an environment variable). So, the options are only for debugging and testing

Copy link
Contributor

openshift-ci bot commented Oct 17, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: edsantiago, Luap99, ygalblum

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [Luap99,edsantiago,ygalblum]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 740f1d1 into containers:main Oct 17, 2024
75 of 78 checks passed
@Luap99 Luap99 deleted the quadlet-root-test branch October 17, 2024 14:28
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Input validation can really hurt. I ran into one in Quay (see https://issues.redhat.com/browse/PROJQUAY-8115). Maybe we can audit the code some time soon and look for similar cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants