[PATCH 0/7] Second batch of fixes reported during Fedora package review
This series fixes one issue in passt itself, reported by Daniel from a rpmlint warning, and implements six recommendations in the spec file, also from Daniel. Stefano Brivio (7): util: Drop any supplementary group before dropping privileges fedora: Adopt versioning guideline for snapshots fedora: Drop SPDX identifier from spec file fedora: Drop comment stating the spec file is an example file fedora: Define git_hash in spec file and reuse it fedora: Use full versioning for SELinux subpackage Requires: tag fedora: Pass explicit bindir, mandir, docdir, and drop OpenSUSE override contrib/fedora/passt.spec | 18 +++++++----------- contrib/fedora/rpkg.macros | 7 +++++-- util.c | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) -- 2.35.1
Commit a951e0b9efcb ("conf: Add --runas option, changing to given UID
and GID if started as root") dropped the call to initgroups() that
used to add supplementary groups corresponding to the user we'll
eventually run as -- we don't need those.
However, if the original user belongs to supplementary groups
(usually not the case, if started as root), we don't drop those,
now, and rpmlint says:
passt.x86_64: E: missing-call-to-setgroups-before-setuid /usr/bin/passt
passt.x86_64: E: missing-call-to-setgroups-before-setuid /usr/bin/passt.avx2
Add a call to setgroups() with an empty set, to drop any
supplementary group we might currently have, before changing GID
and UID.
Reported-by: Daniel P. Berrangé
On Mon, Aug 29, 2022 at 05:17:03PM +0200, Stefano Brivio wrote:
Commit a951e0b9efcb ("conf: Add --runas option, changing to given UID and GID if started as root") dropped the call to initgroups() that used to add supplementary groups corresponding to the user we'll eventually run as -- we don't need those.
However, if the original user belongs to supplementary groups (usually not the case, if started as root), we don't drop those, now, and rpmlint says:
passt.x86_64: E: missing-call-to-setgroups-before-setuid /usr/bin/passt passt.x86_64: E: missing-call-to-setgroups-before-setuid /usr/bin/passt.avx2
Add a call to setgroups() with an empty set, to drop any supplementary group we might currently have, before changing GID and UID.
Reported-by: Daniel P. Berrangé
Signed-off-by: Stefano Brivio
Reviewed-by: David Gibson
--- util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util.c b/util.c index 9b87b65..7e10deb 100644 --- a/util.c +++ b/util.c @@ -525,7 +525,7 @@ void check_root(struct ctx *c) #endif }
- if (!setgid(c->gid) && !setuid(c->uid)) + if (!setgroups(0, NULL) && !setgid(c->gid) && !setuid(c->uid)) return;
fprintf(stderr, "Can't change user/group, exiting");
-- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
The "Simple versioning" scheme:
https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/#_simpl...
probably doesn't apply to passt, given that upstream git tags are
not really releases. Switch to the "Snapshots" versioning scheme:
https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/#_simpl...
Suggested-by: Daniel P. Berrangé
On Mon, 29 Aug 2022 17:17:04 +0200
Stefano Brivio
The "Simple versioning" scheme: https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/#_simpl...
probably doesn't apply to passt, given that upstream git tags are not really releases. Switch to the "Snapshots" versioning scheme: https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/#_simpl...
https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/#_snaps... -- Stefano
...which makes it fall under MIT licensing terms. Daniel reports that
it's very unusual for spec files to contain explicit licensing terms
and might cause minor inconveniences later on, on mass changes to
spec files.
I originally added licensing information using SPDX identifiers to
make the project fully compliant with the REUSE Specification 3.0
(https://reuse.software/spec/), but there are anyway a few more files
not including explicit licensing information. It might be worth to
fix that later on, in any case.
Suggested-by: Daniel P. Berrangé
...as this ends up in the actual spec file.
Suggested-by: Daniel P. Berrangé
...as it's used twice. The short version, however, appears hardcoded
only once in the output, and it comes straight from the rpkg macro
building the version string -- leave that macro as it is.
Suggested-by: Daniel P. Berrangé
...as recommended in:
https://docs.fedoraproject.org/en-US/packaging-guidelines/#_requiring_base_p...
Reported-by: Daniel P. Berrangé
Fedora's parameters currently match the ones from the Makefile (which
is based on GNU recommendations), but that's not necessarily
guaranteed.
This should make the OpenSUSE Tumbleweed override for docdir
unnecessary: drop it.
Suggested-by: Daniel P. Berrangé
On Mon, 29 Aug 2022 17:17:09 +0200
Stefano Brivio
Fedora's parameters currently match the ones from the Makefile (which is based on GNU recommendations), but that's not necessarily guaranteed.
This should make the OpenSUSE Tumbleweed override for docdir unnecessary: drop it.
Suggested-by: Daniel P. Berrangé
Signed-off-by: Stefano Brivio --- contrib/fedora/passt.spec | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/contrib/fedora/passt.spec b/contrib/fedora/passt.spec index a8af326..ca22d38 100644 --- a/contrib/fedora/passt.spec +++ b/contrib/fedora/passt.spec @@ -49,10 +49,8 @@ This package adds SELinux enforcement to passt(1) and pasta(1). %make_build
%install -%if 0%{?suse_version} > 910 -%make_install DESTDIR=%{buildroot} prefix=%{_prefix} docdir=%{_prefix}/share/doc/packages/passt -%else -%make_install DESTDIR=%{buildroot} prefix=%{_prefix} +%make_install DESTDIR=%{buildroot} prefix=%{_prefix} bindir=%{_bindir} mandir=%{_mandir} docdir=%{_docdir}/passt + %endif
Oops, I forgot to complete a rebase before sending this: this %endif goes away of course. -- Stefano
participants (2)
-
David Gibson
-
Stefano Brivio