Skip to content

Commit 8b3c138

Browse files
authored
Merge pull request #1254 from liangxin1300/20230921_user_of_sudoer_crmsh45
[crmsh-4.5] Fix: utils: Add 'sudo' only when there is a sudoer(bsc#1215549)
2 parents 4c7bd70 + eb6a2dd commit 8b3c138

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

crmsh/report/utillib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ def start_slave_collector(node, arg_str):
13731373
logger.warning(err)
13741374
break
13751375
if err:
1376-
print(err)
1376+
print(err, file=sys.stderr)
13771377

13781378
if out == '': # if we couldn't get anything
13791379
return

crmsh/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ def _get_user_of_host_from_config(host):
184184
def _guess_user_for_ssh(host: str) -> typing.Tuple[str, str]:
185185
args = ['ssh']
186186
args.extend(constants.SSH_OPTION_ARGS)
187-
args.extend(['-o', 'BatchMode=yes', host, 'sudo', 'true'])
187+
if userdir.get_sudoer():
188+
args.extend(['-o', 'BatchMode=yes', host, 'sudo', 'true'])
189+
else:
190+
args.extend(['-o', 'BatchMode=yes', host, 'true'])
188191
rc = subprocess.call(
189192
args,
190193
stdin=subprocess.DEVNULL,

test/features/cluster_api.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ Feature: Functional test to cover SAP clusterAPI
1818
And Wait "3" seconds
1919
Then Resource "d" type "Dummy" is "Started"
2020
And Show cluster status on "hanode1"
21+
When Run "echo 'export PATH=$PATH:/usr/sbin/' > ~hacluster/.bashrc" on "hanode1"
22+
When Run "echo 'export PATH=$PATH:/usr/sbin/' > ~hacluster/.bashrc" on "hanode2"
2123

2224
@clean
2325
Scenario: Start and stop resource by hacluster
24-
When Run "echo 'export PATH=$PATH:/usr/sbin/' >> ~hacluster/.bashrc" on "hanode1"
25-
When Run "echo 'export PATH=$PATH:/usr/sbin/' >> ~hacluster/.bashrc" on "hanode2"
2626
When Run "su - hacluster -c 'crm resource stop d'" on "hanode1"
2727
Then Expected return code is "0"
2828
When Wait "3" seconds

0 commit comments

Comments
 (0)