Skip to content

Commit

Permalink
Adds ID validation.
Browse files Browse the repository at this point in the history
Docker-DCO-1.1-Signed-off-by: Mrunal Patel <mrunalp@gmail.com> (github: mrunalp)
  • Loading branch information
mrunalp authored and vmarmol committed Dec 5, 2014
1 parent 47b41a6 commit 66e6806
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions linux_factory.go
Expand Up @@ -4,8 +4,10 @@ package libcontainer

import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"regexp"

"github.com/Sirupsen/logrus"
)
Expand All @@ -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 {
Expand All @@ -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")
}

Expand Down

0 comments on commit 66e6806

Please sign in to comment.