From 800fbd3f7cff53e8d4645b9cafec98cc1675f696 Mon Sep 17 00:00:00 2001 From: Goffi Date: Sat, 1 Aug 2020 16:02:41 +0200 Subject: [PATCH] core (memory): files are now public by default except for those in root directory: using public permissions by default makes permissions change more easy as we don't have to recursively change all permissions of sub files when changing directory. Root directories are private by default. --- sat/memory/memory.py | 10 +++++++++- sat/memory/sqlite.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sat/memory/memory.py b/sat/memory/memory.py index 06afea95..cbd8eb83 100644 --- a/sat/memory/memory.py +++ b/sat/memory/memory.py @@ -1222,7 +1222,15 @@ class Memory(object): perm_data = file_data["access"][perm] perm_type = perm_data["type"] except KeyError: - raise exceptions.PermissionError() + # No permission is set. + # If we are in a root file/directory, we deny access + # otherwise, we use public permission, as the parent directory will + # block anyway, this avoid to have to recursively change permissions for + # all sub directories/files when modifying a permission + if not file_data.get('parent'): + raise exceptions.PermissionError() + else: + perm_type == C.ACCESS_TYPE_PUBLIC if perm_type == C.ACCESS_TYPE_PUBLIC: continue elif perm_type == C.ACCESS_TYPE_WHITELIST: diff --git a/sat/memory/sqlite.py b/sat/memory/sqlite.py index dce110c1..0adbdc54 100644 --- a/sat/memory/sqlite.py +++ b/sat/memory/sqlite.py @@ -1426,7 +1426,7 @@ class Updater(object): ) statements.extend([ f"INSERT INTO files({cols}) SELECT {old_cols} FROM files_old", - f"DROP TABLE files_old", + "DROP TABLE files_old", ]) statements.extend(Updater.indexData2Raw(index)) return statements