-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Eval symlinks on XDG_RUNTIME_DIR #15918
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,7 +129,11 @@ func dbusAuthRootlessConnection(createBus func(opts ...godbus.ConnOption) (*godb | |
func newRootlessConnection() (*dbus.Conn, error) { | ||
return dbus.NewConnection(func() (*godbus.Conn, error) { | ||
return dbusAuthRootlessConnection(func(opts ...godbus.ConnOption) (*godbus.Conn, error) { | ||
path := filepath.Join(os.Getenv("XDG_RUNTIME_DIR"), "systemd/private") | ||
path := filepath.Join(os.Getenv("XDG_RUNTIME_DIR"), "systemd", "private") | ||
path, err := filepath.EvalSymlinks(path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And, like above, I think you need an existence check before you There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would the check do if it does not exists? Still call If the file does not exists EvalSymlinks will return that it does not exists. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know enough about this
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the old code will barf when godbus.Dial attempts to connect to a non existing socket |
||
if err != nil { | ||
return nil, err | ||
} | ||
return godbus.Dial(fmt.Sprintf("unix:path=%s", path)) | ||
}) | ||
}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,12 @@ func GetRuntimeDir() (string, error) { | |
|
||
rootlessRuntimeDirOnce.Do(func() { | ||
runtimeDir := os.Getenv("XDG_RUNTIME_DIR") | ||
|
||
if runtimeDir != "" { | ||
rootlessRuntimeDir, rootlessRuntimeDirError = filepath.EvalSymlinks(runtimeDir) | ||
return | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kind of made me nervous to return early, but AFAICT it's perfectly fine, no code paths are affected, and this actually seems cleaner. PR LGTM but this has too many ramifications for me. |
||
} | ||
|
||
uid := fmt.Sprintf("%d", rootless.GetRootlessUID()) | ||
if runtimeDir == "" { | ||
tmpDir := filepath.Join("/run", "user", uid) | ||
|
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.
Again, I think this is misleading because
XDG
is always, always going to be set very early on byconfig
code.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.
There is no change here if XDG_RUNTIME_DIR is not set or is set to "", Current code would not fail if XDG_RUNTIME_DIR=="" new code would, so I add his check.