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