14f8ab
From 3d0e09400dc21dbb5f76fd9ca4bfce3edad0d626 Mon Sep 17 00:00:00 2001
14f8ab
From: Milind Changire <mchangir@redhat.com>
14f8ab
Date: Fri, 14 Oct 2016 12:53:27 +0530
14f8ab
Subject: [PATCH 15/52] build: randomize temp file names in pretrans scriptlets
14f8ab
14f8ab
Security issue CVE-2015-1795 mentions about possibility of file name
14f8ab
spoof attack for the %pretrans server scriptlet.
14f8ab
Since %pretrans scriptlets are executed only for server builds, we can
14f8ab
use os.tmpname() to randomize temporary file names for all %pretrans
14f8ab
scriptlets using this mechanism.
14f8ab
14f8ab
Label: DOWNSTREAM ONLY
14f8ab
14f8ab
Change-Id: Ic82433897432794b6d311d836355aa4bad886369
14f8ab
Signed-off-by: Milind Changire <mchangir@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/86187
14f8ab
Reviewed-by: Siddharth Sharma <siddharth@redhat.com>
14f8ab
Reviewed-by: Niels de Vos <ndevos@redhat.com>
14f8ab
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
14f8ab
---
14f8ab
 glusterfs.spec.in | 84 +++++++++++++++++++++++++++++++------------------------
14f8ab
 1 file changed, 48 insertions(+), 36 deletions(-)
14f8ab
14f8ab
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
14f8ab
index 8c57f57..3a98822 100644
14f8ab
--- a/glusterfs.spec.in
14f8ab
+++ b/glusterfs.spec.in
14f8ab
@@ -1549,9 +1549,10 @@ if [ $? -eq 0 ]; then
14f8ab
 fi
14f8ab
 ]]
14f8ab
 
14f8ab
--- rpm in RHEL5 does not have os.tmpname()
14f8ab
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
14f8ab
-tmpname = "/tmp/glusterfs_pretrans_" .. os.date("%s")
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
@@ -1590,9 +1591,10 @@ if [ $? -eq 0 ]; then
14f8ab
 fi
14f8ab
 ]]
14f8ab
 
14f8ab
--- rpm in RHEL5 does not have os.tmpname()
14f8ab
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
14f8ab
-tmpname = "/tmp/glusterfs-api_pretrans_" .. os.date("%s")
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
@@ -1631,9 +1633,10 @@ if [ $? -eq 0 ]; then
14f8ab
 fi
14f8ab
 ]]
14f8ab
 
14f8ab
--- rpm in RHEL5 does not have os.tmpname()
14f8ab
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
14f8ab
-tmpname = "/tmp/glusterfs-api-devel_pretrans_" .. os.date("%s")
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
@@ -1672,9 +1675,10 @@ if [ $? -eq 0 ]; then
14f8ab
 fi
14f8ab
 ]]
14f8ab
 
14f8ab
--- rpm in RHEL5 does not have os.tmpname()
14f8ab
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
14f8ab
-tmpname = "/tmp/glusterfs-cli_pretrans_" .. os.date("%s")
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
@@ -1712,9 +1716,10 @@ if [ $? -eq 0 ]; then
14f8ab
 fi
14f8ab
 ]]
14f8ab
 
14f8ab
--- rpm in RHEL5 does not have os.tmpname()
14f8ab
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
14f8ab
-tmpname = "/tmp/glusterfs-client-xlators_pretrans_" .. os.date("%s")
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
@@ -1752,9 +1757,10 @@ if [ $? -eq 0 ]; then
14f8ab
 fi
14f8ab
 ]]
14f8ab
 
14f8ab
--- rpm in RHEL5 does not have os.tmpname()
14f8ab
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
14f8ab
-tmpname = "/tmp/glusterfs-devel_pretrans_" .. os.date("%s")
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
@@ -1793,9 +1799,10 @@ if [ $? -eq 0 ]; then
14f8ab
 fi
14f8ab
 ]]
14f8ab
 
14f8ab
--- rpm in RHEL5 does not have os.tmpname()
14f8ab
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
14f8ab
-tmpname = "/tmp/glusterfs-fuse_pretrans_" .. os.date("%s")
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
@@ -1835,9 +1842,10 @@ if [ $? -eq 0 ]; then
14f8ab
 fi
14f8ab
 ]]
14f8ab
 
14f8ab
--- rpm in RHEL5 does not have os.tmpname()
14f8ab
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
14f8ab
-tmpname = "/tmp/glusterfs-geo-replication_pretrans_" .. os.date("%s")
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
@@ -1877,9 +1885,10 @@ if [ $? -eq 0 ]; then
14f8ab
 fi
14f8ab
 ]]
14f8ab
 
14f8ab
--- rpm in RHEL5 does not have os.tmpname()
14f8ab
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
14f8ab
-tmpname = "/tmp/glusterfs-libs_pretrans_" .. os.date("%s")
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
@@ -1919,9 +1928,10 @@ if [ $? -eq 0 ]; then
14f8ab
 fi
14f8ab
 ]]
14f8ab
 
14f8ab
--- rpm in RHEL5 does not have os.tmpname()
14f8ab
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
14f8ab
-tmpname = "/tmp/glusterfs-rdma_pretrans_" .. os.date("%s")
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
@@ -1962,9 +1972,10 @@ if [ $? -eq 0 ]; then
14f8ab
 fi
14f8ab
 ]]
14f8ab
 
14f8ab
--- rpm in RHEL5 does not have os.tmpname()
14f8ab
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
14f8ab
-tmpname = "/tmp/glusterfs-resource-agents_pretrans_" .. os.date("%s")
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
@@ -2004,9 +2015,10 @@ if [ $? -eq 0 ]; then
14f8ab
 fi
14f8ab
 ]]
14f8ab
 
14f8ab
--- rpm in RHEL5 does not have os.tmpname()
14f8ab
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
14f8ab
-tmpname = "/tmp/glusterfs-server_pretrans_" .. os.date("%s")
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
-- 
14f8ab
1.8.3.1
14f8ab