public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/setup] update_services: Fix %post scriptlet to not require the shell
@ 2026-06-22 15:56 
  0 siblings, 0 replies; only message in thread
From:  @ 2026-06-22 15:56 UTC (permalink / raw)
  To: git-commits

            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)

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-22 15:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-22 15:56 [rpms/setup] update_services: Fix %post scriptlet to not require the shell 

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox