Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion internal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ func main() {

if output != "" {
var err error
outfile, err = os.OpenFile(output, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
// Because the config is commonly expected to have secret values, use mode 0600.
// xref https://github.com/coreos/fedora-coreos-docs/issues/306
outfile, err = os.OpenFile(output, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
fail("failed to open %s: %v\n", output, err)
}
Expand Down
18 changes: 18 additions & 0 deletions test
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@ trap 'rm -r tmpdocs' EXIT
mkdir -p tmpdocs/files-dir/tree
touch tmpdocs/files-dir/{config.ign,ca.pem,file,file-epilogue,local-file3}

tmpd=$(mktemp -d)
${BIN_PATH}/${NAME} --strict --output ${tmpd}/foo.ign << 'EOF'
variant: fcos
version: 1.1.0
storage:
files:
- path: /etc/somesecret
mode: 0600
contents:
source: https://example.com/etc/somesecret
EOF
m=$(stat -c '%a' ${tmpd}/foo.ign)
rm -rf "${tmpd}"
if test "${m}" != 600; then
echo "Unexpected ignition mode: ${m}" 1>&2
exit 1
fi

for doc in docs/*md
do
echo "Checking $doc"
Expand Down