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