BUGFIX removed usr from gBaseDirs as it should not be mounted from basejail
This commit is contained in:
parent
fce64b2939
commit
9208102c84
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
//"log"
|
||||
"time"
|
||||
"errors"
|
||||
"strings"
|
||||
cp "github.com/otiai10/copy"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -85,15 +86,24 @@ func CreateJail(args []string) {
|
||||
fmt.Printf(" > Create base read-only directories\n")
|
||||
dstRootDir := fmt.Sprintf("%s/jails/%s/root", ds.Mountpoint, jname)
|
||||
for _, d := range append(gBaseDirs, gEmptyDirs...) {
|
||||
srcPerm, err := getPermissions(fmt.Sprintf("%s/%s", bj.RootPath, d))
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR getting permissions of %s/%s: %s\n", bj.RootPath, d, err.Error())
|
||||
return
|
||||
}
|
||||
err = os.Mkdir(fmt.Sprintf("%s/%s", dstRootDir, d), srcPerm.Mode().Perm())
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR creating directory %s/%s: %s\n", dstRootDir, d, err.Error())
|
||||
return
|
||||
dstPath := dstRootDir
|
||||
srcPath := bj.RootPath
|
||||
for _, cd := range strings.Split(d, "/") {
|
||||
srcPath = fmt.Sprintf("%s/%s", srcPath, cd)
|
||||
dstPath = fmt.Sprintf("%s/%s", dstPath, cd)
|
||||
_, err := os.Stat(dstPath)
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
srcPerm, err := getPermissions(srcPath)
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR getting permissions of %s: %s\n", srcPath, err.Error())
|
||||
return
|
||||
}
|
||||
err = os.Mkdir(dstPath, srcPerm.Mode().Perm())
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR creating directory %s: %s\n", dstPath, err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,6 +164,11 @@ func CreateJail(args []string) {
|
||||
return
|
||||
}
|
||||
defer fstabHandle.Close()
|
||||
|
||||
for _, d := range gBaseDirs {
|
||||
fmt.Fprintf(fstabHandle, "%s\t%s\tnullfs\tro\t0\t0\n", fmt.Sprintf("%s/%s", bj.RootPath, d), fmt.Sprintf("%s/%s", dstRootDir, d))
|
||||
}
|
||||
|
||||
fmt.Printf(" > Jail created!\n")
|
||||
} else {
|
||||
/**************************************************************************
|
||||
@ -252,6 +267,7 @@ func CreateJail(args []string) {
|
||||
j.Config.Release = gCreateArgs.Release
|
||||
j.Config.Host_hostname = jname
|
||||
j.Config.Host_hostuuid = jname
|
||||
j.Config.Jailtype = "jail"
|
||||
|
||||
j.WriteConfigToDisk(false)
|
||||
|
||||
@ -265,6 +281,5 @@ func CreateJail(args []string) {
|
||||
defer fstabHandle.Close()
|
||||
fmt.Printf(" > Jail created!\n")
|
||||
}
|
||||
// TODO : Set JailType
|
||||
}
|
||||
}
|
||||
|
@ -66,8 +66,8 @@ var (
|
||||
gUpgradeRelease string
|
||||
|
||||
// For a based jail, these are directories binded to basejail
|
||||
gBaseDirs = []string{"bin", "boot", "lib", "libexec", "rescue", "sbin", "usr", "usr/bin",
|
||||
"usr/include", "usr/lib", "usr/lib32", "usr/libdata", "usr/libexec", "usr/sbin", "usr/share"}
|
||||
gBaseDirs = []string{"bin", "boot", "lib", "libexec", "rescue", "sbin", "usr/bin", "usr/include",
|
||||
"usr/lib", "usr/lib32", "usr/libdata", "usr/libexec", "usr/sbin", "usr/share"}
|
||||
// These directories are to be created empty
|
||||
gEmptyDirs = []string{"dev", "media", "mnt", "net", "proc"}
|
||||
// Copy these from base template
|
||||
|
Loading…
Reference in New Issue
Block a user