Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/facter/sudoversion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
setcode do
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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

match[1] if match
elsif Facter::Util::Resolution.which('rpm')
Facter::Util::Resolution.exec('rpm -q sudo --qf \'%{VERSION}\'')
elsif Facter::Util::Resolution.which('dpkg-query')
Expand Down
Loading