Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure permissions of saved files adhere to umask setting #832

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

osma
Copy link
Member

@osma osma commented Feb 3, 2025

Fixes #829

Many types of files saved by Annif using the atomic_save() operation had tighter permissions than expected. This is because they were first saved as temporary files, then renamed.

This PR makes sure that the file permissions respect the umask setting. The unit test verifies that this works using different commonly used umask values.

@osma osma added the bug label Feb 3, 2025
@osma osma added this to the 1.3 milestone Feb 3, 2025
@osma osma self-assigned this Feb 3, 2025
@osma osma requested a review from juhoinkinen February 3, 2025 14:41
Copy link

codecov bot commented Feb 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.63%. Comparing base (e491b3f) to head (bd0eac2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #832   +/-   ##
=======================================
  Coverage   99.63%   99.63%           
=======================================
  Files          95       95           
  Lines        7182     7210   +28     
=======================================
+ Hits         7156     7184   +28     
  Misses         26       26           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

sonarqubecloud bot commented Feb 3, 2025

@juhoinkinen
Copy link
Member

I quickly trained some projects with the code in this PR, and noted that while atomic_save() now behaves as expected permission-wise, the nn-train.mdb/ directory and the files in it (created by NN ensemble backend) does not get the permissions following umask; e.g. with umask for read-write for group, 0007, the write bit is missing:

$ ls -ld data-tmp/./projects/nn-ensemble-fi/nn-train.mdb/
drwxr-x--- 2 <myuser> <mygroup>  4096 Feb  4 17:17 data-tmp/./projects/nn-ensemble-fi/nn-train.mdb/

$ ls -l data-tmp/./projects/nn-ensemble-fi/nn-train.mdb/
total 124
-rw-r----- 1 <myuser> <mygroup> 1073741824 Feb  4 17:17 data.mdb
-rw-r----- 1 <myuser> <mygroup>                8192 Feb  4 17:17 lock.mdb

I wonder if there is something that can be done for this too...?

Otherwise LGTM!

@juhoinkinen
Copy link
Member

It looks like lmdb.open() could uses a mode argument, which by default is O_0755. Maybe this could be get from the umask.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Annif does not adhere umask setting for data files
2 participants