aboutsummaryrefslogtreecommitdiffhomepage
path: root/dbus
diff options
context:
space:
mode:
Diffstat (limited to 'dbus')
-rw-r--r--dbus/dbus.go10
-rw-r--r--dbus/dbus_test.go20
-rw-r--r--dbus/export_test.go4
-rw-r--r--dbus/run.go2
4 files changed, 18 insertions, 18 deletions
diff --git a/dbus/dbus.go b/dbus/dbus.go
index b993d52d..775dfb5e 100644
--- a/dbus/dbus.go
+++ b/dbus/dbus.go
@@ -9,12 +9,16 @@ import (
"git.ophivana.moe/cat/fortify/helper"
)
+// ProxyName is the file name or path to the proxy program.
+// Overriding ProxyName will only affect Proxy instance created after the change.
+var ProxyName = "xdg-dbus-proxy"
+
// Proxy holds references to a xdg-dbus-proxy process, and should never be copied.
// Once sealed, configuration changes will no longer be possible and attempting to do so will result in a panic.
type Proxy struct {
helper helper.Helper
- path string
+ name string
session [2]string
system [2]string
@@ -75,6 +79,6 @@ func (p *Proxy) Seal(session, system *Config) error {
}
// New returns a reference to a new unsealed Proxy.
-func New(binPath string, session, system [2]string) *Proxy {
- return &Proxy{path: binPath, session: session, system: system}
+func New(session, system [2]string) *Proxy {
+ return &Proxy{name: ProxyName, session: session, system: system}
}
diff --git a/dbus/dbus_test.go b/dbus/dbus_test.go
index 098a2179..c20f9bef 100644
--- a/dbus/dbus_test.go
+++ b/dbus/dbus_test.go
@@ -9,10 +9,6 @@ import (
"git.ophivana.moe/cat/fortify/helper"
)
-const (
- binPath = "/usr/bin/bwrap"
-)
-
func TestNew(t *testing.T) {
for _, tc := range [][2][2]string{
{
@@ -33,9 +29,9 @@ func TestNew(t *testing.T) {
},
} {
t.Run("create instance for "+tc[0][0]+" and "+tc[1][0], func(t *testing.T) {
- if got := dbus.New(binPath, tc[0], tc[1]); !got.CompareTestNew(binPath, tc[0], tc[1]) {
- t.Errorf("New(%q, %q, %q) = %v",
- binPath, tc[0], tc[1],
+ if got := dbus.New(tc[0], tc[1]); !got.CompareTestNew(tc[0], tc[1]) {
+ t.Errorf("New(%q, %q) = %v",
+ tc[0], tc[1],
got)
}
})
@@ -52,12 +48,12 @@ func TestProxy_Seal(t *testing.T) {
}
}()
- p := dbus.New(binPath, [2]string{}, [2]string{})
+ p := dbus.New([2]string{}, [2]string{})
_ = p.Seal(dbus.NewConfig("", true, false), nil)
_ = p.Seal(dbus.NewConfig("", true, false), nil)
})
- ep := dbus.New(binPath, [2]string{}, [2]string{})
+ ep := dbus.New([2]string{}, [2]string{})
if err := ep.Seal(nil, nil); !errors.Is(err, dbus.ErrConfig) {
t.Errorf("Seal(nil, nil) error = %v, want %v",
err, dbus.ErrConfig)
@@ -65,7 +61,7 @@ func TestProxy_Seal(t *testing.T) {
for id, tc := range testCasePairs() {
t.Run("create seal for "+id, func(t *testing.T) {
- p := dbus.New(binPath, tc[0].bus, tc[1].bus)
+ p := dbus.New(tc[0].bus, tc[1].bus)
if err := p.Seal(tc[0].c, tc[1].c); (errors.Is(err, helper.ErrContainsNull)) != tc[0].wantErr {
t.Errorf("Seal(%p, %p) error = %v, wantErr %v",
tc[0].c, tc[1].c,
@@ -119,7 +115,7 @@ func TestProxy_Start_Wait_Close_String(t *testing.T) {
t.Run("proxy for "+id, func(t *testing.T) {
helper.InternalReplaceExecCommand(t)
- p := dbus.New(binPath, tc[0].bus, tc[1].bus)
+ p := dbus.New(tc[0].bus, tc[1].bus)
t.Run("unsealed behaviour of "+id, func(t *testing.T) {
t.Run("unsealed string of "+id, func(t *testing.T) {
@@ -164,7 +160,7 @@ func TestProxy_Start_Wait_Close_String(t *testing.T) {
}
t.Run("started string of "+id, func(t *testing.T) {
- wantSubstr := binPath + " --args=3"
+ wantSubstr := dbus.ProxyName + " --args=3"
if got := p.String(); !strings.Contains(got, wantSubstr) {
t.Errorf("String() = %v, want %v",
p.String(), wantSubstr)
diff --git a/dbus/export_test.go b/dbus/export_test.go
index dff02412..d42fde51 100644
--- a/dbus/export_test.go
+++ b/dbus/export_test.go
@@ -3,8 +3,8 @@ package dbus
import "io"
// CompareTestNew provides TestNew with comparison access to unexported Proxy fields.
-func (p *Proxy) CompareTestNew(path string, session, system [2]string) bool {
- return path == p.path && session == p.session && system == p.system
+func (p *Proxy) CompareTestNew(session, system [2]string) bool {
+ return session == p.session && system == p.system
}
// AccessTestProxySeal provides TestProxy_Seal with access to unexported Proxy seal field.
diff --git a/dbus/run.go b/dbus/run.go
index 5e489ba3..ac1c1619 100644
--- a/dbus/run.go
+++ b/dbus/run.go
@@ -18,7 +18,7 @@ func (p *Proxy) Start(ready chan error, output io.Writer) error {
return errors.New("proxy not sealed")
}
- h := helper.New(p.seal, p.path,
+ h := helper.New(p.seal, p.name,
func(argsFD, statFD int) []string {
if statFD == -1 {
return []string{"--args=" + strconv.Itoa(argsFD)}