public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Panu Matilainen <pmatilai@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/rpm] pmatilai-v6: Fix sysusers.d generator barfing on legit content (#2246236)
Date: Mon, 23 Nov 2026 09:35:10 GMT	[thread overview]
Message-ID: <179542651041.1.13938495557321254059.rpms-rpm-b0f8f4c9e82d@fedoraproject.org> (raw)

A new commit has been pushed.

Repo   : rpms/rpm
Branch : pmatilai-v6
Commit : b0f8f4c9e82d602f64399df5f0aa643fbc4bba4d
Author : Panu Matilainen <pmatilai@redhat.com>
Date   : 2023-11-13T10:35:50+02:00
Stats  : +186/-0 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/rpm/c/b0f8f4c9e82d602f64399df5f0aa643fbc4bba4d?branch=pmatilai-v6

Log:
Fix sysusers.d generator barfing on legit content (#2246236)

---
diff --git a/rpm-4.19.0-sysusers-fixes.patch b/rpm-4.19.0-sysusers-fixes.patch
new file mode 100644
index 0000000..ba5bdbd
--- /dev/null
+++ b/rpm-4.19.0-sysusers-fixes.patch
@@ -0,0 +1,184 @@
+From fff4b0b2249223fccddcce9eea8658ddd12f30a0 Mon Sep 17 00:00:00 2001
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Fri, 3 Nov 2023 11:34:54 +0200
+Subject: [PATCH 1/4] Use macro error reporting for %add_sysuser errors
+
+Lua has error() but no warning() (obviously) which we'll want in the next
+step, so for consistency lets just use macro.error() instead.
+---
+ macros.in | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/macros.in b/macros.in
+index a047d1e388..1f6d8b252f 100644
+--- a/macros.in
++++ b/macros.in
+@@ -1325,14 +1325,14 @@ end
+         prefix = 'Provides: '
+     end
+     if #arg < 2 then
+-        error('not enough arguments')
++        macros.error({'not enough arguments'})
+     end
+     if arg[1] == 'g' then
+         type = 'group'
+     elseif arg[1] == 'u' then
+         type = 'user'
+     else
+-        error('invalid sysuser type: '..arg[1])
++        macros.error({'invalid sysuser type: '..arg[1]})
+     end
+     name = arg[2]
+     line = table.concat(arg, ' ')
+
+From 8e392aef642fba1f63b6d86b11fad85d63d94ba1 Mon Sep 17 00:00:00 2001
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Fri, 3 Nov 2023 11:51:11 +0200
+Subject: [PATCH 2/4] Fix an apparent thinko/typo in the sysusers test spec
+
+I'm quite sure I didn't really intend to test duplicate files behavior
+here...
+---
+ tests/data/SPECS/klang.spec | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/tests/data/SPECS/klang.spec b/tests/data/SPECS/klang.spec
+index 7e917fdc7f..e6cce1add8 100644
+--- a/tests/data/SPECS/klang.spec
++++ b/tests/data/SPECS/klang.spec
+@@ -28,6 +28,7 @@ Summary: %{SUMMARY} server
+ 
+ %install
+ mkdir -p ${RPM_BUILD_ROOT}/var/lib/klangd
++mkdir -p ${RPM_BUILD_ROOT}/var/lib/plongd
+ mkdir -p ${RPM_BUILD_ROOT}/usr/bin/
+ mkdir -p ${RPM_BUILD_ROOT}/etc
+ mkdir -p ${RPM_BUILD_ROOT}/%{_sysusersdir}
+@@ -59,5 +60,5 @@ EOF
+ %{_sysusersdir}/klangd.conf
+ %{_sysusersdir}/plong.conf
+ %attr(-,klangd,klangd) /var/lib/klangd
+-%attr(-,plong,klong) /var/lib/klangd
++%attr(-,plong,klong) /var/lib/plongd
+ /usr/bin/klangd
+
+From 59a212dbe3cb19331582c9c022105ae47b9ace21 Mon Sep 17 00:00:00 2001
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Fri, 3 Nov 2023 11:53:11 +0200
+Subject: [PATCH 3/4] Handle unsupported 'r' and 'm' sysusers types more
+ gracefully
+
+People will want to use existing sysusers.d files through rpm and while
+we don't support 'r' and 'm' at this time, we shouldn't really call
+them "invalid" and error out. Issue a warning instead, and ignore.
+
+This is the first half of
+https://bugzilla.redhat.com/show_bug.cgi?id=2246236
+---
+ macros.in                   | 3 +++
+ tests/data/SPECS/klang.spec | 2 ++
+ tests/rpmi.at               | 7 +++++++
+ 3 files changed, 12 insertions(+)
+
+diff --git a/macros.in b/macros.in
+index 1f6d8b252f..fefb351ac3 100644
+--- a/macros.in
++++ b/macros.in
+@@ -1331,6 +1331,9 @@ end
+         type = 'group'
+     elseif arg[1] == 'u' then
+         type = 'user'
++    elseif arg[1] == 'r' or arg[1] == 'm' then
++        macros.warn({'ignoring unsupported sysuser type: '..arg[1]})
++        return
+     else
+         macros.error({'invalid sysuser type: '..arg[1]})
+     end
+diff --git a/tests/data/SPECS/klang.spec b/tests/data/SPECS/klang.spec
+index e6cce1add8..e7c03cd7f8 100644
+--- a/tests/data/SPECS/klang.spec
++++ b/tests/data/SPECS/klang.spec
+@@ -47,6 +47,8 @@ EOF
+ cat << EOF > ${RPM_BUILD_ROOT}/%{_sysusersdir}/plong.conf
+ u plong - "Plong fu" /var/lib/plong /sbin/nologin
+ g klong -
++m ding dong
++r - 123-321
+ EOF
+ 
+ %files common
+diff --git a/tests/rpmi.at b/tests/rpmi.at
+index 6339a70a7c..94d8967b12 100644
+--- a/tests/rpmi.at
++++ b/tests/rpmi.at
+@@ -1481,7 +1481,14 @@ AT_SETUP([rpm -i sysusers])
+ AT_KEYWORDS([install build sysusers])
+ RPMDB_INIT
+ 
++RPMTEST_CHECK([
+ runroot rpmbuild -bb --quiet /data/SPECS/klang.spec
++],
++[0],
++[],
++[warning: ignoring unsupported sysuser type: m
++warning: ignoring unsupported sysuser type: r
++])
+ 
+ RPMTEST_CHECK([
+ runroot rpm -U /build/RPMS/noarch/klang-client-1.0-1.noarch.rpm
+
+From c47f71a72e7f885615c677e88ce92810ed1f00c8 Mon Sep 17 00:00:00 2001
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Fri, 3 Nov 2023 12:15:58 +0200
+Subject: [PATCH 4/4] Fix comment line handling in sysusers.d(8) files
+
+sysusers.d(8) format permits empty lines and commits, and so must we.
+Add some extra fluff to the test-case for this.
+
+This is the second half of
+https://bugzilla.redhat.com/show_bug.cgi?id=2246236
+
+Fixes: #2741
+---
+ fileattrs/sysusers.attr     | 4 ++++
+ tests/data/SPECS/klang.spec | 5 +++++
+ 2 files changed, 9 insertions(+)
+
+diff --git a/fileattrs/sysusers.attr b/fileattrs/sysusers.attr
+index f7a3e838d1..48d4caede9 100644
+--- a/fileattrs/sysusers.attr
++++ b/fileattrs/sysusers.attr
+@@ -6,6 +6,9 @@
+ # For groups created as a side-effect, only provide the group.
+ %__sysusers_provides() %{lua:
+     for line in io.lines(macros["1"]) do
++        if line:sub(1, 1) == '#' then
++            goto continue
++        end
+         fields = {}
+         for w in line:gmatch("%S+") do
+             table.insert(fields, w)
+@@ -14,5 +17,6 @@
+             table.insert(fields, 1, '-b')
+             print(macros.add_sysuser(fields))
+         end
++        ::continue::
+     end
+ }
+diff --git a/tests/data/SPECS/klang.spec b/tests/data/SPECS/klang.spec
+index e7c03cd7f8..64bd90c104 100644
+--- a/tests/data/SPECS/klang.spec
++++ b/tests/data/SPECS/klang.spec
+@@ -45,7 +45,12 @@ cat << EOF > ${RPM_BUILD_ROOT}/%{_sysusersdir}/klangd.conf
+ u klangd - "Klang server" /var/lib/klangd /sbin/nologin
+ EOF
+ cat << EOF > ${RPM_BUILD_ROOT}/%{_sysusersdir}/plong.conf
++
++# Real life files have all sorts of anomalies
+ u plong - "Plong fu" /var/lib/plong /sbin/nologin
++#...such as empty lines
++
++# and comments comments
+ g klong -
+ m ding dong
+ r - 123-321

diff --git a/rpm.spec b/rpm.spec
index 84ebaa4..126eb81 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -140,6 +140,7 @@ rpm-4.18.90-weak-user-group.patch
 
 # Patches already upstream:
 # ...
+rpm-4.19.0-sysusers-fixes.patch
 
 # These are not yet upstream
 rpm-4.7.1-geode-i686.patch
@@ -619,6 +620,7 @@ fi
 * Mon Nov 13 2023 Panu Matilainen <pmatilai@redhat.com> - 4.19.0-2
 - Ensure central package ops log via rpm-plugin-audit recommends (#1476926)
 - Own our Python module directory (#2248555)
+- Fix sysusers.d generator barfing on legit content (#2246236)
 
 * Tue Sep 19 2023 Michal Domonkos <mdomonko@redhat.com> - 4.19.0-1
 - Update to 4.19.0

                 reply	other threads:[~2026-11-23  9:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179542651041.1.13938495557321254059.rpms-rpm-b0f8f4c9e82d@fedoraproject.org \
    --to=pmatilai@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox