Skip to content

Commit

Permalink
fix: truncate "/var/lib/dbus/machine-id" in case it's separate from "…
Browse files Browse the repository at this point in the history
…/etc/machine-id" (#1471)

"/var/lib/dbus/machine-id" MAY be a symlink to "/etc/machine-id".[1]  If it
isn't, however, we need to truncate it separately to avoid reuse.

Fixes #1421.

[1]: https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1818499.html

Signed-off-by: Cory Francis Myers <cory@freedom.press>
  • Loading branch information
cfm authored Feb 10, 2023
1 parent d7bc5f8 commit 0c64148
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions packer_templates/scripts/debian/cleanup_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ find /var/log -type f -exec truncate --size=0 {} \;

echo "blank netplan machine-id (DUID) so machines get unique ID generated on boot"
truncate -s 0 /etc/machine-id
truncate -s 0 /var/lib/dbus/machine-id # if not symlinked to "/etc/machine-id"

echo "remove the contents of /tmp and /var/tmp"
rm -rf /tmp/* /var/tmp/*
Expand Down
1 change: 1 addition & 0 deletions packer_templates/scripts/fedora/cleanup_dnf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ rm -f /var/lib/systemd/random-seed

echo "Wipe netplan machine-id (DUID) so machines get unique ID generated on boot"
truncate -s 0 /etc/machine-id
truncate -s 0 /var/lib/dbus/machine-id # if not symlinked to "/etc/machine-id"

echo "Clear the history so our install commands aren't there"
rm -f /root/.wget-hsts
Expand Down
1 change: 1 addition & 0 deletions packer_templates/scripts/rhel/cleanup_dnf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ rm -f /var/lib/systemd/random-seed

echo "Wipe netplan machine-id (DUID) so machines get unique ID generated on boot"
truncate -s 0 /etc/machine-id
truncate -s 0 /var/lib/dbus/machine-id # if not symlinked to "/etc/machine-id"

echo "Clear the history so our install commands aren't there"
rm -f /root/.wget-hsts
Expand Down
1 change: 1 addition & 0 deletions packer_templates/scripts/rhel/cleanup_yum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ rm -f /var/lib/systemd/random-seed

echo "Wipe netplan machine-id (DUID) so machines get unique ID generated on boot"
truncate -s 0 /etc/machine-id
truncate -s 0 /var/lib/dbus/machine-id # if not symlinked to "/etc/machine-id"

echo "Clear the history so our install commands aren't there"
rm -f /root/.wget-hsts
Expand Down
1 change: 1 addition & 0 deletions packer_templates/scripts/suse/cleanup_suse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ rm -rf /tmp/* /var/tmp/*

echo "blank netplan machine-id (DUID) so machines get unique ID generated on boot"
truncate -s 0 /etc/machine-id
truncate -s 0 /var/lib/dbus/machine-id # if not symlinked to "/etc/machine-id"

echo "force a new random seed to be generated"
rm -f /var/lib/systemd/random-seed
Expand Down
1 change: 1 addition & 0 deletions packer_templates/scripts/ubuntu/cleanup_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ find /var/log -type f -exec truncate --size=0 {} \;

echo "blank netplan machine-id (DUID) so machines get unique ID generated on boot"
truncate -s 0 /etc/machine-id
truncate -s 0 /var/lib/dbus/machine-id # if not symlinked to "/etc/machine-id"

echo "remove the contents of /tmp and /var/tmp"
rm -rf /tmp/* /var/tmp/*
Expand Down

0 comments on commit 0c64148

Please sign in to comment.