@@ -53,6 +53,7 @@ var specCommand = cli.Command{
5353 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ,
5454 "TERM=xterm" ,
5555 },
56+ Cwd : "/" ,
5657 },
5758 Hostname : "shell" ,
5859 Mounts : []specs.MountPoint {
@@ -290,6 +291,15 @@ var mountPropagationMapping = map[string]int{
290291 "" : syscall .MS_PRIVATE | syscall .MS_REC ,
291292}
292293
294+ // validateSpec validates the fields in the spec
295+ // TODO: Add validation for other fields where applicable
296+ func validateSpec (spec * specs.LinuxSpec , rspec * specs.LinuxRuntimeSpec ) error {
297+ if spec .Process .Cwd == "" {
298+ return fmt .Errorf ("Cwd property must not be empty" )
299+ }
300+ return nil
301+ }
302+
293303// loadSpec loads the specification from the provided path.
294304// If the path is empty then the default path will be "config.json"
295305func loadSpec (cPath , rPath string ) (spec * specs.LinuxSpec , rspec * specs.LinuxRuntimeSpec , err error ) {
@@ -317,7 +327,10 @@ func loadSpec(cPath, rPath string) (spec *specs.LinuxSpec, rspec *specs.LinuxRun
317327 if err = json .NewDecoder (rf ).Decode (& rspec ); err != nil {
318328 return spec , rspec , err
319329 }
320- return spec , rspec , checkSpecVersion (spec )
330+ if err := checkSpecVersion (spec ); err != nil {
331+ return spec , rspec , err
332+ }
333+ return spec , rspec , validateSpec (spec , rspec )
321334}
322335
323336// checkSpecVersion makes sure that the spec version matches runc's while we are in the initial
0 commit comments