Skip to content

Commit 2624163

Browse files
mlusettifd0
authored andcommitted
expose command line option to configure umask for
directories and files
1 parent d24ffc1 commit 2624163

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Feature: Expose command line option to configure FileMode and DirMode
2+
3+
Just expose a CLI option to configure Server FileMode and DirMode to
4+
be able to have files stored in the repo shared with other processes
5+
(maybe just read only)
6+
7+
https://github.com/restic/rest-server/issues/189
8+
https://github.com/restic/rest-server/pull/190

cmd/rest-server/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ func init() {
5353
flags.BoolVar(&server.PrivateRepos, "private-repos", server.PrivateRepos, "users can only access their private repo")
5454
flags.BoolVar(&server.Prometheus, "prometheus", server.Prometheus, "enable Prometheus metrics")
5555
flags.BoolVar(&server.PrometheusNoAuth, "prometheus-no-auth", server.PrometheusNoAuth, "disable auth for Prometheus /metrics endpoint")
56+
flags.Uint32Var(&server.DirMode, "dir-mode", server.DirMode, "filesystem dir mode: defaults to 0700. DO NOT MESS UNLESS YOU KNOW WHAT YOUR DOING")
57+
flags.Uint32Var(&server.FileMode, "file-mode", server.FileMode, "filesystem file mode: defaults to 0600. DO NOT MESS UNLESS YOU KNOW WHAT YOUR DOING")
5658
}
5759

5860
var version = "0.11.0"

handlers.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package restserver
22

33
import (
44
"errors"
5+
"io/fs"
56
"log"
67
"net/http"
78
"path"
@@ -30,6 +31,8 @@ type Server struct {
3031
MaxRepoSize int64
3132
PanicOnError bool
3233
NoVerifyUpload bool
34+
DirMode uint32
35+
FileMode uint32
3336

3437
htpasswdFile *HtpasswdFile
3538
quotaManager *quota.Manager
@@ -90,6 +93,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
9093
QuotaManager: s.quotaManager, // may be nil
9194
PanicOnError: s.PanicOnError,
9295
NoVerifyUpload: s.NoVerifyUpload,
96+
DirMode: fs.FileMode(s.DirMode),
97+
FileMode: fs.FileMode(s.FileMode),
9398
}
9499
if s.Prometheus {
95100
opt.BlobMetricFunc = makeBlobMetricFunc(username, folderPath)

0 commit comments

Comments
 (0)