-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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: Fix userLevelFilter
when UnitDirAdmin
is a symlink
#23498
Quadlet: Fix userLevelFilter
when UnitDirAdmin
is a symlink
#23498
Conversation
Please fix your commit message. |
848b41e
to
b4a7d0c
Compare
Additionally, I found that a similar situation exists in |
Ephemeral COPR build failed. @containers/packit-build please check. |
cmd/quadlet/main.go
Outdated
@@ -183,9 +180,16 @@ func appendSubPaths(dirs []string, path string, isUserFlag bool, filterPtr func( | |||
} | |||
|
|||
func nonNumericFilter(_path string, isUserFlag bool) bool { | |||
UnitDirAdminUser := filepath.Join(quadlet.UnitDirAdmin, "users") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing something here, but can't this code (and the one in userLevelFilter
) be executed once somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I wasn't clear on my first comment. I wonder if we can compute UnitDirAdminUser
and resolvedUnitDirAdmin
once instead of every time the filter function is called.
29599bf
to
a7f3831
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR.
As you may have noticed, you will also need to add some sort of a test to make sure the functionality works and not less more importantly does not break in future PRs
cmd/quadlet/main.go
Outdated
@@ -183,9 +180,16 @@ func appendSubPaths(dirs []string, path string, isUserFlag bool, filterPtr func( | |||
} | |||
|
|||
func nonNumericFilter(_path string, isUserFlag bool) bool { | |||
UnitDirAdminUser := filepath.Join(quadlet.UnitDirAdmin, "users") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I wasn't clear on my first comment. I wonder if we can compute UnitDirAdminUser
and resolvedUnitDirAdmin
once instead of every time the filter function is called.
88b0e58
to
209f1cd
Compare
podman/cmd/quadlet/main_test.go Lines 102 to 104 in 0bd43f4
In the original test for symlinks, because the env is set to actualDir , the test result will always pass. Fixed.https://github.com/containers/podman/blob/209f1cd9c08c248678d6a73166f1d05bcfb1eeb7/cmd/quadlet/main_test.go#L116 |
cmd/quadlet/main.go
Outdated
@@ -59,6 +55,12 @@ var ( | |||
} | |||
) | |||
|
|||
var ( | |||
UnitDirAdminUser string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the nit. But, is there a reason why UnitDirAdminUser
and SystemUserDirLevel
are exposed and resolvedUnitDirAdminUser
isn't? Are they used outside of the module?
209f1cd
to
0304b30
Compare
It looks like my test fails in |
Yes this package should only be compiled on Linux (Really for systemd based systems.) |
7f2d946
to
f9b79fc
Compare
f9b79fc
to
e159a02
Compare
@rhatdan I have already answered. Actually all three variables are exposed, I don't understand why @ygalblum says test works without privilege now. |
He wants you to change:
to
|
e159a02
to
53c8d63
Compare
@rhatdan Sorry, I misunderstood. |
LGTM |
53c8d63
to
c0a4f0d
Compare
test with coverage works now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lelemka0, 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:
Approvers can indicate their approval by writing |
@lelemka0 sorry for not being clear. Please rebase you branch, it should fix the test failures |
c0a4f0d
to
79adafa
Compare
Rootless units placed in `users` would be loaded for root when `/etc/containers/systemd` is a symlink. In this case, since `UnitDirAdmin` is hardcoded, `userLevelFilter` always returns `true`. If `/etc/containers/systemd/users` is a symlink, any user would load other users' units. Fix the above two problems. Fixes: containers#23483 Signed-off-by: Uzinn Kagurazaka <[email protected]>
79adafa
to
b0948a5
Compare
/lgtm |
Problem
Rootless unit placed in
/etc/containers/systemd/users/$(UID)
will be loaded for root when/etc/containers/systemd
is a symlink.Fix: #23483
Fix
Try evaluate the path of
UnitDirAdmin
as a symbolic link.Does this PR introduce a user-facing change?