Merge v1.2.1-master
Signed-off-by: Emile Vauge <emile@vauge.com>
This commit is contained in:
parent
a590155b0b
commit
aeb17182b4
396 changed files with 27271 additions and 9969 deletions
57
vendor/github.com/opencontainers/runc/utils.go
generated
vendored
57
vendor/github.com/opencontainers/runc/utils.go
generated
vendored
|
@ -3,12 +3,45 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
const (
|
||||
exactArgs = iota
|
||||
minArgs
|
||||
maxArgs
|
||||
)
|
||||
|
||||
func checkArgs(context *cli.Context, expected, checkType int) error {
|
||||
var err error
|
||||
cmdName := context.Command.Name
|
||||
switch checkType {
|
||||
case exactArgs:
|
||||
if context.NArg() != expected {
|
||||
err = fmt.Errorf("%s: %q requires exactly %d argument(s)", os.Args[0], cmdName, expected)
|
||||
}
|
||||
case minArgs:
|
||||
if context.NArg() < expected {
|
||||
err = fmt.Errorf("%s: %q requires a minimum of %d argument(s)", os.Args[0], cmdName, expected)
|
||||
}
|
||||
case maxArgs:
|
||||
if context.NArg() > expected {
|
||||
err = fmt.Errorf("%s: %q requires a maximum of %d argument(s)", os.Args[0], cmdName, expected)
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("Incorrect Usage.\n\n")
|
||||
cli.ShowCommandHelp(context, cmdName)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// fatal prints the error's details if it is a libcontainer specific error type
|
||||
// then exits the program with an exit status of 1.
|
||||
func fatal(err error) {
|
||||
|
@ -18,7 +51,7 @@ func fatal(err error) {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
// setupSpec performs inital setup based on the cli.Context for the container
|
||||
// setupSpec performs initial setup based on the cli.Context for the container
|
||||
func setupSpec(context *cli.Context) (*specs.Spec, error) {
|
||||
bundle := context.String("bundle")
|
||||
if bundle != "" {
|
||||
|
@ -30,12 +63,20 @@ func setupSpec(context *cli.Context) (*specs.Spec, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
notifySocket := os.Getenv("NOTIFY_SOCKET")
|
||||
if notifySocket != "" {
|
||||
setupSdNotify(spec, notifySocket)
|
||||
}
|
||||
if os.Geteuid() != 0 {
|
||||
return nil, fmt.Errorf("runc should be run as root")
|
||||
}
|
||||
return spec, nil
|
||||
}
|
||||
|
||||
func revisePidFile(context *cli.Context) error {
|
||||
pidFile := context.String("pid-file")
|
||||
if pidFile == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
// convert pid-file to an absolute path so we can write to the right
|
||||
// file after chdir to bundle
|
||||
pidFile, err := filepath.Abs(pidFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return context.Set("pid-file", pidFile)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue