Add creation of basejail (jail based on template, system in readonly, nullfs binded)
This commit is contained in:
25
cmd/utils.go
25
cmd/utils.go
@ -790,9 +790,20 @@ func doZfsDatasetExist(dataset string) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// Create ZFS dataset. mountpoint can be "none", then the dataset won't be mounted
|
||||
/* Create ZFS dataset
|
||||
* mountpoint can be "none", then the dataset won't be mounted
|
||||
* mountpoint can be "", then it will be inherited
|
||||
* compression can be "", then it wil be inherited
|
||||
*/
|
||||
func zfsCreateDataset(dataset, mountpoint, compression string) error {
|
||||
cmd := fmt.Sprintf("zfs create -o mountpoint=%s -o compression=%s %s", mountpoint, compression, dataset)
|
||||
cmd := "zfs create"
|
||||
if len(mountpoint) > 0 {
|
||||
cmd = fmt.Sprintf("%s -o mountpoint=%s", cmd, mountpoint)
|
||||
}
|
||||
if len(compression) > 0 {
|
||||
cmd = fmt.Sprintf("%s -o compression=%s", cmd, compression)
|
||||
}
|
||||
cmd = fmt.Sprintf("%s %s", cmd, dataset)
|
||||
out, err := executeCommand(cmd)
|
||||
if err != nil {
|
||||
return errors.New(fmt.Sprintf("%v; command returned \"%s\"", err, out))
|
||||
@ -821,6 +832,11 @@ func zfsDestroy(dataset string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Filesystem operations
|
||||
*
|
||||
*****************************************************************************/
|
||||
/* Copy file */
|
||||
func copyFile(src, dst string) error {
|
||||
srcfinfo, err := os.Stat(src)
|
||||
@ -845,6 +861,11 @@ func copyFile(src, dst string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Get permissions of file or folder
|
||||
func getPermissions(path string) (os.FileInfo, error) {
|
||||
return os.Stat(path)
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* rc.conf management
|
||||
|
Reference in New Issue
Block a user