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
diff --git a/plainbox/impl/execution.py b/plainbox/impl/execution.py
index 38c1221..8c93f16 100644
--- a/plainbox/impl/execution.py
+++ b/plainbox/impl/execution.py
@@ -265,7 +265,9 @@ class UnifiedRunner(IJobRunner):
265 extcmd_popen._delegate.on_end(proc.returncode)265 extcmd_popen._delegate.on_end(proc.returncode)
266 return proc.returncode266 return proc.returncode
267 if not os.path.isdir(os.path.join(self._session_dir, "CHECKBOX_DATA")):267 if not os.path.isdir(os.path.join(self._session_dir, "CHECKBOX_DATA")):
268 oldmask = os.umask(000)
268 os.makedirs(os.path.join(self._session_dir, "CHECKBOX_DATA"))269 os.makedirs(os.path.join(self._session_dir, "CHECKBOX_DATA"))
270 os.umask(oldmask)
269 # Setup the executable nest directory271 # Setup the executable nest directory
270 with self.configured_filesystem(job) as nest_dir:272 with self.configured_filesystem(job) as nest_dir:
271 # Get the command and the environment.273 # Get the command and the environment.
diff --git a/plainbox/impl/session/assistant.py b/plainbox/impl/session/assistant.py
index 4888730..8ef05e7 100644
--- a/plainbox/impl/session/assistant.py
+++ b/plainbox/impl/session/assistant.py
@@ -1328,7 +1328,9 @@ class SessionAssistant:
1328 checkbox_data_dir = os.path.join(1328 checkbox_data_dir = os.path.join(
1329 self.get_session_dir(), 'CHECKBOX_DATA')1329 self.get_session_dir(), 'CHECKBOX_DATA')
1330 if not os.path.exists(checkbox_data_dir):1330 if not os.path.exists(checkbox_data_dir):
1331 oldmask = os.umask(000)
1331 os.mkdir(checkbox_data_dir)1332 os.mkdir(checkbox_data_dir)
1333 os.umask(oldmask)
1332 respawn_cmd_file = os.path.join(1334 respawn_cmd_file = os.path.join(
1333 checkbox_data_dir, '__respawn_checkbox')1335 checkbox_data_dir, '__respawn_checkbox')
1334 if self._restart_cmd_callback:1336 if self._restart_cmd_callback:

Subscribers

People subscribed via source and target branches