stage1: integrate /diagexec wrapper into rkt run

Use /diagexec for launching the container's apps to assist understanding
execution interpreter problems.  No substantial overhead is introduced in the
normal/success case, diagnostics are only attempted when execv() of the target
fails.

Examples of the assistance provided:

  ~# bin/rkt run imgs/nobash.aci # bash script without /bin/bash
  Error: Unable to open "/bin/bash": No such file or directory
  Sending SIGTERM to remaining processes...
  Sending SIGKILL to remaining processes...
  Unmounting file systems.
  Unmounting /proc/sys/kernel/random/boot_id.
  All filesystems unmounted.
  Halting system.

  ~# bin/rkt run imgs/noexec.aci # file with no execute bits
  Error: "/noexec.sh" is not executable
  Sending SIGTERM to remaining processes...
  Sending SIGKILL to remaining processes...
  Unmounting file systems.
  Unmounting /proc/sys/kernel/random/boot_id.
  All filesystems unmounted.
  Halting system.

  ~# bin/rkt run imgs/noldlinux.aci # ELF program without interp
  Error: Unable to open "/lib64/ld-linux-x86-64.so.2": No such file or directory
  Sending SIGTERM to remaining processes...
  Sending SIGKILL to remaining processes...
  Unmounting file systems.
  Unmounting /proc/sys/kernel/random/boot_id.
  All filesystems unmounted.
  Halting system.

  ~# bin/rkt run imgs/noldlinuxbash.aci # script with bash without ELF interp
  Error: Unable to open "/lib64/ld-linux-x86-64.so.2": No such file or directory
  Sending SIGTERM to remaining processes...
  Sending SIGKILL to remaining processes...
  Unmounting file systems.
  Unmounting /proc/sys/kernel/random/boot_id.
  All filesystems unmounted.
  Halting system.

 Fixes #286
This commit is contained in:
Vito Caputo
2014-12-30 15:43:59 -08:00
parent 9896a67260
commit e210200b4c
2 changed files with 4 additions and 3 deletions
+3 -3
View File
@@ -83,7 +83,8 @@ func LoadContainer(root string) (*Container, error) {
func (c *Container) appToSystemd(am *schema.ImageManifest, id types.Hash) error {
name := am.Name.String()
app := am.App
execStart := strings.Join(app.Exec, " ")
execWrap := []string{"/diagexec", rktpath.RelAppRootfsPath(id)}
execStart := strings.Join(append(execWrap, app.Exec...), " ")
opts := []*unit.UnitOption{
&unit.UnitOption{"Unit", "Description", name},
&unit.UnitOption{"Unit", "DefaultDependencies", "false"},
@@ -91,7 +92,6 @@ func (c *Container) appToSystemd(am *schema.ImageManifest, id types.Hash) error
&unit.UnitOption{"Unit", "OnFailure", "reaper.service"},
&unit.UnitOption{"Unit", "Wants", "exit-watcher.service"},
&unit.UnitOption{"Service", "Restart", "no"},
&unit.UnitOption{"Service", "RootDirectory", rktpath.RelAppRootfsPath(id)},
&unit.UnitOption{"Service", "ExecStart", execStart},
&unit.UnitOption{"Service", "User", app.User},
&unit.UnitOption{"Service", "Group", app.Group},
@@ -107,7 +107,7 @@ func (c *Container) appToSystemd(am *schema.ImageManifest, id types.Hash) error
default:
return fmt.Errorf("unrecognized eventHandler: %v", eh.Name)
}
exec := strings.Join(eh.Exec, " ")
exec := strings.Join(append(execWrap, eh.Exec...), " ")
opts = append(opts, &unit.UnitOption{"Service", typ, exec})
}
+1
View File
@@ -21,6 +21,7 @@ install -m 0644 units/reaper.service "$RD/usr/lib/systemd/system"
install -m 0644 units/sockets.target "$RD/usr/lib/systemd/system"
install -m 0755 scripts/reaper.sh "$RD"
install -m 0755 ../shim/shim.so "$RD"
install -m 0755 ../diagexec/diagexec "$RD"
ln -s shim.so "$RD/fakesdboot.so"
install -d "$RD/etc"