feat: add --socket-perm flag to control unix socket file permissions (closes #1060)

This commit is contained in:
Oleg Lobanov 2020-09-11 15:59:06 +02:00
parent ede4213c8e
commit 65ac73414f
No known key found for this signature in database
GPG Key ID: 7CC64E41212621B0

View File

@ -58,6 +58,7 @@ func addServerFlags(flags *pflag.FlagSet) {
flags.StringP("key", "k", "", "tls key")
flags.StringP("root", "r", ".", "root to prepend to relative paths")
flags.String("socket", "", "socket to listen to (cannot be used with address, port, cert nor key flags)")
flags.Uint32("socket-perm", 0666, "unix socket file permissions")
flags.StringP("baseurl", "b", "", "base url")
flags.String("cache-dir", "", "file cache directory (disabled if empty)")
flags.Int("img-processors", 4, "image processors count")
@ -143,6 +144,10 @@ user created with the credentials from options "username" and "password".`,
case server.Socket != "":
listener, err = net.Listen("unix", server.Socket)
checkErr(err)
socketPerm, err := cmd.Flags().GetUint32("socket-perm")
checkErr(err)
err = os.Chmod(server.Socket, os.FileMode(socketPerm))
checkErr(err)
case server.TLSKey != "" && server.TLSCert != "":
cer, err := tls.LoadX509KeyPair(server.TLSCert, server.TLSKey) //nolint:shadow
checkErr(err)