Merge ~sylvain-pineau/checkbox-ng:fix-persmission-denied-nonroot-jobs into checkbox-ng:master

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: d126bb4480cee979a4e65f4aef35990e893bac9c
Merged at revision: ecbc651c3f837df9cf97aa5535ca5d35a4f4b15e
Proposed branch: ~sylvain-pineau/checkbox-ng:fix-persmission-denied-nonroot-jobs
Merge into: checkbox-ng:master
Diff against target: 28 lines (+4/-0)
2 files modified
plainbox/impl/execution.py (+2/-0)
plainbox/impl/session/assistant.py (+2/-0)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Review via email: mp+375261@code.launchpad.net

Description of the change

Fixes a bug where a slave service is running as root but with jobs executing with a regular user. In such cases, the jobs in question are not allowed to write data to CHECKBOX_DATA.

Eg:

bash: /root/.cache/plainbox/sessions/session_title-2019-11-07T07.19.25.session/CHECKBOX_DATA/cpuinfo_before_suspend: Permission denied

This patch fixes the problem.

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

self-approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/plainbox/impl/execution.py b/plainbox/impl/execution.py
2index 38c1221..8c93f16 100644
3--- a/plainbox/impl/execution.py
4+++ b/plainbox/impl/execution.py
5@@ -265,7 +265,9 @@ class UnifiedRunner(IJobRunner):
6 extcmd_popen._delegate.on_end(proc.returncode)
7 return proc.returncode
8 if not os.path.isdir(os.path.join(self._session_dir, "CHECKBOX_DATA")):
9+ oldmask = os.umask(000)
10 os.makedirs(os.path.join(self._session_dir, "CHECKBOX_DATA"))
11+ os.umask(oldmask)
12 # Setup the executable nest directory
13 with self.configured_filesystem(job) as nest_dir:
14 # Get the command and the environment.
15diff --git a/plainbox/impl/session/assistant.py b/plainbox/impl/session/assistant.py
16index 4888730..8ef05e7 100644
17--- a/plainbox/impl/session/assistant.py
18+++ b/plainbox/impl/session/assistant.py
19@@ -1328,7 +1328,9 @@ class SessionAssistant:
20 checkbox_data_dir = os.path.join(
21 self.get_session_dir(), 'CHECKBOX_DATA')
22 if not os.path.exists(checkbox_data_dir):
23+ oldmask = os.umask(000)
24 os.mkdir(checkbox_data_dir)
25+ os.umask(oldmask)
26 respawn_cmd_file = os.path.join(
27 checkbox_data_dir, '__respawn_checkbox')
28 if self._restart_cmd_callback:

Subscribers

People subscribed via source and target branches