-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Add with_privileges parameter to SSHConnection for elevated com #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for running SSH commands with elevated privileges through a new with_privileges parameter and improves command escaping for safer privilege escalation.
Key Changes:
- Added
with_privilegesparameter toSSHConnectionto enable sudo-based command execution - Refactored
_adjust_commandmethod to properly escape quotes in echo commands before applying sudo - Changed quote style in
write_textmethod from double to single quotes for better shell compatibility
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| mfd_connect/ssh.py | Added with_privileges parameter and improved command adjustment logic for privilege escalation |
| mfd_connect/pathlib/path.py | Changed quoting style in write_text from double to single quotes |
| README.md | Updated constructor documentation to include the new with_privileges parameter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
We don't publish DEVs .whl. |
1 similar comment
|
We don't publish DEVs .whl. |
…mand execution Signed-off-by: Lasota, Adrian <adrian.lasota@intel.com>
Signed-off-by: Mateusz Chrominski <mateusz.chrominski@intel.com>
aff57a6 to
00caf30
Compare
|
We don't publish DEVs .whl. |
This pull request introduces support for running SSH commands with elevated privileges (using
sudo) and improves command handling for writing text to remote files. The main changes include adding a newwith_privilegesparameter to theSSHConnectionclass, updating documentation to reflect this, and refining how commands are constructed for privilege escalation and text writing.Privilege escalation support:
with_privilegesparameter to theSSHConnectionconstructor, allowing users to specify whether commands should be executed with elevated privileges (sudo). This is now reflected in both the code (mfd_connect/ssh.py) and documentation (README.md). [1] [2]self.__use_sudobased on thewith_privilegesparameter, ensuring commands are executed with the correct privilege level._adjust_commandmethod to properly escape quotes in commands containingechoand applysudoonly when needed, making privilege escalation safer and more reliable.Documentation updates:
README.mdnow documents the newwith_privilegesparameter forSSHConnection, explaining its purpose and usage.Command construction improvements:
write_textmethod inpath.pyfrom double quotes to single quotes, reducing issues with shell escaping and improving reliability when writing text to remote files.