Compare commits
6 Commits
683b7f0c3e
...
fba87b0c39
Author | SHA1 | Date | |
---|---|---|---|
fba87b0c39 | |||
cdfc23700f | |||
b956ce4052 | |||
dc579dc610 | |||
ade57c39af | |||
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 {
|
||||||
@ -91,6 +93,9 @@ func (p *Proxy) Start(ready chan error, output io.Writer, sandbox bool) error {
|
|||||||
if path.IsAbs(ent.Path) {
|
if path.IsAbs(ent.Path) {
|
||||||
roBindTarget[path.Dir(ent.Path)] = struct{}{}
|
roBindTarget[path.Dir(ent.Path)] = struct{}{}
|
||||||
}
|
}
|
||||||
|
if path.IsAbs(ent.Name) {
|
||||||
|
roBindTarget[path.Dir(ent.Name)] = struct{}{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolve upstream bus directories
|
// resolve upstream bus directories
|
||||||
|
@ -32,7 +32,7 @@ func Parse(stdout fmt.Stringer) ([]*Entry, error) {
|
|||||||
switch len(segment) {
|
switch len(segment) {
|
||||||
case 2: // /lib/ld-musl-x86_64.so.1 (0x7f04d14ef000)
|
case 2: // /lib/ld-musl-x86_64.so.1 (0x7f04d14ef000)
|
||||||
iL = 1
|
iL = 1
|
||||||
result[i] = &Entry{Name: segment[0]}
|
result[i] = &Entry{Name: strings.TrimSpace(segment[0])}
|
||||||
case 4: // libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f04d14ef000)
|
case 4: // libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f04d14ef000)
|
||||||
iL = 3
|
iL = 3
|
||||||
if segment[1] != "=>" {
|
if segment[1] != "=>" {
|
||||||
@ -42,7 +42,7 @@ func Parse(stdout fmt.Stringer) ([]*Entry, error) {
|
|||||||
return nil, ErrPathNotAbsolute
|
return nil, ErrPathNotAbsolute
|
||||||
}
|
}
|
||||||
result[i] = &Entry{
|
result[i] = &Entry{
|
||||||
Name: segment[0],
|
Name: strings.TrimSpace(segment[0]),
|
||||||
Path: segment[2],
|
Path: segment[2],
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -65,12 +65,12 @@ libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7ff71c0a4000)`,
|
|||||||
{"libc.musl-x86_64.so.1", "/lib/ld-musl-x86_64.so.1", 0x7ff71c0a4000},
|
{"libc.musl-x86_64.so.1", "/lib/ld-musl-x86_64.so.1", 0x7ff71c0a4000},
|
||||||
}},
|
}},
|
||||||
{"glibc /nix/store/rc3n2r3nffpib2gqpxlkjx36frw6n34z-kmod-31/bin/kmod", `
|
{"glibc /nix/store/rc3n2r3nffpib2gqpxlkjx36frw6n34z-kmod-31/bin/kmod", `
|
||||||
linux-vdso.so.1 (0x00007ffed65be000)
|
linux-vdso.so.1 (0x00007ffed65be000)
|
||||||
libzstd.so.1 => /nix/store/80pxmvb9q43kh9rkjagc4h41vf6dh1y6-zstd-1.5.6/lib/libzstd.so.1 (0x00007f3199cd1000)
|
libzstd.so.1 => /nix/store/80pxmvb9q43kh9rkjagc4h41vf6dh1y6-zstd-1.5.6/lib/libzstd.so.1 (0x00007f3199cd1000)
|
||||||
liblzma.so.5 => /nix/store/g78jna1i5qhh8gqs4mr64648f0szqgw4-xz-5.4.7/lib/liblzma.so.5 (0x00007f3199ca2000)
|
liblzma.so.5 => /nix/store/g78jna1i5qhh8gqs4mr64648f0szqgw4-xz-5.4.7/lib/liblzma.so.5 (0x00007f3199ca2000)
|
||||||
libc.so.6 => /nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib/libc.so.6 (0x00007f3199ab5000)
|
libc.so.6 => /nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib/libc.so.6 (0x00007f3199ab5000)
|
||||||
libpthread.so.0 => /nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib/libpthread.so.0 (0x00007f3199ab0000)
|
libpthread.so.0 => /nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib/libpthread.so.0 (0x00007f3199ab0000)
|
||||||
/nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib/ld-linux-x86-64.so.2 => /nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib64/ld-linux-x86-64.so.2 (0x00007f3199da5000)`,
|
/nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib/ld-linux-x86-64.so.2 => /nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib64/ld-linux-x86-64.so.2 (0x00007f3199da5000)`,
|
||||||
[]*ldd.Entry{
|
[]*ldd.Entry{
|
||||||
{"linux-vdso.so.1", "", 0x00007ffed65be000},
|
{"linux-vdso.so.1", "", 0x00007ffed65be000},
|
||||||
{"libzstd.so.1", "/nix/store/80pxmvb9q43kh9rkjagc4h41vf6dh1y6-zstd-1.5.6/lib/libzstd.so.1", 0x00007f3199cd1000},
|
{"libzstd.so.1", "/nix/store/80pxmvb9q43kh9rkjagc4h41vf6dh1y6-zstd-1.5.6/lib/libzstd.so.1", 0x00007f3199cd1000},
|
||||||
@ -79,6 +79,35 @@ libpthread.so.0 => /nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib
|
|||||||
{"libpthread.so.0", "/nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib/libpthread.so.0", 0x00007f3199ab0000},
|
{"libpthread.so.0", "/nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib/libpthread.so.0", 0x00007f3199ab0000},
|
||||||
{"/nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib/ld-linux-x86-64.so.2", "/nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib64/ld-linux-x86-64.so.2", 0x00007f3199da5000},
|
{"/nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib/ld-linux-x86-64.so.2", "/nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib64/ld-linux-x86-64.so.2", 0x00007f3199da5000},
|
||||||
}},
|
}},
|
||||||
|
{"glibc /usr/bin/xdg-dbus-proxy", `
|
||||||
|
linux-vdso.so.1 (0x00007725f5772000)
|
||||||
|
libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x00007725f55d5000)
|
||||||
|
libgio-2.0.so.0 => /usr/lib/libgio-2.0.so.0 (0x00007725f5406000)
|
||||||
|
libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0x00007725f53a6000)
|
||||||
|
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007725f5378000)
|
||||||
|
libc.so.6 => /usr/lib/libc.so.6 (0x00007725f5187000)
|
||||||
|
libpcre2-8.so.0 => /usr/lib/libpcre2-8.so.0 (0x00007725f50e8000)
|
||||||
|
libgmodule-2.0.so.0 => /usr/lib/libgmodule-2.0.so.0 (0x00007725f50df000)
|
||||||
|
libz.so.1 => /usr/lib/libz.so.1 (0x00007725f50c6000)
|
||||||
|
libmount.so.1 => /usr/lib/libmount.so.1 (0x00007725f5076000)
|
||||||
|
libffi.so.8 => /usr/lib/libffi.so.8 (0x00007725f506b000)
|
||||||
|
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007725f5774000)
|
||||||
|
libblkid.so.1 => /usr/lib/libblkid.so.1 (0x00007725f5032000)`,
|
||||||
|
[]*ldd.Entry{
|
||||||
|
{"linux-vdso.so.1", "", 0x00007725f5772000},
|
||||||
|
{"libglib-2.0.so.0", "/usr/lib/libglib-2.0.so.0", 0x00007725f55d5000},
|
||||||
|
{"libgio-2.0.so.0", "/usr/lib/libgio-2.0.so.0", 0x00007725f5406000},
|
||||||
|
{"libgobject-2.0.so.0", "/usr/lib/libgobject-2.0.so.0", 0x00007725f53a6000},
|
||||||
|
{"libgcc_s.so.1", "/usr/lib/libgcc_s.so.1", 0x00007725f5378000},
|
||||||
|
{"libc.so.6", "/usr/lib/libc.so.6", 0x00007725f5187000},
|
||||||
|
{"libpcre2-8.so.0", "/usr/lib/libpcre2-8.so.0", 0x00007725f50e8000},
|
||||||
|
{"libgmodule-2.0.so.0", "/usr/lib/libgmodule-2.0.so.0", 0x00007725f50df000},
|
||||||
|
{"libz.so.1", "/usr/lib/libz.so.1", 0x00007725f50c6000},
|
||||||
|
{"libmount.so.1", "/usr/lib/libmount.so.1", 0x00007725f5076000},
|
||||||
|
{"libffi.so.8", "/usr/lib/libffi.so.8", 0x00007725f506b000},
|
||||||
|
{"/lib64/ld-linux-x86-64.so.2", "/usr/lib64/ld-linux-x86-64.so.2", 0x00007725f5774000},
|
||||||
|
{"libblkid.so.1", "/usr/lib/libblkid.so.1", 0x00007725f5032000},
|
||||||
|
}},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.file, func(t *testing.T) {
|
t.Run(tc.file, func(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user