Skip to content

Commit

Permalink
expose command line option to configure umask for
Browse files Browse the repository at this point in the history
directories and files
  • Loading branch information
mlusetti authored and fd0 committed Apr 15, 2022
1 parent d24ffc1 commit 2624163
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions changelog/0.11.0_2022-02-10/issue-189
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Feature: Expose command line option to configure FileMode and DirMode

Just expose a CLI option to configure Server FileMode and DirMode to
be able to have files stored in the repo shared with other processes
(maybe just read only)

https://github.com/restic/rest-server/issues/189
https://github.com/restic/rest-server/pull/190
2 changes: 2 additions & 0 deletions cmd/rest-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ func init() {
flags.BoolVar(&server.PrivateRepos, "private-repos", server.PrivateRepos, "users can only access their private repo")
flags.BoolVar(&server.Prometheus, "prometheus", server.Prometheus, "enable Prometheus metrics")
flags.BoolVar(&server.PrometheusNoAuth, "prometheus-no-auth", server.PrometheusNoAuth, "disable auth for Prometheus /metrics endpoint")
flags.Uint32Var(&server.DirMode, "dir-mode", server.DirMode, "filesystem dir mode: defaults to 0700. DO NOT MESS UNLESS YOU KNOW WHAT YOUR DOING")
flags.Uint32Var(&server.FileMode, "file-mode", server.FileMode, "filesystem file mode: defaults to 0600. DO NOT MESS UNLESS YOU KNOW WHAT YOUR DOING")
}

var version = "0.11.0"
Expand Down
5 changes: 5 additions & 0 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package restserver

import (
"errors"
"io/fs"
"log"
"net/http"
"path"
Expand Down Expand Up @@ -30,6 +31,8 @@ type Server struct {
MaxRepoSize int64
PanicOnError bool
NoVerifyUpload bool
DirMode uint32
FileMode uint32

htpasswdFile *HtpasswdFile
quotaManager *quota.Manager
Expand Down Expand Up @@ -90,6 +93,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
QuotaManager: s.quotaManager, // may be nil
PanicOnError: s.PanicOnError,
NoVerifyUpload: s.NoVerifyUpload,
DirMode: fs.FileMode(s.DirMode),
FileMode: fs.FileMode(s.FileMode),
}
if s.Prometheus {
opt.BlobMetricFunc = makeBlobMetricFunc(username, folderPath)
Expand Down

0 comments on commit 2624163

Please sign in to comment.