summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNataliia Solomko <natalirs1985@gmail.com>2026-07-03 14:18:32 +0300
committerNataliia Solomko <natalirs1985@gmail.com>2026-07-03 14:18:32 +0300
commit2a73f2a1bdd1c1ea6b7fd3d27ba8c2e335fa14bb (patch)
treed2df2eede057efed1fc2f2c20c8c0c0d127ce46a /src
parent279f785efb15667c266da9ea73d016b5d5f0f403 (diff)
downloadvyos-1x-2a73f2a1bdd1c1ea6b7fd3d27ba8c2e335fa14bb.tar.gz
vyos-1x-2a73f2a1bdd1c1ea6b7fd3d27ba8c2e335fa14bb.zip
T8344: Preserve symlinks when copying config to/from TPM encrypted volume
shutil.copytree() defaults to symlinks=False, so it recurses into symlinked directories and recreates them as real directories instead of preserving the symlink. cloud-init creates /opt/vyatta/etc/config/cloud/instance as a symlink to instances/i-<id>. Enabling/disabling config encryption copied this tree with copytree() and silently turned that symlink into a real directory, causing cloud-init to fail on later runs with: IsADirectoryError: [Errno 21] Is a directory: '.../cloud/instance' Pass symlinks=True to preserve symlinks during the copy.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/helpers/vyos-config-encrypt.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/helpers/vyos-config-encrypt.py b/src/helpers/vyos-config-encrypt.py
index e035040e1..876a835ec 100755
--- a/src/helpers/vyos-config-encrypt.py
+++ b/src/helpers/vyos-config-encrypt.py
@@ -122,7 +122,9 @@ def encrypt_config(key, recovery_key=None, is_tpm=True):
cmd(f'mount /dev/mapper/vyos_config {d}')
# Move mount_path to encrypted volume
- shutil.copytree(mount_path, d, copy_function=shutil.move, dirs_exist_ok=True)
+ shutil.copytree(
+ mount_path, d, symlinks=True, copy_function=shutil.move, dirs_exist_ok=True
+ )
cmd(f'chgrp -R vyattacfg {d}')
cmd(f'umount {d}')
@@ -207,7 +209,9 @@ def decrypt_config(key):
cmd(f'mount /dev/mapper/vyos_config {d}')
# Move encrypted volume to /opt/vyatta/etc/config
- shutil.copytree(d, mount_path, copy_function=shutil.move, dirs_exist_ok=True)
+ shutil.copytree(
+ d, mount_path, symlinks=True, copy_function=shutil.move, dirs_exist_ok=True
+ )
cmd(f'chgrp -R vyattacfg {mount_path}')
cmd(f'umount {d}')