From be0086f15b19fd93d9d27581faed5fbf32d79aaf Mon Sep 17 00:00:00 2001 From: Andrew Walker Date: Fri, 6 Sep 2024 08:55:51 -0600 Subject: [PATCH] Fix --- src/middlewared/middlewared/utils/user_api_key.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/middlewared/middlewared/utils/user_api_key.py b/src/middlewared/middlewared/utils/user_api_key.py index 21ef30e4f0dfb..673a4c7a8c1ee 100644 --- a/src/middlewared/middlewared/utils/user_api_key.py +++ b/src/middlewared/middlewared/utils/user_api_key.py @@ -16,7 +16,7 @@ PAM_TDB_FILE = os.path.join(PAM_TDB_DIR, 'pam_tdb.tdb') PAM_TDB_DIR_MODE = 0o700 PAM_TDB_VERSION = 1 -PAM_TDB_MAX_TOKENS = 10 # Max number of tokens per user +PAM_TDB_MAX_KEYS = 10 # Max number of keys per user PAM_TDB_OPTIONS = TDBOptions(TDBPathType.CUSTOM, TDBDataType.BYTES) @@ -45,7 +45,7 @@ def _pack_user_auth_key(api_key: UserApiKey) -> bytes: integer, and the userhash converted into a pascal string. """ if not isinstance(api_key, UserApiKey): - raise TypeError(f'{type(token)}: not a UserAuthToken') + raise TypeError(f'{type(api_key)}: not a UserAuthToken') userhash = api_key.userhash.encode() + b'\x00' return pack(f' None: raise TypeError(f'{type(entry)}: expected UserAuthToken') key_cnt = len(entry.keys) - if token_cnt > PAM_TDB_MAX_TOKENS: - raise ValueError(f'{token_cnt}: count of entries exceeds maximum') + if key_cnt > PAM_TDB_MAX_KEYS: + raise ValueError(f'{key_cnt}: count of entries exceeds maximum') entry_bytes = pack('