Skip to content

Commit 11659e8

Browse files
ryancdotorgFiloSottile
authored andcommitted
cmd/age-keygen: don't warn about world-readable output for public keys (#268)
Fixes #267
1 parent 7309913 commit 11659e8

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

cmd/age-keygen/keygen.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,6 @@ func main() {
102102
out = f
103103
}
104104

105-
if fi, err := out.Stat(); err == nil {
106-
if fi.Mode().IsRegular() && fi.Mode().Perm()&0004 != 0 {
107-
fmt.Fprintf(os.Stderr, "Warning: writing secret key to a world-readable file.\n")
108-
}
109-
}
110-
111105
in := os.Stdin
112106
if inFile := flag.Arg(0); inFile != "" && inFile != "-" {
113107
f, err := os.Open(inFile)
@@ -121,6 +115,9 @@ func main() {
121115
if convertFlag {
122116
convert(in, out)
123117
} else {
118+
if fi, err := out.Stat(); err == nil && fi.Mode().IsRegular() && fi.Mode().Perm()&0004 != 0 {
119+
fmt.Fprintf(os.Stderr, "Warning: writing secret key to a world-readable file.\n")
120+
}
124121
generate(out)
125122
}
126123
}

0 commit comments

Comments
 (0)