From 94d605040c3ff3c8e7dbe19d818e2c9c047a8744 Mon Sep 17 00:00:00 2001 From: wangxiaomeng Date: Thu, 9 May 2024 03:26:42 +0800 Subject: [PATCH] Backport patch:fix permission denied error when lock file is placed in /tmp --- ...ssion-denied-error-when-lock-file-is.patch | 36 +++++++++++++++++++ python-filelock.spec | 6 +++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 0001-BugFix-fix-permission-denied-error-when-lock-file-is.patch diff --git a/0001-BugFix-fix-permission-denied-error-when-lock-file-is.patch b/0001-BugFix-fix-permission-denied-error-when-lock-file-is.patch new file mode 100644 index 0000000..78e90a9 --- /dev/null +++ b/0001-BugFix-fix-permission-denied-error-when-lock-file-is.patch @@ -0,0 +1,36 @@ +From 9a6437521131490a72e68813164885cecfd1232d Mon Sep 17 00:00:00 2001 +From: kota-iizuka <64062831+kota-iizuka@users.noreply.github.com> +Date: Mon, 25 Mar 2024 23:24:53 +0900 +Subject: [PATCH] [BugFix] fix permission denied error when lock file is placed + in `/tmp` (#317) + +--- + src/filelock/_unix.py | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/src/filelock/_unix.py b/src/filelock/_unix.py +index 4ee6033..4ae1fbe 100644 +--- a/src/filelock/_unix.py ++++ b/src/filelock/_unix.py +@@ -4,6 +4,7 @@ import os + import sys + from contextlib import suppress + from errno import ENOSYS ++from pathlib import Path + from typing import cast + + from ._api import BaseFileLock +@@ -35,7 +36,9 @@ else: # pragma: win32 no cover + + def _acquire(self) -> None: + ensure_directory_exists(self.lock_file) +- open_flags = os.O_RDWR | os.O_CREAT | os.O_TRUNC ++ open_flags = os.O_RDWR | os.O_TRUNC ++ if not Path(self.lock_file).exists(): ++ open_flags |= os.O_CREAT + fd = os.open(self.lock_file, open_flags, self._context.mode) + with suppress(PermissionError): # This locked is not owned by this UID + os.fchmod(fd, self._context.mode) +-- +2.33.0 + diff --git a/python-filelock.spec b/python-filelock.spec index f8bae87..f392b6e 100644 --- a/python-filelock.spec +++ b/python-filelock.spec @@ -1,10 +1,11 @@ Name: python-filelock Version: 3.13.1 -Release: 1 +Release: 2 Summary: A platform independent file lock License: Unlicense URL: https://github.com/benediktschmitt/py-filelock Source0: https://files.pythonhosted.org/packages/70/70/41905c80dcfe71b22fb06827b8eae65781783d4a14194bce79d16a013263/filelock-3.13.1.tar.gz +Patch0: 0001-BugFix-fix-permission-denied-error-when-lock-file-is.patch BuildArch: noarch @@ -62,6 +63,9 @@ pytest %doc README.md %changelog +* Thu May 09 2024 wangxiaomeng - 3.13.1-2 +- Backport patch:fix permission denied error when lock file is placed in /tmp + * Wed Dec 06 2023 jiangxinyu - 3.13.1-1 - Update package to version 3.13.1