Skip to content

Commit

Permalink
Merge pull request #1254 from liangxin1300/20230921_user_of_sudoer_cr…
Browse files Browse the repository at this point in the history
…msh45

[crmsh-4.5] Fix: utils: Add 'sudo' only when there is a sudoer(bsc#1215549)
  • Loading branch information
liangxin1300 authored Dec 5, 2023
2 parents 4c7bd70 + eb6a2dd commit 8b3c138
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crmsh/report/utillib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,7 @@ def start_slave_collector(node, arg_str):
logger.warning(err)
break
if err:
print(err)
print(err, file=sys.stderr)

if out == '': # if we couldn't get anything
return
Expand Down
5 changes: 4 additions & 1 deletion crmsh/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ def _get_user_of_host_from_config(host):
def _guess_user_for_ssh(host: str) -> typing.Tuple[str, str]:
args = ['ssh']
args.extend(constants.SSH_OPTION_ARGS)
args.extend(['-o', 'BatchMode=yes', host, 'sudo', 'true'])
if userdir.get_sudoer():
args.extend(['-o', 'BatchMode=yes', host, 'sudo', 'true'])
else:
args.extend(['-o', 'BatchMode=yes', host, 'true'])
rc = subprocess.call(
args,
stdin=subprocess.DEVNULL,
Expand Down
4 changes: 2 additions & 2 deletions test/features/cluster_api.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ Feature: Functional test to cover SAP clusterAPI
And Wait "3" seconds
Then Resource "d" type "Dummy" is "Started"
And Show cluster status on "hanode1"
When Run "echo 'export PATH=$PATH:/usr/sbin/' > ~hacluster/.bashrc" on "hanode1"
When Run "echo 'export PATH=$PATH:/usr/sbin/' > ~hacluster/.bashrc" on "hanode2"

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

0 comments on commit 8b3c138

Please sign in to comment.