Skip to content

Commit 8cb6c51

Browse files
committed
main: Write output ignition files with mode 0600
Because the config is commonly expected to have secret values, use mode 0600. xref coreos/fedora-coreos-docs#306
1 parent 97c6866 commit 8cb6c51

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

internal/main.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ func main() {
102102

103103
if output != "" {
104104
var err error
105-
outfile, err = os.OpenFile(output, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
105+
// Because the config is commonly expected to have secret values, use mode 0600.
106+
// xref https://github.com/coreos/fedora-coreos-docs/issues/306
107+
outfile, err = os.OpenFile(output, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
106108
if err != nil {
107109
fail("failed to open %s: %v\n", output, err)
108110
}

test

+18
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,24 @@ trap 'rm -r tmpdocs' EXIT
2929
mkdir -p tmpdocs/files-dir/tree
3030
touch tmpdocs/files-dir/{config.ign,ca.pem,file,file-epilogue,local-file3}
3131

32+
tmpd=$(mktemp -d)
33+
${BIN_PATH}/${NAME} --strict --output ${tmpd}/foo.ign << 'EOF'
34+
variant: fcos
35+
version: 1.1.0
36+
storage:
37+
files:
38+
- path: /etc/somesecret
39+
mode: 0600
40+
contents:
41+
source: https://example.com/etc/somesecret
42+
EOF
43+
m=$(stat -c '%a' ${tmpd}/foo.ign)
44+
rm -rf "${tmpd}"
45+
if test "${m}" != 600; then
46+
echo "Unexpected ignition mode: ${m}" 1>&2
47+
exit 1
48+
fi
49+
3250
for doc in docs/*md
3351
do
3452
echo "Checking $doc"

0 commit comments

Comments
 (0)