233933
From a577dd0a3cbf435681f10d095a0dca0595c6a354 Mon Sep 17 00:00:00 2001
233933
From: Milind Changire <mchangir@redhat.com>
233933
Date: Sat, 9 Feb 2019 14:01:28 +0530
233933
Subject: [PATCH 38/52] spec: avoid creation of temp file in lua script
233933
233933
Avoiding creation of temporary file to execute bash shell script from a
233933
lua scriptlet increases install time security.
233933
233933
Label: DOWNSTREAM ONLY
233933
233933
Change-Id: Ie5b9035f292402b18dea768aca8bc82a1e7fa615
233933
Signed-off-by: Milind Changire <mchangir@redhat.com>
233933
Reviewed-on: https://code.engineering.redhat.com/gerrit/162621
233933
Tested-by: RHGS Build Bot <nigelb@redhat.com>
233933
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
233933
---
233933
 glusterfs.spec.in | 120 ++++++------------------------------------------------
233933
 1 file changed, 12 insertions(+), 108 deletions(-)
233933
233933
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
233933
index 9db5a34..df8d116 100644
233933
--- a/glusterfs.spec.in
233933
+++ b/glusterfs.spec.in
233933
@@ -1542,15 +1542,7 @@ if [ $? -eq 0 ]; then
233933
 fi
233933
 ]]
233933
 
233933
--- Since we run pretrans scripts only for RPMs built for a server build,
233933
--- we can now use os.tmpname() since it is available on RHEL6 and later
233933
--- platforms which are server platforms.
233933
-tmpname = os.tmpname()
233933
-tmpfile = io.open(tmpname, "w")
233933
-tmpfile:write(script)
233933
-tmpfile:close()
233933
-ok, how, val = os.execute("/bin/bash " .. tmpname)
233933
-os.remove(tmpname)
233933
+ok, how, val = os.execute(script)
233933
 if not (ok == 0) then
233933
    error("Detected running glusterfs processes", ok)
233933
 end
233933
@@ -1584,15 +1576,7 @@ if [ $? -eq 0 ]; then
233933
 fi
233933
 ]]
233933
 
233933
--- Since we run pretrans scripts only for RPMs built for a server build,
233933
--- we can now use os.tmpname() since it is available on RHEL6 and later
233933
--- platforms which are server platforms.
233933
-tmpname = os.tmpname()
233933
-tmpfile = io.open(tmpname, "w")
233933
-tmpfile:write(script)
233933
-tmpfile:close()
233933
-ok, how, val = os.execute("/bin/bash " .. tmpname)
233933
-os.remove(tmpname)
233933
+ok, how, val = os.execute(script)
233933
 if not (ok == 0) then
233933
    error("Detected running glusterfs processes", ok)
233933
 end
233933
@@ -1626,15 +1610,7 @@ if [ $? -eq 0 ]; then
233933
 fi
233933
 ]]
233933
 
233933
--- Since we run pretrans scripts only for RPMs built for a server build,
233933
--- we can now use os.tmpname() since it is available on RHEL6 and later
233933
--- platforms which are server platforms.
233933
-tmpname = os.tmpname()
233933
-tmpfile = io.open(tmpname, "w")
233933
-tmpfile:write(script)
233933
-tmpfile:close()
233933
-ok, how, val = os.execute("/bin/bash " .. tmpname)
233933
-os.remove(tmpname)
233933
+ok, how, val = os.execute(script)
233933
 if not (ok == 0) then
233933
    error("Detected running glusterfs processes", ok)
233933
 end
233933
@@ -1668,15 +1644,7 @@ if [ $? -eq 0 ]; then
233933
 fi
233933
 ]]
233933
 
233933
--- Since we run pretrans scripts only for RPMs built for a server build,
233933
--- we can now use os.tmpname() since it is available on RHEL6 and later
233933
--- platforms which are server platforms.
233933
-tmpname = os.tmpname()
233933
-tmpfile = io.open(tmpname, "w")
233933
-tmpfile:write(script)
233933
-tmpfile:close()
233933
-ok, how, val = os.execute("/bin/bash " .. tmpname)
233933
-os.remove(tmpname)
233933
+ok, how, val = os.execute(script)
233933
 if not (ok == 0) then
233933
    error("Detected running glusterfs processes", ok)
233933
 end
233933
@@ -1709,15 +1677,7 @@ if [ $? -eq 0 ]; then
233933
 fi
233933
 ]]
233933
 
233933
--- Since we run pretrans scripts only for RPMs built for a server build,
233933
--- we can now use os.tmpname() since it is available on RHEL6 and later
233933
--- platforms which are server platforms.
233933
-tmpname = os.tmpname()
233933
-tmpfile = io.open(tmpname, "w")
233933
-tmpfile:write(script)
233933
-tmpfile:close()
233933
-ok, how, val = os.execute("/bin/bash " .. tmpname)
233933
-os.remove(tmpname)
233933
+ok, how, val = os.execute(script)
233933
 if not (ok == 0) then
233933
    error("Detected running glusterfs processes", ok)
233933
 end
233933
@@ -1750,15 +1710,7 @@ if [ $? -eq 0 ]; then
233933
 fi
233933
 ]]
233933
 
