dbus: fail on LookPath error
An absolute path to xdg-dbus-proxy is required. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
831dc6a181
commit
614ad86a5b
@ -124,6 +124,8 @@ func testProxyStartWaitCloseString(t *testing.T, sandbox bool) {
|
|||||||
|
|
||||||
t.Run("proxy for "+id, func(t *testing.T) {
|
t.Run("proxy for "+id, func(t *testing.T) {
|
||||||
helper.InternalReplaceExecCommand(t)
|
helper.InternalReplaceExecCommand(t)
|
||||||
|
overridePath(t)
|
||||||
|
|
||||||
p := dbus.New(tc[0].bus, tc[1].bus)
|
p := dbus.New(tc[0].bus, tc[1].bus)
|
||||||
output := new(strings.Builder)
|
output := new(strings.Builder)
|
||||||
|
|
||||||
@ -174,7 +176,7 @@ func testProxyStartWaitCloseString(t *testing.T, sandbox bool) {
|
|||||||
|
|
||||||
t.Run("sealed start of "+id, func(t *testing.T) {
|
t.Run("sealed start of "+id, func(t *testing.T) {
|
||||||
if err := p.Start(nil, output, sandbox); err != nil {
|
if err := p.Start(nil, output, sandbox); err != nil {
|
||||||
t.Errorf("Start(nil, nil) error = %v",
|
t.Fatalf("Start(nil, nil) error = %v",
|
||||||
err)
|
err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,3 +215,11 @@ func testProxyStartWaitCloseString(t *testing.T, sandbox bool) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func overridePath(t *testing.T) {
|
||||||
|
proxyName := dbus.ProxyName
|
||||||
|
dbus.ProxyName = "/nonexistent-xdg-dbus-proxy"
|
||||||
|
t.Cleanup(func() {
|
||||||
|
dbus.ProxyName = proxyName
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -46,14 +46,16 @@ func (p *Proxy) Start(ready chan error, output io.Writer, sandbox bool) error {
|
|||||||
// look up absolute path if name is just a file name
|
// look up absolute path if name is just a file name
|
||||||
toolPath := p.name
|
toolPath := p.name
|
||||||
if filepath.Base(p.name) == p.name {
|
if filepath.Base(p.name) == p.name {
|
||||||
if s, err := exec.LookPath(p.name); err == nil {
|
if s, err := exec.LookPath(p.name); err != nil {
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
toolPath = s
|
toolPath = s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolve libraries by parsing ldd output
|
// resolve libraries by parsing ldd output
|
||||||
var proxyDeps []*ldd.Entry
|
var proxyDeps []*ldd.Entry
|
||||||
if path.IsAbs(toolPath) {
|
if toolPath != "/nonexistent-xdg-dbus-proxy" {
|
||||||
if l, err := ldd.Exec(toolPath); err != nil {
|
if l, err := ldd.Exec(toolPath); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user