diff mbox series

[kirkstone,10/19] rootfspostcommands.py: Cleanup subid backup files generated by shadow-utils

Message ID 84b2e9a6c17278cbcc08020aa78759004a7b60bf.1661956484.git.steve@sakoman.com
State Accepted, archived
Commit 84b2e9a6c17278cbcc08020aa78759004a7b60bf
Headers show
Series [kirkstone,01/19] sqlite: fix CVE-2022-35737 | expand

Commit Message

Steve Sakoman Aug. 31, 2022, 2:39 p.m. UTC
From: Andrei Gherzan <andrei.gherzan@huawei.com>

When creating users, shadow-utils might create backup files for
subordinate ID files (subid, subgid). Make sure we clean them up
similarly to the other backup files shadow-utils creates.

This is a backport from master that brings in only the cleanup of the
subid backup files without the code restructure.

Signed-off-by: Andrei Gherzan <andrei.gherzan@huawei.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
---
 meta/lib/rootfspostcommands.py | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/meta/lib/rootfspostcommands.py b/meta/lib/rootfspostcommands.py
index fdb9f5b850..12f66d2ce2 100644
--- a/meta/lib/rootfspostcommands.py
+++ b/meta/lib/rootfspostcommands.py
@@ -58,3 +58,10 @@  def sort_passwd(sysconfdir):
             remove_backup(filename)
             if os.path.exists(filename):
                  sort_file(filename, mapping)
+    # Drop other known backup shadow-utils.
+    for filename in (
+            'subgid',
+            'subuid',
+        ):
+        filepath = os.path.join(sysconfdir, filename)
+        remove_backup(filepath)