opennms.spec file tries to find out if gid 1000 is used but doesn't actually check hat
Description
I have tried to update to 29 from 28.1.1 and the opennms-core failed with errors:
groupadd: GID '1000' already exists useradd: group 'opennms' does not exist error: %pre(opennms-core-29.0.0-1.noarch) scriptlet failed, exit status 6 Error in PREIN scriptlet in rpm package opennms-core-29.0.0-1.noarch {{ Updating : opennms-webapp-jetty-29.0.0-1.noarch 2/6 }} error: opennms-core-29.0.0-1.noarch: install failed warning: user opennms does not exist - using root warning: group opennms does not exist - using root ...
It's supposed to check if gid number 1000 is used or not, but in fact only shows the effective gid of the user with uid 1000.
Now if you don't have a user with uid 1000 but you do have a group with gid 1000 this completely breaks the update as neither opennms user nor group gets created but used a lot afterwards...
To be honest: I don't like using fixed gid or uid numbers anyway. By default, 1000 is the first id number for standard accounts, not system accounts.
Just let the system allocate a number and don't try to force 1000 onto it...
Yeah, I didn't plan on starting with 1000 but IIRC it was decided to do it this way to try to match the accounts used in other places. (docker I think?) I agree that trying to force it to 1000 is probably more trouble than it's worth, though.
Benjamin Reed November 11, 2021 at 8:08 PM
Yeah, ubuntu/debian already have their own provisions/tools for creating "service accounts"; it's a bit harder to standardize on the RPM side since there are a billion RPM-based distros with different tools and such.
Ronny Trommer November 11, 2021 at 12:39 PM
I've tested today a fresh install of Horizon 29.0.0 on Debian 11, Ubuntu 20.04 LTS, and CentOS 8. The OpenNMS accounts where created as the following:
CentOS 8: opennms:x:995:992:OpenNMS service account:/opt/opennms:/sbin/nologin
I have tried to update to 29 from 28.1.1 and the opennms-core failed with errors:
groupadd: GID '1000' already exists
useradd: group 'opennms' does not exist
error: %pre(opennms-core-29.0.0-1.noarch) scriptlet failed, exit status 6
Error in PREIN scriptlet in rpm package opennms-core-29.0.0-1.noarch
{{ Updating : opennms-webapp-jetty-29.0.0-1.noarch 2/6 }}
error: opennms-core-29.0.0-1.noarch: install failed
warning: user opennms does not exist - using root
warning: group opennms does not exist - using root
...
The problem is here:
https://github.com/OpenNMS/opennms/blob/197be4074c778465fb286901e2332223e550a16d/tools/packages/opennms/opennms.spec#L883
if ! id -g 1000 >/dev/null 2>&1; then
It's supposed to check if gid number 1000 is used or not, but in fact only shows the effective gid of the user with uid 1000.
Now if you don't have a user with uid 1000 but you do have a group with gid 1000 this completely breaks the update as neither opennms user nor group gets created but used a lot afterwards...
To be honest: I don't like using fixed gid or uid numbers anyway. By default, 1000 is the first id number for standard accounts, not system accounts.
Just let the system allocate a number and don't try to force 1000 onto it...