From 4d8ca48bd712d73efa5596746d02ddc6c1cfddf0 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sun, 6 Aug 2023 22:51:18 +0200 Subject: [PATCH] Allow for removing "Guest" from permission hierarchy without messing up access. Resolve #3247 --- CHANGELOG.md | 1 + evennia/locks/lockfuncs.py | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a10238f47..5082afff88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Fix: Webclient was not giving a proper error when sending an unknown outputfunc to it. - Fix: Make `py` command always send strings unless `client_raw` flag is set. - Fix: `Script.start` with an integer `start_delay` caused a traceback. +- Fix: Removing "Guest" from the permission-hierarchy setting messed up access. - Docs: Remove doc pages for Travis/TeamCity CI tools, they were both very much out of date, and Travis is not free for OSS anymore. - Docs: A lot fixes of typos and bugs in tutorials. diff --git a/evennia/locks/lockfuncs.py b/evennia/locks/lockfuncs.py index 0f5a7733b6..f6e67644ef 100644 --- a/evennia/locks/lockfuncs.py +++ b/evennia/locks/lockfuncs.py @@ -17,7 +17,6 @@ a certain object type. from ast import literal_eval from django.conf import settings - from evennia.utils import utils _PERMISSION_HIERARCHY = [pe.lower() for pe in settings.PERMISSION_HIERARCHY] @@ -127,7 +126,7 @@ def perm(accessing_obj, accessed_obj, *args, **kwargs): hpos_target = None if permission in _PERMISSION_HIERARCHY: hpos_target = _PERMISSION_HIERARCHY.index(permission) - if permission.endswith("s") and permission[:-1] in _PERMISSION_HIERARCHY: + elif permission.endswith("s") and permission[:-1] in _PERMISSION_HIERARCHY: hpos_target = _PERMISSION_HIERARCHY.index(permission[:-1]) if hpos_target is not None: # hieratchy match @@ -142,7 +141,7 @@ def perm(accessing_obj, accessed_obj, *args, **kwargs): for hpos, hperm in enumerate(_PERMISSION_HIERARCHY) if hperm in perms_account_single ] - hpos_account = hpos_account and hpos_account[-1] or -1 + hpos_account = hpos_account[-1] if hpos_account else -1 if not account or is_quell: # only get the object-level perms if there is no account or quelling @@ -152,7 +151,7 @@ def perm(accessing_obj, accessed_obj, *args, **kwargs): for hpos, hperm in enumerate(_PERMISSION_HIERARCHY) if hperm in perms_object_single ] - hpos_object = hpos_object and hpos_object[-1] or -1 + hpos_object = hpos_object[-1] if hpos_object else -1 if account and is_quell: # quell mode: use smallest perm from account and object