mirror of
https://github.com/evennia/evennia.git
synced 2026-03-17 05:16:31 +01:00
Fixed a bug that caused superuser status to be cached only once for characters, even if the player was not yet connected.
This commit is contained in:
parent
29e313492f
commit
bbdf2e0896
3 changed files with 17 additions and 15 deletions
|
|
@ -136,7 +136,7 @@ class CmdPy(MuxCommand):
|
|||
"""
|
||||
key = "@py"
|
||||
aliases = ["!"]
|
||||
locks = "cmd:perm(py) or perm(Immortals)"
|
||||
locks = "cmd:all()"#"cmd:perm(py) or perm(Immortals)"
|
||||
help_category = "System"
|
||||
|
||||
def func(self):
|
||||
|
|
|
|||
|
|
@ -170,20 +170,7 @@ class LockHandler(object):
|
|||
self.log_obj = None
|
||||
self.reset_flag = False
|
||||
self._cache_locks(self.obj.lock_storage)
|
||||
# we handle bypass checks already here for efficiency. We need to grant access to superusers.
|
||||
# We need to check both directly on the object (players), through obj.player and using the
|
||||
# get_player method (this sits on serversessions, in some rare cases where a check is done
|
||||
# before the login process has yet been fully finalized)
|
||||
self.lock_bypass = ((hasattr(obj, "is_superuser") and obj.is_superuser)
|
||||
or (hasattr(obj, "player") and hasattr(obj.player, "is_superuser") and obj.player.is_superuser)
|
||||
or (hasattr(obj, "get_player") and (not obj.get_player() or obj.get_player().is_superuser)))
|
||||
if obj.key == "Griatch":
|
||||
print "SETTING lock_bypass:", obj, self.lock_bypass, "<-",
|
||||
print (hasattr(obj, "is_superuser") and obj.is_superuser),
|
||||
print (hasattr(obj, "player") and hasattr(obj.player, "is_superuser") and obj.player.is_superuser),
|
||||
print (hasattr(obj, "get_player") and (not obj.get_player() or obj.get_player().is_superuser)),
|
||||
if hasattr(obj, "player"):
|
||||
print obj.player and obj.player.is_superuser
|
||||
self.cache_lock_bypass(obj)
|
||||
|
||||
def __str__(self):
|
||||
return ";".join(self.locks[key][2] for key in sorted(self.locks))
|
||||
|
|
@ -265,6 +252,17 @@ class LockHandler(object):
|
|||
"Store locks to obj"
|
||||
self.obj.lock_storage = ";".join([tup[2] for tup in self.locks.values()])
|
||||
|
||||
def cache_lock_bypass(self, obj):
|
||||
"""
|
||||
We cache superuser bypass checks here for efficiency. This needs to be re-run when a player is assigned to a character.
|
||||
We need to grant access to superusers. We need to check both directly on the object (players), through obj.player and using the
|
||||
get_player method (this sits on serversessions, in some rare cases where a check is done
|
||||
before the login process has yet been fully finalized)
|
||||
"""
|
||||
self.lock_bypass = ((hasattr(obj, "is_superuser") and obj.is_superuser)
|
||||
or (hasattr(obj, "player") and hasattr(obj.player, "is_superuser") and obj.player.is_superuser)
|
||||
or (hasattr(obj, "get_player") and (not obj.get_player() or obj.get_player().is_superuser)))
|
||||
|
||||
def add(self, lockstring, log_obj=None):
|
||||
"""
|
||||
Add a new lockstring on the form '<access_type>:<functions>'. Multiple
|
||||
|
|
|
|||
|
|
@ -256,6 +256,10 @@ class ObjectDB(TypedObject):
|
|||
if inherits_from(player, TypeClass):
|
||||
player = player.dbobj
|
||||
set_field_cache(self, "player", player)
|
||||
# we must set this here or superusers won't be able to
|
||||
# bypass lockchecks unless they start the game connected
|
||||
# to the character in question.
|
||||
self.locks.cache_lock_bypass(self)
|
||||
#@player.deleter
|
||||
def __player_del(self):
|
||||
"Deleter. Allows for del self.player"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue