Merge ~sylvain-pineau/checkbox-ng:psutilAccessDenied into checkbox-ng:master

Proposed by Sylvain Pineau
Status: Merged
Approved by: Taihsiang Ho
Approved revision: dbb9b3e1a9340f5f735995beddbd136dc6ddc073
Merged at revision: 464d20e736e767da8b4f9b0abab5ed729eb4649e
Proposed branch: ~sylvain-pineau/checkbox-ng:psutilAccessDenied
Merge into: checkbox-ng:master
Diff against target: 18 lines (+5/-2)
1 file modified
plainbox/impl/session/remote_assistant.py (+5/-2)
Reviewer Review Type Date Requested Status
Taihsiang Ho Approve
Jonathan Cave (community) Approve
Review via email: mp+374956@code.launchpad.net

Description of the change

Avoid a crash if the checkbox slave is started with a normal user (not root).

Note that's not the recommended way since all remote slaves are meant to run as root (from debs and snaps)

To post a comment you must log in.
Revision history for this message
Jonathan Cave (jocave) wrote :

+1

review: Approve
Revision history for this message
Taihsiang Ho (tai271828) wrote :

Thanks for the quick fix. Let's land it and have a try.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/plainbox/impl/session/remote_assistant.py b/plainbox/impl/session/remote_assistant.py
2index 35a5b11..948a5f5 100644
3--- a/plainbox/impl/session/remote_assistant.py
4+++ b/plainbox/impl/session/remote_assistant.py
5@@ -190,8 +190,11 @@ class RemoteSessionAssistant():
6 # If possible also set the DISPLAY env var
7 # i.e when a user desktop session is running
8 for p in psutil.pids():
9- p_environ = psutil.Process(p).environ()
10- p_user = psutil.Process(p).username()
11+ try:
12+ p_environ = psutil.Process(p).environ()
13+ p_user = psutil.Process(p).username()
14+ except psutil.AccessDenied:
15+ continue
16 if ("DISPLAY" in p_environ and p_user != 'gdm'): # gdm uses :1024
17 return {'DISPLAY': p_environ['DISPLAY']}
18 break

Subscribers

People subscribed via source and target branches