tmpfiles: optionally, decode string to write to files with base64

This is useful to use "f" or "w" to write arbitrary binary files to
disk, or files with newlines and similar (for example to provision SSH
host keys and similar).
This commit is contained in:
Lennart Poettering
2022-07-15 11:55:03 +02:00
parent b89cfe8a60
commit 708daf42d8
3 changed files with 113 additions and 33 deletions
+10
View File
@@ -188,6 +188,14 @@ def test_hard_cleanup(*, user):
label = 'valid_symlink-deep'
test_content('f= {} - - - - ' + label, label, user=user, subpath='/deep/1/2', path_cb=valid_symlink)
def test_base64():
test_line('f~ /tmp/base64-test - - - - UGlmZgpQYWZmClB1ZmYgCg==', user=False, returncode=0)
with open("/tmp/base64-test", mode='r') as f:
d = f.read()
assert d == "Piff\nPaff\nPuff \n"
if __name__ == '__main__':
test_invalids(user=False)
test_invalids(user=True)
@@ -198,3 +206,5 @@ if __name__ == '__main__':
test_hard_cleanup(user=False)
test_hard_cleanup(user=True)
test_base64()