-
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
runtime: Warn if XDG_RUNTIME_DIR
is set but is not writable.
#11327
runtime: Warn if XDG_RUNTIME_DIR
is set but is not writable.
#11327
Conversation
We will have to see if tests are unhappy with this warning. |
7ed6953
to
a29273c
Compare
a29273c
to
52ceb27
Compare
libpod/runtime.go
Outdated
// if current user has no write access to XDG_RUNTIME_DIR we will fail later | ||
if runtimeDir != "" { | ||
if unix.Access(runtimeDir, unix.W_OK) != nil { | ||
logrus.Warnf("Required login session. Note: For su or sudo try `su -i | sudo -l") |
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.
su -i
or sudo -l
do not create a systemd session for the user. Only ssh
or machinectl
do.
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.
Yes but they do create enough of a session that podman will work, I believe.
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.
This PR adds a warning if XDG_RUNTIME_DIR is set but not writeable, telling the user to use su -i
or sudo -l
does not make XDG_RUNTIME_DIR writeable because systemd still doesn't create a session for the user.
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.
@Luap99 I sort of agree i think user must do loginctl
or by any means create a session
before performing any su
commands. I think we cannot make su
work at all without patching su
as it doesn't really cares about systemd
session.
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 am not really sure about this. Should we just change warning to Note: su or sudo with -c might not work
or we can fall back to tmpdir
but pretty sure it will fail later somewhere especially for cgroupv2
in case of falling back to tmpdir
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 think it should just warn about XDG_RUNTIME_DIR
not being writable.
The user could have a valid session but the XDG_RUNTIME_DIR
has the wrong value.
I think we should not suggest what the fix is. It should be enough to say the directory is not writable |
Check is in the wrong place, should be moved to after https://github.com/containers/podman/blob/52ceb273c04854efca34a90231a4db45deabc471/libpod/runtime.go#L340 Basically, at this point, we're determining what the runtime directory should be for a new installation. If a runtime directory has already been chosen, whatever we choose here will be overwritten by the DB at this point. So we could be warning that |
@mheon Would it be better if we check everytime a user namespace is created ? |
We will not have the correct directories at that point. We need to check once we have the final rundir nailed down, and the line I linked is when that happens. |
52ceb27
to
ce0834d
Compare
ce0834d
to
39cc5c8
Compare
libpod/runtime.go
Outdated
// it will try to use existing XDG_RUNTIME_DIR | ||
// if current user has no write access to XDG_RUNTIME_DIR we will fail later | ||
if unix.Access(runtime.storageConfig.RunRoot, unix.W_OK) != nil { | ||
logrus.Warnf("XDG_RUNTIME_DIR is pointing to a path which is not writable. Most likely podman will fail.") |
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.
Suggest changing "XDG_RUNTIME_DIR" to "Temporary files directory"
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 think only actionable from user's side which user can take if this warning shows up is to debug using XDG_RUNTIME_DIR
, "Temporary files directory" might not pass enough context to user WDYT ?
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.
Why, users will have no idea what that means? I think we should make this smarter to at lease check if XDG_RUNTIME_DIR is set and report it in that case.
Can we update the podman run and podman start man pages with information about loginctl, so users have a chance to figure this out.
This is too common an error for us to keep getting issues and bugzillas. Users need to have a clue on how to fix this without having to talk to Support.
Eventually this becomes a costly support issue for RHEL.
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.
Printing the directory path seems reasonable to me.
@rhatdan On v1 systems it is perfectly possible to get Podman running without a login session, and a lot of people are doing it unintentionally by running for the first time under sudo
or su
without a proper login session. We can't start throwing warnings about perfectly-working configurations - we should only check XDG_RUNTIME_DIR if we are actually using it.
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.
Does this mean a user with XDG_RUNTIME_DIR set to an unwritable directory, podman will work in V1? If yes, then we should add a check for cgroupv2.
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.
How about we add something like this into man pages
Note: Podman expects a valid login session for `rootless` use-case, In most cases podman will figure out solution on
its own but if `XDG_RUNTIME_DIR` is pointing to path which is not writable most likely execution will fail. In such cases `rootless` user needs a valid systemd session.
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.
Since the three most common cases for this are
1 su
2 sudo
3 systemd unit files, we should document all three.
XDG_RUNTIME_DIR is just a side effect. The problem is people logging in as root and then lauching rootless containers by switching to a rootless user. In the case of XDG_RUNTIME_DIR being set incorrectly, the problem is that su (and maybe sudo) do not clean the environment when you change users, therefore rootless podman attempts to use roots XDG_RUNTIME_DIR.
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.
Added a check for cgroupv2
and updated docs. Will add into start man
page as well if note looks fine.
63c10b1
to
667e2cb
Compare
@baude @ashley-cui Is the use of golang.org/x/sys/unix here going to cause issues for remote? I know we usually use os.Stat() and test for os.IsExist() |
The libpod package should never be imported on the remote client so this is fine. |
667e2cb
to
16f6ef9
Compare
[NO TESTS NEEDED] Signed-off-by: Aditya Rajan <[email protected]>
16f6ef9
to
9b7ef3d
Compare
@giuseppe @Luap99 @mheon @rhatdan @TomSweeneyRedHat Moved resolution guide to troubleshooting page, could you all please take a look. |
// If user is rootless and XDG_RUNTIME_DIR is found, podman will not proceed with /tmp directory | ||
// it will try to use existing XDG_RUNTIME_DIR | ||
// if current user has no write access to XDG_RUNTIME_DIR we will fail later | ||
if unix.Access(runtime.storageConfig.RunRoot, unix.W_OK) != nil { |
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 am not sure this is the right place for the check.
runtime.storageConfig.RunRoot
could have been set for a different reason than XDG_RUNTIME_DIR
being specified.
Would it work if we have it in SetXdgDirs
for the case where os.Getenv("XDG_RUNTIME_DIR") != ""
?
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.
@giuseppe first version of PR had check exactly where you suggested, moved it after @mheon suggestion reason is added in the comment itself #11327 (comment)
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.
This seems more sane - there's no guarantee Podman is actually using XDG_RUNTIME_DIR (we can fall back to other directories). This guarantees that we are checking whatever the currently-configured temporary files directory is.
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 clarification. It makes sense.
/assign @mheon |
assigning @mheon for review since he is already writing stuff on this. |
LGTM |
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: flouthoc, rhatdan 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 |
If user is
rootless
andXDG_RUNTIME_DIR
is found, podman will not proceed with/tmp
directory it will try to use existingXDG_RUNTIME_DIR
and if current user has no write access toXDG_RUNTIME_DIR
podman session will fail later