golf and also securing
parent
872d2ade23
commit
9444954bc6
|
@ -53,22 +53,13 @@ func main() {
|
|||
quit(err.Error())
|
||||
}
|
||||
|
||||
_, err = os.Open(keyfilePath)
|
||||
if err == nil {
|
||||
quit(fmt.Sprintf("%s already exists", keyfilePath))
|
||||
}
|
||||
|
||||
f, err := os.Create(keyfilePath)
|
||||
f, err := os.OpenFile(keyfilePath, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0600)
|
||||
if err != nil {
|
||||
quit(err.Error())
|
||||
quit(fmt.Sprintf("failed to open %s: %s", keyfilePath, err.Error()))
|
||||
}
|
||||
|
||||
defer f.Close()
|
||||
|
||||
if err = os.Chmod(keyfilePath, os.FileMode(0600)); err != nil {
|
||||
quit(err.Error())
|
||||
}
|
||||
|
||||
stdin := make([]byte, 90000) // arbitrary limit
|
||||
|
||||
n, err := os.Stdin.Read(stdin)
|
||||
|
|
Loading…
Reference in New Issue