Update facter regex to work for Rust sudo variant (sudo-rs)#334
Update facter regex to work for Rust sudo variant (sudo-rs)#334saz merged 2 commits intosaz:masterfrom
Conversation
|
Fixes #331. |
There was a problem hiding this comment.
Pull request overview
Updates the custom sudoversion Facter fact parsing to recognize Rust-based sudo-rs output, addressing failures on newer Ubuntu releases.
Changes:
- Expand the
sudo -Voutput regex to match both classicSudo version …andsudo-rs …formats.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| if Facter::Util::Resolution.which('sudo') | ||
| sudoversion = Facter::Util::Resolution.exec('sudo -V 2>&1') | ||
| %r{^Sudo version ([\w.]+)}.match(sudoversion)[1] | ||
| match = %r{^(?:Sudo version|sudo-rs)\s+([\w.]+)}i.match(sudoversion) |
There was a problem hiding this comment.
This silences an error, but may cause existing logic to do the wrong thing as sudo-rs has a very small version number compared to traditional sudo, and the fact does not communicate which is in use.
There was a problem hiding this comment.
You're right about that, thanks for pointing it out. I guess it would be best to add another fact, sudokind or something like that, and extend any version checks to also check for the expected kind of sudo.
What do you think?
There was a problem hiding this comment.
My thought was a new structured fact that contained both the implementation and the version:
{'sudo' => {'version' => '0.2.0', 'type' => 'sudo-rs'}}And then have the existing sudoversion return nil when an unrecognized version string appears. That should prevent any existing logic from thinking sudo-rs is a very old version of sudo and provide a new fact source that pairs the version with the type of implementation.
Pull Request (PR) description
This Pull Request (PR) fixes the following issues