Files
troubleshoot/cmd/collect/cli/chroot_darwin.go
Ash c968fca125 Allow collect to chroot itself (#1658)
* Enable chroot

* typo

* platform specific chroot functions

* Add friendly chroot warning if running without elevated permissions
2024-10-22 17:06:07 +01:00

22 lines
352 B
Go

package cli
import (
"errors"
"syscall"
"github.com/replicatedhq/troubleshoot/internal/util"
)
func checkAndSetChroot(newroot string) error {
if newroot == "" {
return nil
}
if !util.IsRunningAsRoot() {
return errors.New("Can only chroot when run as root")
}
if err := syscall.Chroot(newroot); err != nil {
return err
}
return nil
}