Browse code

docker save: fix filemode permissions

currently the files created are not readable. This makes the files and
directories permissions more sane.

Docker-DCO-1.1-Signed-off-by: Vincent Batts <vbatts@redhat.com> (github: vbatts)

Vincent Batts authored on 2014/04/09 01:39:25
Showing 1 changed files
... ...
@@ -340,7 +340,7 @@ func (srv *Server) ImageExport(job *engine.Job) engine.Status {
340 340
 		rootRepoMap[name] = rootRepo
341 341
 		rootRepoJson, _ := json.Marshal(rootRepoMap)
342 342
 
343
-		if err := ioutil.WriteFile(path.Join(tempdir, "repositories"), rootRepoJson, os.ModeAppend); err != nil {
343
+		if err := ioutil.WriteFile(path.Join(tempdir, "repositories"), rootRepoJson, os.FileMode(0644)); err != nil {
344 344
 			return job.Error(err)
345 345
 		}
346 346
 	} else {
... ...
@@ -369,7 +369,7 @@ func (srv *Server) exportImage(img *image.Image, tempdir string) error {
369 369
 	for i := img; i != nil; {
370 370
 		// temporary directory
371 371
 		tmpImageDir := path.Join(tempdir, i.ID)
372
-		if err := os.Mkdir(tmpImageDir, os.ModeDir); err != nil {
372
+		if err := os.Mkdir(tmpImageDir, os.FileMode(0755)); err != nil {
373 373
 			if os.IsExist(err) {
374 374
 				return nil
375 375
 			}
... ...
@@ -379,7 +379,7 @@ func (srv *Server) exportImage(img *image.Image, tempdir string) error {
379 379
 		var version = "1.0"
380 380
 		var versionBuf = []byte(version)
381 381
 
382
-		if err := ioutil.WriteFile(path.Join(tmpImageDir, "VERSION"), versionBuf, os.ModeAppend); err != nil {
382
+		if err := ioutil.WriteFile(path.Join(tmpImageDir, "VERSION"), versionBuf, os.FileMode(0644)); err != nil {
383 383
 			return err
384 384
 		}
385 385
 
... ...
@@ -388,7 +388,7 @@ func (srv *Server) exportImage(img *image.Image, tempdir string) error {
388 388
 		if err != nil {
389 389
 			return err
390 390
 		}
391
-		if err := ioutil.WriteFile(path.Join(tmpImageDir, "json"), b, os.ModeAppend); err != nil {
391
+		if err := ioutil.WriteFile(path.Join(tmpImageDir, "json"), b, os.FileMode(0644)); err != nil {
392 392
 			return err
393 393
 		}
394 394