We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Reproducer
// +build linux package main import ( "fmt" "os" "strconv" "strings" "syscall" "github.com/godbus/dbus/v5" ) func main() { sudoUidStr := os.Getenv("SUDO_UID") sudoUid, sudoUiderr := strconv.Atoi(sudoUidStr) if sudoUiderr == nil { connectSessionDbus(sudoUid) return } xdgRuntimeDir := os.Getenv("XDG_RUNTIME_DIR") userUid, err := strconv.Atoi(strings.TrimPrefix(xdgRuntimeDir, "/run/user/")) if err != nil { fmt.Printf("neither SUDO_UID ('%s') nor XDG_RUNTIME_DIR ('%s') were set\n", sudoUidStr, xdgRuntimeDir) return } connectSessionDbus(userUid) } // to access another user's dbus session under root we need DBUS_SESSION_BUS_ADDRESS env var to be set and connect under user's uid // see https://stackoverflow.com/questions/6496847/access-another-users-d-bus-session func connectSessionDbus(userUid int) { err := syscall.Seteuid(userUid) if err != nil { fmt.Printf("syscall.Seteuid(%d): %v\n", userUid, err) return } fmt.Printf("syscall.Seteuid(%d): %v\n", userUid, err) // REMOVE _, err = dbus.SessionBus() if err != nil { fmt.Println("connect session dbus:", err) } err = syscall.Seteuid(0) if err != nil { fmt.Println("syscall.Seteuid(0):", err) } }
go build sudo ./test
Output:
syscall.Seteuid(1000): <nil> connect session dbus: dbus: authentication failed
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Reproducer
go build
sudo ./test
Output:
The text was updated successfully, but these errors were encountered: