puppet-sudo icon indicating copy to clipboard operation
puppet-sudo copied to clipboard

'versioncmp' parameter 'a' expects a String value, got Undef

Open cdenneen opened this issue 4 years ago • 7 comments

Looks like these are still valid issues:

https://github.com/saz/puppet-sudo/issues/264 https://github.com/saz/puppet-sudo/issues/260

cdenneen avatar Dec 06 '21 19:12 cdenneen

Module Version 7.0.2 Puppet Version 6.25.1 CentOS 7

cdenneen avatar Dec 06 '21 19:12 cdenneen

Hello,

This is important, it's broken on all RedHat family at least, since puppet 4 versioncmp function only accepts strings.

Centos: 7.9 Puppet Agent: 7.x

Change line 87 on puppet master from: if (versioncmp($::sudoversion, '1.7.2p1') < 0)

To: if (versioncmp("$::sudoversion", '1.7.2p1') < 0)

nevesigor avatar Jan 06 '22 16:01 nevesigor

I just ran into this issue this past week and found a fix/workaround that might help others before it gets fixed in the sudo module. This was all done with CentOS7, so I am not sure if it would be prevalent in other versions. In the following rb file, it looks like the sudoversion fact is created by running sudo -V 2>&1

https://github.com/saz/puppet-sudo/blob/master/lib/facter/sudoversion.rb

Whenever I tried to run that command manually, I got the following: # sudo --version /var/tmp/scl7Hipfg: line 8: --version: command not found So the module is not getting a valid string when looking up the sudo version. In this instance, the issue is instigated by the version of sudo I have installed. Well, more specifically, a wrapper script that came with devtoolset-7 and was first in my PATH: /opt/rh/devtoolset-7/root/usr/bin/sudo This is known to cause issues with parsing sudo options and has been documented in a few different bug reports, such as:

https://bugzilla.redhat.com/show_bug.cgi?id=1319936

So if you run into errors with the sudo module, check the PATH for sudo to see which one it is using. The fix for this is to either remove /opt/rh/devtoolset-7/root/usr/bin from your PATH or at least prepend /usr/bin/sudo to it. This only needs to happen for the root user since Puppet needs to run as root.

I hope this helps others save some time.

dwest-galois avatar May 25 '22 21:05 dwest-galois

@kilianw can you check, if you're seeing the same as reported by @dwest-galois ? Tests are working fine on CentOS 7 and I'm confused, how's that possible.

saz avatar Jul 17 '22 20:07 saz

@saz - My testing has been successful on CentOS 7, Alma 8 and Ubuntu 20.

The redhat devtoolset isn't installed.

kilianw avatar Aug 09 '22 08:08 kilianw

As this issue is related to some additional package on RedHat, it's not helping to fix the issue by just converting the fact to a string.

Instead, I'd rather change the fact:

  1. If we find sudo as command, check if the full path contains /devtoolset-
  2. If it's the case, prepend /usr/bin/sudo, instead of just using sudo
  3. Maybe the check should be done on RedHat only?

This should keep the fact compatible on all systems and fix it, if the devtools-7 package is installed.

saz avatar Apr 30 '23 10:04 saz