[elbe-devel] [PATCH 8/9] elbepack: efilesystem: set file permissions through opener
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Mon Jul 29 10:46:35 CEST 2024
Directly set the file permissions when creating the file.
Also replace stat.S_IREAD with the octal mode 0o400 which is easier to
recognize.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/efilesystem.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/elbepack/efilesystem.py b/elbepack/efilesystem.py
index 7fb7b7ccc933..83dea915690b 100644
--- a/elbepack/efilesystem.py
+++ b/elbepack/efilesystem.py
@@ -9,7 +9,6 @@ import logging
import os
import pathlib
import shutil
-import stat
import subprocess
import time
@@ -183,10 +182,11 @@ class ElbeFilesystem(Filesystem):
version_file.write(xml.text('/project/version'))
version_file.close()
- elbe_base = self.open('etc/elbe_base.xml', 'wb')
- xml.xml.write(elbe_base)
- elbe_base.close()
- self.chmod('etc/elbe_base.xml', stat.S_IREAD)
+ def opener(path, flags):
+ return os.open(path, flags, mode=0o400)
+
+ with self.open('etc/elbe_base.xml', 'wb', opener=opener) as elbe_base:
+ xml.xml.write(elbe_base)
def write_licenses(self, f, pkglist, xml_fname=None):
licence_xml = copyright_xml()
--
2.45.2
More information about the elbe-devel
mailing list