feat: Add with_privileges parameter to SSHConnection for elevated com#9
Open
adrianlasota wants to merge 2 commits intomainfrom
Open
feat: Add with_privileges parameter to SSHConnection for elevated com#9adrianlasota wants to merge 2 commits intomainfrom
adrianlasota wants to merge 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
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.
Contributor
|
We don't publish DEVs .whl. |
1 similar comment
Contributor
|
We don't publish DEVs .whl. |
mchromin
approved these changes
Dec 9, 2025
aff57a6 to
00caf30
Compare
Contributor
|
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>
00caf30 to
d7c3ebe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.