File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -83,9 +83,19 @@ type Conn struct {
8383 }
8484}
8585
86- // New establishes a connection to the system bus and authenticates.
86+ // New establishes a connection to any available bus and authenticates.
8787// Callers should call Close() when done with the connection.
8888func New () (* Conn , error ) {
89+ conn , err := NewSystemConnection ()
90+ if err != nil && os .Geteuid () == 0 {
91+ return NewSystemdConnection ()
92+ }
93+ return conn , err
94+ }
95+
96+ // NewSystemConnection establishes a connection to the system bus and authenticates.
97+ // Callers should call Close() when done with the connection
98+ func NewSystemConnection () (* Conn , error ) {
8999 return NewConnection (func () (* dbus.Conn , error ) {
90100 return dbusAuthHelloConnection (dbus .SystemBusPrivate )
91101 })
You can’t perform that action at this time.
0 commit comments