Repository navigation
Open
Description
put_data in deploy/linux/tendcf-install.sh (
tendcf/deploy/linux/tendcf-install.sh
Lines 142 to 162 in db1e73e
| } | |
| put_data() { # put_data FILE | |
| local src="$1" backup="" | |
| [ -f "$src" ] || die "no such data file: $src" | |
| if [ -f "$data" ]; then | |
| backup="$data.previous" | |
| cp -p "$data" "$backup" | |
| fi | |
| # Write beside the live file, then rename over it: the agent (cf-execd runs | |
| # it on a schedule) never reads a half-written host_specific.json, and the | |
| # loader and the policy's cross-check cannot see two different halves. | |
| local tmp="$data.new" | |
| if ! install -m 0600 -o root -g root "$src" "$tmp"; then | |
| rm -f "$tmp" | |
| die "could not write $tmp" | |
| fi | |
| mv -f "$tmp" "$data" | |
| if ! "$cf_promises" -f "$entry" >/dev/null; then | |
| if [ -n "$backup" ]; then mv -f "$backup" "$data"; else rm -f "$data"; fi | |
| die "cf-promises rejected $src; previous data restored" |
$data.new and .previous paths. Two concurrent installer runs clobber each other's temp file and backup. The atomic rename added in #42 protects readers from one writer's partial install. It does not make publication a multi-writer transaction.
Wanted: unique same-directory staging (mktemp "$data.XXXXXX") and serialised publish/rollback (a lock), with a concurrent-publisher test. Needs root, so low impact.
From the round-3 reviews of #42 (frontier review C2; adversary I3.3).
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
No labels
Activity