Open drawks opened 1 year ago
Just after hitting "create" on this issue I also noticed that the scriptlets delete the consul
user in the postuninstall
scriptlet if they receive purge
as the first argument to the script. Deleting users/groups in scriptlets is very expressly forbidden in the Fedora packaging guidelines, but this code path doesn't actually seem reachable as rpm/yum/dnf do not use the purge
argument; it appears that this is perhaps an artifact of deb
/apt
packaging and/or the use of a tool like alien
or fpm
to generate multiple platform specific packages simultaneously. I'd advise against using such tools as they tend to result in the types of issues as I've detailed here.
I just spent a little while crawling through the github actions that are used to for building the release artifacts and see now that nfpm is being used to generate both deb and rpm packages. So naturally these scripts should be compliant with the policy requirements and expectations of both flavors of linux distro. I'll see if I can float a PR that addresses my above issues with the rpm packaging and also make similar changes where needed for debian policy compliance.
Overview of the Issue
When using the rpm packages as provided by this project during install or upgrade scriptlets present in the package
During installation/upgrade of the rpm packages provided by this project several scriptlets are run which do the following:
consul
system user and group/opt/consul
/etc/consul.d
and/opt/consul
While these actions are made with good intent they are in some cases fully in violation of the fedora/redhat packaging guidelines and in other cases implemented in a way which can create subtle and disruptive problems for users.
soft allocation
strategy as is documented by fedora or if compatibility with older or more divergent redhat/fedora-alike distros should use the older example also provided by the Fedora project. Either methods prevents a number of corner cases related to user and group creation which have been well thought out and battle tested over many years and versions of Fedora/RedHat./opt/consul
in the rpm scriptlets prevents this directory from being owned by the package and also sidesteps the normal creation of the system user home directory. There is no hard requirement for this directory to exist for consul to run aside from the fact that this is the default directory used by the default consul configuration as shipped. As such it would be more appropriate for creation of thsi directory to happen in the systemd service unit as anExecStartPre
action which uses anEnvironment
to set the desired path. This would allow operators to override the location of this directory. Something like:Recursively changing ownership/group of
/opt/consul
and/etc/consul.d
is actually VERY problematic because any file can be present in either of these directories and there should be a general expectation that file with a given owner/group and mode will retain that owner group and mode until an operator explicitly changes them (manually or config management etc). The current rpm can make files which were previously root owned and only readable by their owner spontaneously become readable by theconsul
user. The rpm package should only be managing ownership/group of its own packaged files. The spec file from which the rpm is generated does not appear to be present in this repository, but looking at the metadata usingrpm --query
we can see which config files are shipped by the package and marked as config files and that they are owned byroot
as opposed toconsul
:consul
user nor do they in their default state contain any secrets. Additionally since they are marked as config files, should an operator replace these files, change their owner/group/mode or modify the contents the rpm/yum/dnf package manager will not replace the locally modified files with their packaged defaults. This behavior is expected and safe as opposed to the current rpm's behavior.upgrade | [1-9]*) if [ -d "/run/systemd/system" ]; then systemctl try-restart consul.service >/dev/null || : fi ;; esac
Reproduction Steps
rpm -q --scripts consul
and observe that all of the above details of how the rpm package scriptlets behave is true.Operating system and Environment details
Any currently supported rpm based distribution as detailed in Hasicorp's packaging guide, currently: