mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 10:58:57 +00:00
cmd/stcrashreceiver: Minor cleanup, stricter file permissions
This commit is contained in:
parent
808dcb09b4
commit
1975e88444
@ -40,7 +40,7 @@ type currentFile struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *diskStore) Serve(ctx context.Context) {
|
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)
|
log.Println("Creating directory:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ func (d *diskStore) Serve(ctx context.Context) {
|
|||||||
case entry := <-d.inbox:
|
case entry := <-d.inbox:
|
||||||
path := d.fullPath(entry.path)
|
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)
|
log.Println("Creating directory:", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ func (d *diskStore) Serve(ctx context.Context) {
|
|||||||
log.Println("Failed to compress crash report:", err)
|
log.Println("Failed to compress crash report:", err)
|
||||||
continue
|
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)
|
log.Printf("Failed to write %s: %v", entry.path, err)
|
||||||
_ = os.Remove(path)
|
_ = os.Remove(path)
|
||||||
continue
|
continue
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/alecthomas/kong"
|
"github.com/alecthomas/kong"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
@ -34,14 +33,13 @@ import (
|
|||||||
const maxRequestSize = 1 << 20 // 1 MiB
|
const maxRequestSize = 1 << 20 // 1 MiB
|
||||||
|
|
||||||
type cli struct {
|
type cli struct {
|
||||||
Dir string `help:"Parent directory to store crash and failure reports in" env:"REPORTS_DIR" default:"."`
|
Dir string `help:"Parent directory to store crash and failure reports in" env:"REPORTS_DIR" default:"."`
|
||||||
DSN string `help:"Sentry DSN" env:"SENTRY_DSN"`
|
DSN string `help:"Sentry DSN" env:"SENTRY_DSN"`
|
||||||
Listen string `help:"HTTP listen address" default:":8080" env:"LISTEN_ADDRESS"`
|
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"`
|
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"`
|
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"`
|
||||||
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"`
|
||||||
DiskQueue int `help:"Maximum number of reports to queue for writing to disk" default:"64" env:"DISK_QUEUE"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
Loading…
Reference in New Issue
Block a user