The default lark.Lark caching mechanism can fail when utilized on a multi-user system with more than one user due to the default permissions of the cached file. (See the traceback/reproduction steps below.)
User 1 runs the program and lark generates the cache file:
-rw------- 1 user1 group1 28250 Aug 3 09:41 /tmp/.lark_cache_42d962555f1b4b923579d2cfd7bfbbfc_3_9.tmp
User 2 runs the program and lark tries to open from the cache. Read access fails due to permissions on the file:
...
File "env_path/python3.9/site-packages/whatrecord/db.py", line 646, in from_string
grammar = lark.Lark.open_from_package(
File "env_path/python3.9/site-packages/lark/lark.py", line 566, in open_from_package
return cls(text, **options)
File "env_path/python3.9/site-packages/lark/lark.py", line 315, in __init__
with FS.open(cache_fn, 'rb') as f:
File "env_path/python3.9/site-packages/lark/utils.py", line 232, in open
return open(name, mode, **kwargs)
PermissionError: [Errno 13] Permission denied: '/tmp/.lark_cache_bf910f0d49cfefbc0576ce70de8a7dbd_3_9.tmp'
I wonder if the default cache filename format should perhaps also include a username? Read-only permissions for group/other could be okay, too.
Describe the bug
The default
lark.Lark
caching mechanism can fail when utilized on a multi-user system with more than one user due to the default permissions of the cached file. (See the traceback/reproduction steps below.)To Reproduce
-rw------- 1 user1 group1 28250 Aug 3 09:41 /tmp/.lark_cache_42d962555f1b4b923579d2cfd7bfbbfc_3_9.tmp
I wonder if the default cache filename format should perhaps also include a username? Read-only permissions for group/other could be okay, too.