233933
--- Since we run pretrans scripts only for RPMs built for a server build,
233933
--- we can now use os.tmpname() since it is available on RHEL6 and later
233933
--- platforms which are server platforms.
233933
-tmpname = os.tmpname()
233933
-tmpfile = io.open(tmpname, "w")
233933
-tmpfile:write(script)
233933
-tmpfile:close()
233933
-ok, how, val = os.execute("/bin/bash " .. tmpname)
233933
-os.remove(tmpname)
233933
+ok, how, val = os.execute(script)
233933
 if not (ok == 0) then
233933
    error("Detected running glusterfs processes", ok)
233933
 end
233933
@@ -1792,15 +1744,7 @@ if [ $? -eq 0 ]; then
233933
 fi
233933
 ]]
233933
 
233933
--- Since we run pretrans scripts only for RPMs built for a server build,
233933
--- we can now use os.tmpname() since it is available on RHEL6 and later
233933
--- platforms which are server platforms.
233933
-tmpname = os.tmpname()
233933
-tmpfile = io.open(tmpname, "w")
233933
-tmpfile:write(script)
233933
-tmpfile:close()
233933
-ok, how, val = os.execute("/bin/bash " .. tmpname)
233933
-os.remove(tmpname)
233933
+ok, how, val = os.execute(script)
233933
 if not (ok == 0) then
233933
    error("Detected running glusterfs processes", ok)
233933
 end
233933
@@ -1835,15 +1779,7 @@ if [ $? -eq 0 ]; then
233933
 fi
233933
 ]]
233933
 
233933
--- Since we run pretrans scripts only for RPMs built for a server build,
233933
--- we can now use os.tmpname() since it is available on RHEL6 and later
233933
--- platforms which are server platforms.
233933
-tmpname = os.tmpname()
233933
-tmpfile = io.open(tmpname, "w")
233933
-tmpfile:write(script)
233933
-tmpfile:close()
233933
-ok, how, val = os.execute("/bin/bash " .. tmpname)
233933
-os.remove(tmpname)
233933
+ok, how, val = os.execute(script)
233933
 if not (ok == 0) then
233933
    error("Detected running glusterfs processes", ok)
233933
 end
233933
@@ -1878,15 +1814,7 @@ if [ $? -eq 0 ]; then
233933
 fi
233933
 ]]
233933
 
233933
--- Since we run pretrans scripts only for RPMs built for a server build,
233933
--- we can now use os.tmpname() since it is available on RHEL6 and later
233933
--- platforms which are server platforms.
233933
-tmpname = os.tmpname()
233933
-tmpfile = io.open(tmpname, "w")
233933
-tmpfile:write(script)
233933
-tmpfile:close()
233933
-ok, how, val = os.execute("/bin/bash " .. tmpname)
233933
-os.remove(tmpname)
233933
+ok, how, val = os.execute(script)
233933
 if not (ok == 0) then
233933
    error("Detected running glusterfs processes", ok)
233933
 end
233933
@@ -1921,15 +1849,7 @@ if [ $? -eq 0 ]; then
233933
 fi
233933
 ]]
233933
 
233933
--- Since we run pretrans scripts only for RPMs built for a server build,
233933
--- we can now use os.tmpname() since it is available on RHEL6 and later
233933
--- platforms which are server platforms.
233933
-tmpname = os.tmpname()
233933
-tmpfile = io.open(tmpname, "w")
233933
-tmpfile:write(script)
233933
-tmpfile:close()
233933
-ok, how, val = os.execute("/bin/bash " .. tmpname)
233933
-os.remove(tmpname)
233933
+ok, how, val = os.execute(script)
233933
 if not (ok == 0) then
233933
    error("Detected running glusterfs processes", ok)
233933
 end
233933
@@ -1965,15 +1885,7 @@ if [ $? -eq 0 ]; then
233933
 fi
233933
 ]]
233933
 
233933
--- Since we run pretrans scripts only for RPMs built for a server build,
233933
--- we can now use os.tmpname() since it is available on RHEL6 and later
233933
--- platforms which are server platforms.
233933
-tmpname = os.tmpname()
233933
-tmpfile = io.open(tmpname, "w")
233933
-tmpfile:write(script)
233933
-tmpfile:close()
233933
-ok, how, val = os.execute("/bin/bash " .. tmpname)
233933
-os.remove(tmpname)
233933
+ok, how, val = os.execute(script)
233933
 if not (ok == 0) then
233933
    error("Detected running glusterfs processes", ok)
233933
 end
233933
@@ -2008,15 +1920,7 @@ if [ $? -eq 0 ]; then
233933
 fi
233933
 ]]
233933
 
233933
--- Since we run pretrans scripts only for RPMs built for a server build,
233933
--- we can now use os.tmpname() since it is available on RHEL6 and later
233933
--- platforms which are server platforms.
233933
-tmpname = os.tmpname()
233933
-tmpfile = io.open(tmpname, "w")
233933
-tmpfile:write(script)
233933
-tmpfile:close()
233933
-ok, how, val = os.execute("/bin/bash " .. tmpname)
233933
-os.remove(tmpname)
233933
+ok, how, val = os.execute(script)
233933
 if not (ok == 0) then
233933
    error("Detected running glusterfs processes", ok)
233933
 end
233933
-- 
233933
1.8.3.1
233933