resolver.conf bugfix, datasets now should be specified with zpool
This commit is contained in:
parent
7cf4594f34
commit
00fd283987
28
cmd/start.go
28
cmd/start.go
@ -190,24 +190,26 @@ func prepareJailedZfsDatasets(jail *Jail) error {
|
||||
}
|
||||
for _, d := range strings.Split(jail.Config.Jail_zfs_dataset, " ") {
|
||||
// Check if dataset exist, create if necessary
|
||||
cmd := fmt.Sprintf("zfs get -H creation %s/%s", jail.Zpool, d)
|
||||
// Support jailing datasets on differents pools : dataset should be specified with pool name
|
||||
cmd := fmt.Sprintf("zfs get -H creation %s", d)
|
||||
out, err := executeCommand(cmd)
|
||||
if err != nil {
|
||||
if strings.HasSuffix(out, "dataset does not exist") {
|
||||
cmd = fmt.Sprintf("zfs create -o compression=lz4 -o mountpoint=none %s/%s", jail.Zpool, d)
|
||||
// Support jailing datasets on differents pools : dataset should be specified with pool name
|
||||
cmd = fmt.Sprintf("zfs create -o compression=lz4 -o mountpoint=none %s", d)
|
||||
_, err = executeCommand(cmd)
|
||||
if err != nil {
|
||||
return errors.New(fmt.Sprintf("Error creating dataset %s/%s: %s", jail.Zpool, d, err.Error()))
|
||||
return errors.New(fmt.Sprintf("Error creating dataset %s: %s", d, err.Error()))
|
||||
}
|
||||
} else {
|
||||
return errors.New(fmt.Sprintf("Error getting zfs dataset %s: %s", d, err.Error()))
|
||||
}
|
||||
}
|
||||
|
||||
cmd = fmt.Sprintf("zfs set jailed=on %s/%s", jail.Zpool, d)
|
||||
cmd = fmt.Sprintf("zfs set jailed=on %s", d)
|
||||
out, err = executeCommand(cmd)
|
||||
if err != nil {
|
||||
return errors.New(fmt.Sprintf("Error executing \"zfs set jailed=on %s/%s\": %s", jail.Zpool, d, err.Error()))
|
||||
return errors.New(fmt.Sprintf("Error executing \"zfs set jailed=on %s\": %s", d, err.Error()))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -218,27 +220,27 @@ func jailZfsDatasets(jail *Jail) error {
|
||||
if jail.Config.Jail_zfs > 0 {
|
||||
for _, d := range strings.Split(jail.Config.Jail_zfs_dataset, " ") {
|
||||
// Jail dataset
|
||||
cmd := fmt.Sprintf("zfs jail %d %s/%s", jail.JID, jail.Zpool, d)
|
||||
// Support jailing datasets on differents pools : dataset should be specified with pool name
|
||||
cmd := fmt.Sprintf("zfs jail %d %s", jail.JID, d)
|
||||
out, err := executeCommand(cmd)
|
||||
if err != nil {
|
||||
return errors.New(fmt.Sprintf("Error jailling zfs dataset %s: %v: out", d, err, out))
|
||||
}
|
||||
|
||||
// Mount from inside jail if mountpoint is set
|
||||
cmd = fmt.Sprintf("zfs get -H -o value mountpoint %s/%s", jail.Zpool, d)
|
||||
cmd = fmt.Sprintf("zfs get -H -o value mountpoint %s", d)
|
||||
out, err = executeCommand(cmd)
|
||||
if err != nil {
|
||||
return errors.New(fmt.Sprintf("Error getting zfs dataset %s/%s mountpoint: %v: %s", jail.Zpool, d, err, out))
|
||||
return errors.New(fmt.Sprintf("Error getting zfs dataset %s mountpoint: %v: %s", d, err, out))
|
||||
}
|
||||
if len(out) > 0 && out != "-" && (false == strings.EqualFold(out, "none")) {
|
||||
//cmd = fmt.Sprintf("zfs mount %s/%s", jail.Zpool, d)
|
||||
cmd = fmt.Sprintf("zfs mount -a")
|
||||
// Should we "mount -a" ? cmd = fmt.Sprintf("zfs mount -a")
|
||||
cmd = fmt.Sprintf("zfs mount %s", d)
|
||||
out, err = executeCommandInJail(jail, cmd)
|
||||
if err != nil {
|
||||
// If already mounted, continue processing
|
||||
if ! strings.HasSuffix(out, "filesystem already mounted\n") {
|
||||
//return errors.New(fmt.Sprintf("Error mounting zfs dataset %s/%s: %v: %s", jail.Zpool, d, err, out))
|
||||
return errors.New(fmt.Sprintf("Error executing \"zfs mount -a\" from inside jail: %v: %s", err, out))
|
||||
return errors.New(fmt.Sprintf("Error mounting zfs dataset %s from inside jail: %v: %s", d, err, out))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1011,7 +1013,7 @@ func generateResolvConf(jail *Jail) error {
|
||||
for _, l := range strings.Split(jail.Config.Resolver, ";") {
|
||||
f.WriteString(fmt.Sprintf("%s\n", l))
|
||||
}
|
||||
} else if jail.Config.Resolver == "none" {
|
||||
} else if jail.Config.Resolver == "none" || jail.Config.Resolver == "/etc/resolv.conf" {
|
||||
read, err := ioutil.ReadFile("/etc/resolv.conf")
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error opening /etc/resolv.conf: %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user