-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow
collect
to chroot itself (#1658)
* Enable chroot * typo * platform specific chroot functions * Add friendly chroot warning if running without elevated permissions
- Loading branch information
1 parent
0fb0a07
commit c968fca
Showing
4 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package cli | ||
|
||
import ( | ||
"errors" | ||
) | ||
|
||
func checkAndSetChroot(newroot string) error { | ||
return errors.New("chroot is only implimented in linux/darwin") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters