diff --git a/linux_factory.go b/linux_factory.go index dc998c343b5..4adb1bfbc19 100644 --- a/linux_factory.go +++ b/linux_factory.go @@ -4,8 +4,10 @@ package libcontainer import ( "encoding/json" + "fmt" "os" "path/filepath" + "regexp" "github.com/Sirupsen/logrus" ) @@ -15,6 +17,10 @@ const ( stateFilename = "state.json" ) +var ( + idRegex = regexp.MustCompile(`^[\w_]{1,1024}$`) +) + // New returns a linux based container factory based in the root directory. func New(root string, logger *logrus.Logger) (Factory, error) { if err := os.MkdirAll(root, 0700); err != nil { @@ -37,6 +43,10 @@ type linuxFactory struct { } func (l *linuxFactory) Create(id string, config *Config) (Container, error) { + if !idRegex.MatchString(id) { + return nil, newGenericError(fmt.Errorf("Invalid id format: %s ", id), InvalidIdFormat) + } + panic("not implemented") }