File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -132,17 +132,16 @@ def is_remote(self) -> bool:
132
132
@property
133
133
def support_sudo (self ) -> bool :
134
134
self .initialize ()
135
-
136
135
# self._support_sudo already set, return it directly.
137
136
if self ._support_sudo is not None :
138
137
return self ._support_sudo
139
138
140
- if not self .is_posix :
141
- # Windows or non-POSIX: assume sudo not needed
139
+ if self .is_posix :
140
+ self ._support_sudo = self ._check_sudo_available ()
141
+ else :
142
+ # set Windows to true to ignore sudo asks.
142
143
self ._support_sudo = True
143
- return self ._support_sudo
144
144
145
- self ._support_sudo = self ._check_sudo_available ()
146
145
return self ._support_sudo
147
146
148
147
def _check_sudo_available (self ) -> bool :
@@ -157,8 +156,13 @@ def _check_sudo_available(self) -> bool:
157
156
process = self ._execute ("ls" , shell = True , sudo = True , no_info_log = True )
158
157
result = process .wait_result (10 )
159
158
if result .exit_code != 0 :
160
- self .log .debug ("node doesn't support sudo /bin/sh." )
161
- return False
159
+ # e.g. raw error: "user is not allowed to execute '/bin/sh -c ...'"
160
+ if "not allowed" in result .stderr :
161
+ self .log .debug (
162
+ "The command 'sudo /bin/sh -c ls' may fail due to SELinux policies"
163
+ " that restrict the use of sudo in combination with /bin/sh."
164
+ )
165
+ return False
162
166
163
167
return True
164
168
You can’t perform that action at this time.
0 commit comments