Skip to content

Commit 31960c8

Browse files
committed
Fix overly permissive file permissions in luigi/lock.py
Fixes spotify#3303 Update file permissions in `luigi/lock.py` to be more restrictive. * Change the file permissions of the `pid_dir` directory from `0o777` to `0o700` in the `acquire_for` function. * Update the test cases `test_acquiring_partially_taken_lock` and `test_acquiring_lock_from_missing_process` in `test/lock_test.py` to check for the new file permissions `0o700`.
1 parent 3ce0f62 commit 31960c8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

luigi/lock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def acquire_for(pid_dir, num_available=1, kill_signal=None):
100100
# Create a pid file if it does not exist
101101
try:
102102
os.mkdir(pid_dir)
103-
os.chmod(pid_dir, 0o777)
103+
os.chmod(pid_dir, 0o700)
104104
except OSError as exc:
105105
if exc.errno != errno.EEXIST:
106106
raise

test/lock_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def test_acquiring_partially_taken_lock(self):
100100
self.assertTrue(acquired)
101101

102102
s = os.stat(self.pid_file)
103-
self.assertEqual(s.st_mode & 0o777, 0o777)
103+
self.assertEqual(s.st_mode & 0o700, 0o700)
104104

105105
def test_acquiring_lock_from_missing_process(self):
106106
fake_pid = 99999
@@ -111,7 +111,7 @@ def test_acquiring_lock_from_missing_process(self):
111111
self.assertTrue(acquired)
112112

113113
s = os.stat(self.pid_file)
114-
self.assertEqual(s.st_mode & 0o777, 0o777)
114+
self.assertEqual(s.st_mode & 0o700, 0o700)
115115

116116
@mock.patch('os.kill')
117117
def test_take_lock_with_kill(self, kill_fn):

0 commit comments

Comments
 (0)