Commit f2943901 authored by Simon Ruderich's avatar Simon Ruderich
Browse files

Use ioutil.ReadFile()

parent 3b97f0f1
Pipeline #4854 passed with stage
in 2 minutes and 11 seconds
...@@ -53,25 +53,19 @@ func main() { ...@@ -53,25 +53,19 @@ func main() {
"file in which the hmac secret is stored") "file in which the hmac secret is stored")
flag.Parse() flag.Parse()
// setup hmac secret from file hmacSecret, err := ioutil.ReadFile(*hmacSecretFile)
f, err := os.Open(*hmacSecretFile)
if err != nil {
log.Fatalf("unable to open secrets file: %v", err)
}
hmacSecret, err := ioutil.ReadAll(f)
if err != nil { if err != nil {
log.Fatalf("unable to read HMAC secret: %v", err) log.Fatalf("unable to read HMAC secret: %v", err)
} }
// warn if hmac file has insecure permissions // warn if hmac file has insecure permissions
s, err := f.Stat() s, err := os.Stat(*hmacSecretFile)
if err != nil { if err != nil {
log.Fatalf("unable to fstat secrets file: %v", err) log.Fatalf("unable to fstat secrets file: %v", err)
} }
if s.Mode().Perm()&0077 != 0 { if s.Mode().Perm()&0077 != 0 {
log.Fatalf("insecure permissions of secrets file") log.Fatalf("insecure permissions of secrets file")
} }
f.Close()
l, err := net.Listen("tcp", ":ident") l, err := net.Listen("tcp", ":ident")
if err != nil { if err != nil {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment