feat(net): customize socket file permission
This commit is contained in:
parent
50a3917a65
commit
f02b6f0286
3 changed files with 15 additions and 1 deletions
2
assets
2
assets
|
@ -1 +1 @@
|
|||
Subproject commit 00d3552a762a87df53687f069e0b5856a5cff39d
|
||||
Subproject commit 2bf915a33d58fc78c9c13ffc64685219c28a4732
|
13
main.go
13
main.go
|
@ -118,8 +118,21 @@ func RunUnix(server *http.Server) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer listener.Close()
|
||||
defer os.Remove(conf.UnixConfig.Listen)
|
||||
|
||||
if conf.UnixConfig.Perm > 0 {
|
||||
err = os.Chmod(conf.UnixConfig.Listen, os.FileMode(conf.UnixConfig.Perm))
|
||||
if err != nil {
|
||||
util.Log().Warning(
|
||||
"Failed to set permission to %q for socket file %q: %s",
|
||||
conf.UnixConfig.Perm,
|
||||
conf.UnixConfig.Listen,
|
||||
err,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return server.Serve(listener)
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ type ssl struct {
|
|||
type unix struct {
|
||||
Listen string
|
||||
ProxyHeader string `validate:"required_with=Listen"`
|
||||
Perm uint32
|
||||
}
|
||||
|
||||
// slave 作为slave存储端配置
|
||||
|
|
Loading…
Add table
Reference in a new issue