fakechroot icon indicating copy to clipboard operation
fakechroot copied to clipboard

Q: Is it Possible to use fakechroot/fakeroot-ng with Golang Binaries

Open munagekar opened this issue 4 years ago • 4 comments

Golang uses syscalls directly and does not use glibc.

I was trying to get syncthing to work inside a fakechroot. However it fails with /usr/bin/syncthing not in path. It is in path, however since it uses syscalls directly, it does not work. This error is similar to https://github.com/dex4er/fakechroot/issues/67.

Is it possible to use fakeroot-ng with fakechroot ? I checked the documentation for fakechroot but couldn't find the use of fakeroot-ng ?

munagekar avatar Jan 26 '21 06:01 munagekar

Stack trace with Syncthing

root@abi-0:/# syncthing
[monitor] 06:56:57 INFO: Default folder created and/or linked to new config
[monitor] 06:56:57 WARNING: Error starting the main Syncthing process: exec: "syncthing": executable file not found in $PATH
panic: Error starting the main Syncthing process

goroutine 1 [running]:
main.monitorMain(0xc000156930, 0x22, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        github.com/syncthing/syncthing/cmd/syncthing/monitor.go:125 +0x14f3
main.main()
        github.com/syncthing/syncthing/cmd/syncthing/main.go:442 +0x3f8

goroutine 33 [chan receive]:
github.com/syncthing/notify.(*nonrecursiveTree).dispatch(0xc00012c300, 0xc00012c240)
        github.com/syncthing/[email protected]/tree_nonrecursive.go:36 +0xb6
created by github.com/syncthing/notify.newNonrecursiveTree
        github.com/syncthing/[email protected]/tree_nonrecursive.go:29 +0xe5

goroutine 34 [chan receive]:
github.com/syncthing/notify.(*nonrecursiveTree).internal(0xc00012c300, 0xc00012c2a0)
        github.com/syncthing/[email protected]/tree_nonrecursive.go:81 +0x58
created by github.com/syncthing/notify.newNonrecursiveTree
        github.com/syncthing/[email protected]/tree_nonrecursive.go:30 +0x111

goroutine 35 [sleep]:
time.Sleep(0x1dcd6500)
        runtime/time.go:188 +0xbf
github.com/syncthing/syncthing/lib/dialer.init.1.func2()
        github.com/syncthing/syncthing/lib/dialer/internal.go:44 +0x2a
created by github.com/syncthing/syncthing/lib/dialer.init.1
        github.com/syncthing/syncthing/lib/dialer/internal.go:43 +0x15f

goroutine 5 [syscall]:
os/signal.signal_recv(0x0)
        runtime/sigqueue.go:147 +0x9d
os/signal.loop()
        os/signal/signal_unix.go:23 +0x25
created by os/signal.Notify.func1.1
        os/signal/signal.go:150 +0x45
root@abi-0:/# 

munagekar avatar Jan 26 '21 06:01 munagekar

goalng does not completely use glibc?

JasonYangShadow avatar Nov 13 '21 09:11 JasonYangShadow

Usually it does not use glibc. In my understanding you can get it to use glibc/musl by explicitly setting CGO_ENABLED=1, which is usually not done, to support cross-platform compilation.

munagekar avatar Nov 13 '21 10:11 munagekar

yes, if golang binaries are compiled with glibc and not statical linked. then LD_PRELOAD can work

JasonYangShadow avatar Nov 13 '21 11:11 JasonYangShadow