Skip to content

Installer: concurrent publishers collide on fixed .new/.previous paths #58

Open

Description

@djbclark

put_data in deploy/linux/tendcf-install.sh (

}
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"
) uses fixed $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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions