Merge pull request #5143 from hashicorp/b-exec-regressions

Restore some `exec` behavior
This commit is contained in:
Mahmood Ali 2019-01-04 08:58:40 -05:00 committed by GitHub
commit a9f6288fe3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 27 deletions

View file

@ -297,11 +297,16 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru
return nil, nil, fmt.Errorf("failed to create executor: %v", err)
}
user := cfg.User
if user == "" {
user = "nobody"
}
execCmd := &executor.ExecCommand{
Cmd: driverConfig.Command,
Args: driverConfig.Args,
Env: cfg.EnvList(),
User: cfg.User,
User: user,
ResourceLimits: true,
Resources: cfg.Resources,
TaskDir: cfg.TaskDir().Dir,

View file

@ -328,11 +328,16 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru
return nil, nil, fmt.Errorf("failed to create executor: %v", err)
}
user := cfg.User
if user == "" {
user = "nobody"
}
execCmd := &executor.ExecCommand{
Cmd: absPath,
Args: args,
Env: cfg.EnvList(),
User: cfg.User,
User: user,
ResourceLimits: true,
Resources: cfg.Resources,
TaskDir: cfg.TaskDir().Dir,

View file

@ -506,7 +506,9 @@ func configureIsolation(cfg *lconfigs.Config, command *ExecCommand) error {
"/proc/sys", "/proc/sysrq-trigger", "/proc/irq", "/proc/bus",
}
cfg.Devices = lconfigs.DefaultAutoCreatedDevices
// we bind-mount /dev to preserve pre-0.9 behavior; so avoid setting up individual devices
cfg.Devices = []*lconfigs.Device{}
if len(command.Devices) > 0 {
devs, err := cmdDevices(command.Devices)
if err != nil {
@ -517,11 +519,10 @@ func configureIsolation(cfg *lconfigs.Config, command *ExecCommand) error {
cfg.Mounts = []*lconfigs.Mount{
{
Source: "tmpfs",
Source: "/dev",
Destination: "/dev",
Device: "tmpfs",
Flags: syscall.MS_NOSUID | syscall.MS_STRICTATIME,
Data: "mode=755",
Device: "bind",
Flags: syscall.MS_BIND | syscall.MS_RDONLY | syscall.MS_NOEXEC,
},
{
Source: "proc",
@ -529,26 +530,6 @@ func configureIsolation(cfg *lconfigs.Config, command *ExecCommand) error {
Device: "proc",
Flags: defaultMountFlags,
},
{
Source: "devpts",
Destination: "/dev/pts",
Device: "devpts",
Flags: syscall.MS_NOSUID | syscall.MS_NOEXEC,
Data: "newinstance,ptmxmode=0666,mode=0620,gid=5",
},
{
Device: "tmpfs",
Source: "shm",
Destination: "/dev/shm",
Data: "mode=1777,size=65536k",
Flags: defaultMountFlags,
},
{
Source: "mqueue",
Destination: "/dev/mqueue",
Device: "mqueue",
Flags: defaultMountFlags,
},
{
Source: "sysfs",
Destination: "/sys",