Skip to content

Commit 779324d

Browse files
authored
Merge pull request #1247 from liangxin1300/20230921_user_of_sudoer_crmsh46
[crmsh-4.6] Fix: utils: Add 'sudo' only when there is a sudoer(bsc#1215549)
2 parents 576a86e + 5a9bb15 commit 779324d

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
@@ -1374,7 +1374,7 @@ def start_slave_collector(node, arg_str):
13741374
logger.warning(err)
13751375
break
13761376
if err:
1377-
print(err)
1377+
print(err, file=sys.stderr)
13781378

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

crmsh/user_of_host.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ def _get_user_of_host_from_config(host):
9898
def _guess_user_for_ssh(host: str) -> typing.Tuple[str, str]:
9999
args = ['ssh']
100100
args.extend(constants.SSH_OPTION_ARGS)
101-
args.extend(['-o', 'BatchMode=yes', host, 'sudo', 'true'])
101+
if userdir.get_sudoer():
102+
args.extend(['-o', 'BatchMode=yes', host, 'sudo', 'true'])
103+
else:
104+
args.extend(['-o', 'BatchMode=yes', host, 'true'])
102105
rc = subprocess.call(
103106
args,
104107
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)