public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
To: git-commits@fedoraproject.org
Subject: [rpms/setup] update_services: Fix %post scriptlet to not require the shell
Date: Mon, 22 Jun 2026 15:56:15 GMT	[thread overview]
Message-ID: <178214377540.1.6578383402867275838.rpms-setup-e72e5cf604fa@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/setup
            Branch : update_services
            Commit : e72e5cf604faf61ae9ebceb61a591e3d4c0d8c8d
            Author : Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
            Date   : 2022-05-27T16:38:25+02:00
            Stats  : +12/-3 in 1 file(s)
            URL    : https://src.fedoraproject.org/rpms/setup/c/e72e5cf604faf61ae9ebceb61a591e3d4c0d8c8d?branch=update_services

            Log:
            Fix %post scriptlet to not require the shell

os.execute uses /bin/sh, which to a large extent defeats the purpose of having
the scriptlet in lua ;)

$ strace -qq -ff -eexecve rpm -E "%{lua:os.execute('true')}"
execve("/usr/bin/rpm", ["rpm", "-E", "%{lua:os.execute('true')}"], 0x7ffd180ce638 /* 60 vars */) = 0
[pid 849466] execve("/bin/sh", ["sh", "-c", "true"], 0x7fff73cfc9d8 /* 60 vars */) = 0

Let's use posix.exec(). rpm.execute() would be nice, but it does not
support suppressing of stderr.

---
diff --git a/setup.spec b/setup.spec
index 65afa5e..a069e92 100644
--- a/setup.spec
+++ b/setup.spec
@@ -1,7 +1,7 @@
 Summary: A set of system configuration and setup files
 Name: setup
 Version: 2.13.10
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: Public Domain
 Group: System Environment/Base
 URL: https://pagure.io/setup/
@@ -68,10 +68,16 @@ rm -rf %{buildroot}/etc/contrib
 #handle it ( http://rpm.org/ticket/6 )
 %post -p <lua>
 for i, name in ipairs({"passwd", "shadow", "group", "gshadow"}) do
-     os.remove("/etc/"..name..".rpmnew")
+   os.remove("/etc/"..name..".rpmnew")
 end
 if posix.access("/usr/bin/newaliases", "x") then
-  os.execute("/usr/bin/newaliases >/dev/null")
+  local pid = posix.fork()
+  if pid == 0 then
+    posix.redirect2null(2)
+    posix.exec("/usr/bin/newaliases")
+  elseif pid > 0 then
+    posix.wait(pid)
+  end
 end
 
 %files
@@ -114,6 +120,9 @@ end
 %{_tmpfilesdir}/%{name}.conf
 
 %changelog
+* Fri May 27 2022 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 2.13.10-2
+- Fix %%post scriptlet to not require the shell
+
 * Sat May 07 2022 Martin Osvald <mosvald@redhat.com> - 2.13.10-1
 - Move /var/log/lastlog ownership to systemd (#1798685)
 - tcsh sets variable p to /usr/sbin from /etc/csh.login (#2019874)

                 reply	other threads:[~2026-06-22 15:56 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=178214377540.1.6578383402867275838.rpms-setup-e72e5cf604fa@fedoraproject.org \
    --to=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