summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Borg <jakob@kastelo.net>2023-11-24 08:55:33 +0100
committerJakob Borg <jakob@kastelo.net>2023-11-27 08:24:59 +0100
commit47bcf4f8f4909b971640ffc4607807382f156803 (patch)
tree1b6ca56917a347c14ff1c574aeeaf95350706ca1
parenta8b90963535f2919ceea5994821472b85288a4dd (diff)
downloadsyncthing-47bcf4f8f4909b971640ffc4607807382f156803.tar.gz
syncthing-47bcf4f8f4909b971640ffc4607807382f156803.zip
cmd/stcrashreceiver: Minor cleanup, stricter file permissions
-rw-r--r--cmd/stcrashreceiver/diskstore.go6
-rw-r--r--cmd/stcrashreceiver/main.go16
2 files changed, 10 insertions, 12 deletions
diff --git a/cmd/stcrashreceiver/diskstore.go b/cmd/stcrashreceiver/diskstore.go
index 83a4cc175..1073dee14 100644
--- a/cmd/stcrashreceiver/diskstore.go
+++ b/cmd/stcrashreceiver/diskstore.go
@@ -40,7 +40,7 @@ type currentFile struct {
}
func (d *diskStore) Serve(ctx context.Context) {
- if err := os.MkdirAll(d.dir, 0750); err != nil {
+ if err := os.MkdirAll(d.dir, 0o700); err != nil {
log.Println("Creating directory:", err)
return
}
@@ -60,7 +60,7 @@ func (d *diskStore) Serve(ctx context.Context) {
case entry := <-d.inbox:
path := d.fullPath(entry.path)
- if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
+ if err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil {
log.Println("Creating directory:", err)
continue
}
@@ -75,7 +75,7 @@ func (d *diskStore) Serve(ctx context.Context) {
log.Println("Failed to compress crash report:", err)
continue
}
- if err := os.WriteFile(path, buf.Bytes(), 0644); err != nil {
+ if err := os.WriteFile(path, buf.Bytes(), 0o600); err != nil {
log.Printf("Failed to write %s: %v", entry.path, err)
_ = os.Remove(path)
continue
diff --git a/cmd/stcrashreceiver/main.go b/cmd/stcrashreceiver/main.go
index 4ea02da39..197466a9a 100644
--- a/cmd/stcrashreceiver/main.go
+++ b/cmd/stcrashreceiver/main.go
@@ -21,7 +21,6 @@ import (
"net/http"
"os"
"path/filepath"
- "time"
"github.com/alecthomas/kong"
"github.com/prometheus/client_golang/prometheus/promhttp"
@@ -34,14 +33,13 @@ import (
const maxRequestSize = 1 << 20 // 1 MiB
type cli struct {
- Dir string `help:"Parent directory to store crash and failure reports in" env:"REPORTS_DIR" default:"."`
- DSN string `help:"Sentry DSN" env:"SENTRY_DSN"`
- Listen string `help:"HTTP listen address" default:":8080" env:"LISTEN_ADDRESS"`
- MaxDiskFiles int `help:"Maximum number of reports on disk" default:"100000" env:"MAX_DISK_FILES"`
- MaxDiskSizeMB int64 `help:"Maximum disk space to use for reports" default:"1024" env:"MAX_DISK_SIZE_MB"`
- CleanInterval time.Duration `help:"Interval between cleaning up old reports" default:"12h" env:"CLEAN_INTERVAL"`
- SentryQueue int `help:"Maximum number of reports to queue for sending to Sentry" default:"64" env:"SENTRY_QUEUE"`
- DiskQueue int `help:"Maximum number of reports to queue for writing to disk" default:"64" env:"DISK_QUEUE"`
+ Dir string `help:"Parent directory to store crash and failure reports in" env:"REPORTS_DIR" default:"."`
+ DSN string `help:"Sentry DSN" env:"SENTRY_DSN"`
+ Listen string `help:"HTTP listen address" default:":8080" env:"LISTEN_ADDRESS"`
+ MaxDiskFiles int `help:"Maximum number of reports on disk" default:"100000" env:"MAX_DISK_FILES"`
+ MaxDiskSizeMB int64 `help:"Maximum disk space to use for reports" default:"1024" env:"MAX_DISK_SIZE_MB"`
+ SentryQueue int `help:"Maximum number of reports to queue for sending to Sentry" default:"64" env:"SENTRY_QUEUE"`
+ DiskQueue int `help:"Maximum number of reports to queue for writing to disk" default:"64" env:"DISK_QUEUE"`
}
func main() {