community.general icon indicating copy to clipboard operation
community.general copied to clipboard

Become Plugin pbrun Fails to Find Command due to Quotation Padding from Ansible

Open jamesmarshall24 opened this issue 4 years ago • 7 comments

SUMMARY

Adding quotation padding around commands for privilege escalation breaks pbrun's execution stating "command not found"

ISSUE TYPE
  • Bug Report
COMPONENT NAME

pbrun.py

ANSIBLE VERSION
2.9.11

STEPS TO REPRODUCE
---
- hosts: all
  become_method: pbrun
  become: true
  gather_facts: false
  tasks:
    - shell: echo $PATH

EXPECTED RESULTS

$PATH is echoed to stdout

ACTUAL RESULTS
ssh -o StrictHostKeyChecking=no -o 'User="remote-user"' -o ConnectTimeout=10 -tt remote-host 'pbrun '"'"'echo BECOME-SUCCESS-ofsgdkxshyqguxrkwjyvnujmakxfhuff'"'"''
pbrun9.4.1-03[24202]: 3201.08 Exec of echo BECOME-SUCCESS-ofsgdkxshyqguxrkwjyvnujmakxfhuff
failed: Command not found. Connection to remote-host closed.

jamesmarshall24 avatar Aug 03 '20 20:08 jamesmarshall24

Testing from command line, the above fails but removing quotes around the embedded "pbrun" commands works:

ssh -o StrictHostKeyChecking=no -o 'User="remote-user"' -o ConnectTimeout=10 -tt remote-host 'pbrun echo BECOME-SUCCESS-ofsgdkxshyqguxrkwjyvnujmakxfhuff; echo $PATH'

BECOME-SUCCESS-ofsgdkxshyqguxrkwjyvnujmakxfhuff
/usr/local/bin:/usr/bin

jamesmarshall24 avatar Aug 03 '20 20:08 jamesmarshall24

!component =plugins/become/pbrun.py

felixfontein avatar Aug 03 '20 20:08 felixfontein

Any resolution on this issue?

goutam-ghosh avatar Aug 06 '21 07:08 goutam-ghosh

cc @None click here for bot help

ansibullbot avatar Aug 06 '21 07:08 ansibullbot

I don't think anyone has been working on this plugin. In any case, the history speaks for itself: https://github.com/ansible-collections/community.general/commits/main/plugins/become/pbrun.py (my changes are not related to any functionality except some very generic bug fixing)

felixfontein avatar Aug 06 '21 08:08 felixfontein

pbrun (power broker) with ansible is not working as every time it is giving the error "Command not found"

Exec of echo BECOME-SUCCESS-tsafolemoxcgtbnrzzjvehfja ; /usr/bin/python /users/userid/.ansible/tmp/ansible-tmp-1628238621.82-19572-9510618362995/AnsiballZ_command.py failed: Command not found.

goutam-ghosh avatar Aug 06 '21 08:08 goutam-ghosh

This is something I am seeing too

mpmurphy-aexp avatar Sep 17 '24 14:09 mpmurphy-aexp