aboutsummaryrefslogtreecommitdiffstats
path: root/webmap-download
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2025-04-28 17:40:39 +0200
committerGuilhem Moulin <guilhem@fripost.org>2025-04-28 18:12:14 +0200
commita06c77784468f071508ee432c0b0f6d58accbc21 (patch)
tree04fbc34ccf5116ba7fa8698b6f87c1fde7566895 /webmap-download
parentae4de42894153eba76a34e15df7582b2071e66a5 (diff)
Set and restore umask to ensure lockfiles are atomically created with mode 0664.
Using the default 0022 yields lock files with g-w, so trying to flock(2) from a different user failed.
Diffstat (limited to 'webmap-download')
-rwxr-xr-xwebmap-download11
1 files changed, 8 insertions, 3 deletions
diff --git a/webmap-download b/webmap-download
index 087e7fc..fcbbd16 100755
--- a/webmap-download
+++ b/webmap-download
@@ -310,10 +310,15 @@ def main() -> NoReturn:
# place an exclusive lock on a lockfile as the destination can be used by other layers
# hence might be updated in parallel
if lockdir_fd is not None:
+ umask = os.umask(0o002)
lockfile = getSourcePathLockFileName(dest)
- # use O_TRUNC to bump lockfile's mtime
- lock_fd = os.open(lockfile, O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, mode=0o664,
- dir_fd=lockdir_fd)
+ try:
+ # use O_TRUNC to bump lockfile's mtime
+ lock_fd = os.open(lockfile, O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, mode=0o664,
+ dir_fd=lockdir_fd)
+ finally:
+ os.umask(umask)
+
try:
if lockdir_fd is not None:
logging.debug('flock("%s", LOCK_EX)', lockfile)