mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-02-14 18:29:53 +00:00
* Enable chroot * typo * platform specific chroot functions * Add friendly chroot warning if running without elevated permissions
22 lines
352 B
Go
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
|
|
}
|