Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 84041b5

Browse files
committedAug 27, 2021
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 84041b5

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-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

+17
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@ 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+
if test "${m}" != 600; then
45+
echo "Unexpected ignition mode: ${m}" 1>&2
46+
exit 1
47+
fi
48+
3249
for doc in docs/*md
3350
do
3451
echo "Checking $doc"

0 commit comments

Comments
 (0)
Please sign in to comment.