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

rootless: set DBUS_SESSION_BUS_ADDRESS if it is not set #4166

Conversation

giuseppe
Copy link
Member

@giuseppe giuseppe commented Oct 1, 2019

if the variable is not set, make sure it has a sane value so that
go-dbus won't try to connect to the wrong user session.

Closes: #4162
Closes: #4164

Signed-off-by: Giuseppe Scrivano [email protected]

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 1, 2019
@giuseppe
Copy link
Member Author

giuseppe commented Oct 1, 2019

/cc @edsantiago @mheon @baude

@mheon
Copy link
Member

mheon commented Oct 1, 2019

LGTM

@@ -387,6 +387,12 @@ func SetXdgDirs() error {
return errors.Wrapf(err, "cannot set XDG_RUNTIME_DIR")
}

if rootless.IsRootless() && os.Getenv("DBUS_SESSION_BUS_ADDRESS") == "" {
if _, err := os.Stat(fmt.Sprintf("/run/user/%d/bus", rootless.GetRootlessUID())); err == nil {
os.Setenv("DBUS_SESSION_BUS_ADDRESS", fmt.Sprintf("unix:path=/run/user/%d/bus", rootless.GetRootlessUID()))
Copy link
Member

Choose a reason for hiding this comment

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

Duplication bothers me; would you mind declaring a local var to hold /run/user/etc ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've fixed it in the last commit. I've also dropped the /run/user/%d part as we already have runtimeDir

Copy link
Member

Choose a reason for hiding this comment

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

Let's fix this and then we can merge

buspath:=fmt.Sprintf("/run/user/%d/bus", rootless.GetRootlessUID()
if _, err := os.Stat(buspath); err := nil {
 			os.Setenv("DBUS_SESSION_BUS_ADDRESS",  fmt.Sprintf("unix:path=%s", buspath) 
}

@edsantiago
Copy link
Member

I don't see how this closes either of those bugs. I tried manually setting that envariable, and system tests fail in exactly the same way:

$ export DBUS_SESSION_BUS_ADDRESS=/run/user/1000/bus
$ ll $DBUS_SESSION_BUS_ADDRESS
srw-rw-rw-. 1 fedora fedora 0 Oct  1 17:29 /run/user/1000/bus
$ bats /usr/share/podman/test/system/
...
same failures in podman exec and podman pod create

I no longer see the warnings about /run/user/0 with log-level=debug, but aside from that there's no difference.

IOW: this looks like a fine addition but please do not close 4162 or 4164.

@edsantiago
Copy link
Member

NEVER MIND! My mistake: I missed the unix:path= prefix. With that, all tests pass. (This is all the more reason to fix the duplication: it will make the prefix more obvious)

Thank you for addressing this so quickly.

@TomSweeneyRedHat
Copy link
Member

LGTM other than @edsantiago duplication comment.

if the variable is not set, make sure it has a sane value so that
go-dbus won't try to connect to the wrong user session.

Closes: containers#4162
Closes: containers#4164

Signed-off-by: Giuseppe Scrivano <[email protected]>
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

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 2, 2019
@openshift-merge-robot openshift-merge-robot merged commit 32a2ce8 into containers:master Oct 2, 2019
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
8 participants