dex4er / fakechroot

gives a fake chroot environment
GNU Lesser General Public License v2.1
295 stars 73 forks source link

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

Open munagekar opened 3 years ago

munagekar commented 3 years ago

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 commented 3 years ago
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/notify@v0.0.0-20201109091751-9a0e44181151/tree_nonrecursive.go:36 +0xb6 created by github.com/syncthing/notify.newNonrecursiveTree github.com/syncthing/notify@v0.0.0-20201109091751-9a0e44181151/tree_nonrecursive.go:29 +0xe5 goroutine 34 [chan receive]: github.com/syncthing/notify.(*nonrecursiveTree).internal(0xc00012c300, 0xc00012c2a0) github.com/syncthing/notify@v0.0.0-20201109091751-9a0e44181151/tree_nonrecursive.go:81 +0x58 created by github.com/syncthing/notify.newNonrecursiveTree github.com/syncthing/notify@v0.0.0-20201109091751-9a0e44181151/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:/# ```

JasonYangShadow commented 3 years ago

goalng does not completely use glibc?

munagekar commented 3 years ago

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.

JasonYangShadow commented 3 years ago

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