cmd/age-keygen: detect world-readable output file

This commit is contained in:
Filippo Valsorda
2019-12-06 23:45:54 -05:00
parent 93ea79628d
commit 0369d9b7fb

View File

@@ -36,6 +36,13 @@ func main() {
out = f
}
if fi, err := out.Stat(); err == nil {
if fi.Mode().IsRegular() && fi.Mode().Perm()&0004 != 0 {
fmt.Fprintf(os.Stderr, "Warning: writing to a world-readable file.\n")
fmt.Fprintf(os.Stderr, "Consider setting the umask to 066 and trying again.\n")
}
}
generate(out)
}