Skip to content

Conversation

@adrianlasota
Copy link
Contributor

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 new with_privileges parameter to the SSHConnection class, updating documentation to reflect this, and refining how commands are constructed for privilege escalation and text writing.

Privilege escalation support:

  • Added a new with_privileges parameter to the SSHConnection constructor, 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]
  • Updated the internal logic to set self.__use_sudo based on the with_privileges parameter, ensuring commands are executed with the correct privilege level.
  • Improved the _adjust_command method to properly escape quotes in commands containing echo and apply sudo only when needed, making privilege escalation safer and more reliable.

Documentation updates:

  • The README.md now documents the new with_privileges parameter for SSHConnection, explaining its purpose and usage.

Command construction improvements:

  • Changed the quoting in the write_text method in path.py from double quotes to single quotes, reducing issues with shell escaping and improving reliability when writing text to remote files.

Copilot AI review requested due to automatic review settings December 9, 2025 09:30
@adrianlasota adrianlasota changed the title feat: Add with_privileges parameter to SSHConnection for elevated com… #7 feat: Add with_privileges parameter to SSHConnection for elevated com Dec 9, 2025
Copy link

Copilot AI left a 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_privileges parameter to SSHConnection to enable sudo-based command execution
  • Refactored _adjust_command method to properly escape quotes in echo commands before applying sudo
  • Changed quote style in write_text method 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.

@mfd-intel-bot
Copy link

We don't publish DEVs .whl.
To build .whl, run 'pip install git+https://github.com/intel/mfd-connect@enable_sudo'

1 similar comment
@mfd-intel-bot
Copy link

We don't publish DEVs .whl.
To build .whl, run 'pip install git+https://github.com/intel/mfd-connect@enable_sudo'

adrianlasota and others added 2 commits December 10, 2025 12:19
…mand execution

Signed-off-by: Lasota, Adrian <adrian.lasota@intel.com>
Signed-off-by: Mateusz Chrominski <mateusz.chrominski@intel.com>
@mfd-intel-bot
Copy link

We don't publish DEVs .whl.
To build .whl, run 'pip install git+https://intel/mfd-connect@enable_sudo'

@coveralls-official
Copy link

Coverage Status

coverage: 75.941% (+0.01%) from 75.93%
when pulling 00caf30 on enable_sudo
into 35cd452 on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants