Changing cache file rigths to 666 so that different users on the same…#686
Open
ivanprado wants to merge 1 commit intofxsjy:masterfrom
Open
Changing cache file rigths to 666 so that different users on the same…#686ivanprado wants to merge 1 commit intofxsjy:masterfrom
ivanprado wants to merge 1 commit intofxsjy:masterfrom
Conversation
… machine could use it concurrently. Otherwise it fails at initialization and cache is not used so there is no inicialization gains in the case of two users running the library in the same machine.
|
To give more details: currently temporary cache file is created with permissions which allow reading and writing only for the current user. It is then moved to the global temp dir (/tmp on Linux), with the same permissions. Once the file is created by one user, other users can't overwrite it. What's worse, they can't even read it. So once cache file is created, jieba cache stops working for all other users, they're getting a traceback in logs each time. |
Contributor
|
Write permission for other users can be a security risk because marshal files cannot be securely loaded. |
Author
|
I understand. You are right. Then I propose to add a username to the
default jieba config file, so that each user has its own cache file.
Something like this:
```python
cache_file = 'jieba.cache.{}'.format(os.getuid())
```
What do you think?
An alternative is to give only read permission... but what if a user needs
to refresh the cache or something like that? I think is better to have one
file per user.
…On Thu, Nov 8, 2018 at 10:01 AM Dingyuan Wang ***@***.***> wrote:
Write permission for other users can be a security risk because marshal
files cannot be securely loaded.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#686 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA2q6EuM_iXZ97q2tC3b8djOm5ZgL8cCks5utADigaJpZM4YS3bU>
.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… machine could use it concurrently.
Otherwise, it fails at initialization and cache is not used so there are no initialization gains in the case of two different users running the library in the same machine.