]> Cypherpunks.ru repositories - gocheese.git/commitdiff
umask friendly permissions for newly created files
authorSergey Matveev <stargrave@stargrave.org>
Wed, 4 Dec 2019 08:32:10 +0000 (11:32 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 4 Dec 2019 13:40:25 +0000 (16:40 +0300)
gocheese.go

index bdb6ead659d35082a32eb7f52fb8b07ff8395ec2..835e8c5b392a2f66ab0c2a7e0500c0a976445477 100644 (file)
@@ -84,7 +84,7 @@ type Auther interface {
 func mkdirForPkg(w http.ResponseWriter, r *http.Request, dir string) bool {
        path := filepath.Join(*root, dir)
        if _, err := os.Stat(path); os.IsNotExist(err) {
-               if err = os.Mkdir(path, 0700); err != nil {
+               if err = os.Mkdir(path, os.FileMode(0777)); err != nil {
                        http.Error(w, err.Error(), http.StatusInternalServerError)
                        return false
                }
@@ -187,7 +187,7 @@ func refreshDir(w http.ResponseWriter, r *http.Request, dir, filenameGet string)
                        }
                }
                log.Println(r.RemoteAddr, "pypi touch", filename)
-               if err = ioutil.WriteFile(path, digest, os.FileMode(0600)); err != nil {
+               if err = ioutil.WriteFile(path, digest, os.FileMode(0666)); err != nil {
                        http.Error(w, err.Error(), http.StatusInternalServerError)
                        return false
                }
@@ -337,11 +337,7 @@ func serveUpload(w http.ResponseWriter, r *http.Request) {
                        http.Error(w, err.Error(), http.StatusInternalServerError)
                        return
                }
-               if err = ioutil.WriteFile(
-                       path+SHA256Ext,
-                       hasher.Sum(nil),
-                       os.FileMode(0600),
-               ); err != nil {
+               if err = ioutil.WriteFile(path+SHA256Ext, hasher.Sum(nil), os.FileMode(0666)); err != nil {
                        http.Error(w, err.Error(), http.StatusInternalServerError)
                        return
                }