d1681e
From fdf4475ea3598b4287803001932f426f2c58f3b1 Mon Sep 17 00:00:00 2001
3604df
From: Milind Changire <mchangir@redhat.com>
3604df
Date: Fri, 14 Oct 2016 12:53:27 +0530
d1681e
Subject: [PATCH 23/74] build: randomize temp file names in pretrans scriptlets
3604df
3604df
Security issue CVE-2015-1795 mentions about possibility of file name
3604df
spoof attack for the %pretrans server scriptlet.
3604df
Since %pretrans scriptlets are executed only for server builds, we can
3604df
use os.tmpname() to randomize temporary file names for all %pretrans
3604df
scriptlets using this mechanism.
3604df
3604df
Label: DOWNSTREAM ONLY
3604df
3604df
Change-Id: Ic82433897432794b6d311d836355aa4bad886369
3604df
Signed-off-by: Milind Changire <mchangir@redhat.com>
3604df
Reviewed-on: https://code.engineering.redhat.com/gerrit/86187
3604df
Reviewed-by: Siddharth Sharma <siddharth@redhat.com>
3604df
Reviewed-by: Niels de Vos <ndevos@redhat.com>
3604df
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
3604df
---
d1681e
 glusterfs.spec.in | 106 ++++++++++++++++++++++++++++++++----------------------
d1681e
 1 file changed, 64 insertions(+), 42 deletions(-)
3604df
3604df
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
d1681e
index 8f30020..ab61688 100644
3604df
--- a/glusterfs.spec.in
3604df
+++ b/glusterfs.spec.in
d1681e
@@ -1579,9 +1579,10 @@ if [ $? -eq 0 ]; then
3604df
 fi
3604df
 ]]
3604df
 
3604df
--- rpm in RHEL5 does not have os.tmpname()
3604df
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
3604df
-tmpname = "/tmp/glusterfs_pretrans_" .. os.date("%s")
3604df
+-- Since we run pretrans scripts only for RPMs built for a server build,
3604df
+-- we can now use os.tmpname() since it is available on RHEL6 and later
3604df
+-- platforms which are server platforms.
3604df
+tmpname = os.tmpname()
3604df
 tmpfile = io.open(tmpname, "w")
3604df
 tmpfile:write(script)
3604df
 tmpfile:close()
d1681e
@@ -1620,9 +1621,10 @@ if [ $? -eq 0 ]; then
3604df
 fi
3604df
 ]]
3604df
 
3604df
--- rpm in RHEL5 does not have os.tmpname()
3604df
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
3604df
-tmpname = "/tmp/glusterfs-api_pretrans_" .. os.date("%s")
3604df
+-- Since we run pretrans scripts only for RPMs built for a server build,
3604df
+-- we can now use os.tmpname() since it is available on RHEL6 and later
3604df
+-- platforms which are server platforms.
3604df
+tmpname = os.tmpname()
3604df
 tmpfile = io.open(tmpname, "w")
3604df
 tmpfile:write(script)
3604df
 tmpfile:close()
d1681e
@@ -1661,9 +1663,10 @@ if [ $? -eq 0 ]; then
3604df
 fi
3604df
 ]]
3604df
 
3604df
--- rpm in RHEL5 does not have os.tmpname()
3604df
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
3604df
-tmpname = "/tmp/glusterfs-api-devel_pretrans_" .. os.date("%s")
3604df
+-- Since we run pretrans scripts only for RPMs built for a server build,
3604df
+-- we can now use os.tmpname() since it is available on RHEL6 and later
3604df
+-- platforms which are server platforms.
3604df
+tmpname = os.tmpname()
3604df
 tmpfile = io.open(tmpname, "w")
3604df
 tmpfile:write(script)
3604df
 tmpfile:close()
d1681e
@@ -1702,9 +1705,10 @@ if [ $? -eq 0 ]; then
3604df
 fi
3604df
 ]]
3604df
 
3604df
--- rpm in RHEL5 does not have os.tmpname()
3604df
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
3604df
-tmpname = "/tmp/glusterfs-cli_pretrans_" .. os.date("%s")
3604df
+-- Since we run pretrans scripts only for RPMs built for a server build,
3604df
+-- we can now use os.tmpname() since it is available on RHEL6 and later
3604df
+-- platforms which are server platforms.
3604df
+tmpname = os.tmpname()
3604df
 tmpfile = io.open(tmpname, "w")
3604df
 tmpfile:write(script)
3604df
 tmpfile:close()
d1681e
@@ -1743,9 +1747,10 @@ if [ $? -eq 0 ]; then
3604df
 fi
3604df
 ]]
3604df
 
3604df
--- rpm in RHEL5 does not have os.tmpname()
3604df
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
3604df
-tmpname = "/tmp/glusterfs-client-xlators_pretrans_" .. os.date("%s")
3604df
+-- Since we run pretrans scripts only for RPMs built for a server build,
3604df
+-- we can now use os.tmpname() since it is available on RHEL6 and later
3604df
+-- platforms which are server platforms.
3604df
+tmpname = os.tmpname()
3604df
 tmpfile = io.open(tmpname, "w")
3604df
 tmpfile:write(script)
3604df
 tmpfile:close()
d1681e
@@ -1784,9 +1789,10 @@ if [ $? -eq 0 ]; then
3604df
 fi
3604df
 ]]
3604df
 
3604df
--- rpm in RHEL5 does not have os.tmpname()
3604df
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
3604df
-tmpname = "/tmp/glusterfs-devel_pretrans_" .. os.date("%s")
3604df
+-- Since we run pretrans scripts only for RPMs built for a server build,
3604df
+-- we can now use os.tmpname() since it is available on RHEL6 and later
3604df
+-- platforms which are server platforms.
3604df
+tmpname = os.tmpname()
3604df
 tmpfile = io.open(tmpname, "w")
3604df
 tmpfile:write(script)
3604df
 tmpfile:close()
d1681e
@@ -1825,9 +1831,10 @@ if [ $? -eq 0 ]; then
3604df
 fi
3604df
 ]]
3604df
 
3604df
--- rpm in RHEL5 does not have os.tmpname()
3604df
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
3604df
-tmpname = "/tmp/glusterfs-fuse_pretrans_" .. os.date("%s")
3604df
+-- Since we run pretrans scripts only for RPMs built for a server build,
3604df
+-- we can now use os.tmpname() since it is available on RHEL6 and later
3604df
+-- platforms which are server platforms.
3604df
+tmpname = os.tmpname()
3604df
 tmpfile = io.open(tmpname, "w")
3604df
 tmpfile:write(script)
3604df
 tmpfile:close()
d1681e
@@ -1866,9 +1873,10 @@ if [ $? -eq 0 ]; then
3604df
 fi
3604df
 ]]
3604df
 
3604df
--- rpm in RHEL5 does not have os.tmpname()
3604df
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
3604df
-tmpname = "/tmp/glusterfs-ganesha_pretrans_" .. os.date("%s")
3604df
+-- Since we run pretrans scripts only for RPMs built for a server build,
3604df
+-- we can now use os.tmpname() since it is available on RHEL6 and later
3604df
+-- platforms which are server platforms.
3604df
+tmpname = os.tmpname()
3604df
 tmpfile = io.open(tmpname, "w")
3604df
 tmpfile:write(script)
3604df
 tmpfile:close()
d1681e
@@ -1908,9 +1916,10 @@ if [ $? -eq 0 ]; then
3604df
 fi
3604df
 ]]
3604df
 
3604df
--- rpm in RHEL5 does not have os.tmpname()
3604df
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
3604df
-tmpname = "/tmp/glusterfs-geo-replication_pretrans_" .. os.date("%s")
3604df
+-- Since we run pretrans scripts only for RPMs built for a server build,
3604df
+-- we can now use os.tmpname() since it is available on RHEL6 and later
3604df
+-- platforms which are server platforms.
3604df
+tmpname = os.tmpname()
3604df
 tmpfile = io.open(tmpname, "w")
3604df
 tmpfile:write(script)
3604df
 tmpfile:close()
d1681e
@@ -1950,9 +1959,10 @@ if [ $? -eq 0 ]; then
3604df
 fi
3604df
 ]]
3604df
 
3604df
--- rpm in RHEL5 does not have os.tmpname()
3604df
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
3604df
-tmpname = "/tmp/glusterfs-libs_pretrans_" .. os.date("%s")
3604df
+-- Since we run pretrans scripts only for RPMs built for a server build,
3604df
+-- we can now use os.tmpname() since it is available on RHEL6 and later
3604df
+-- platforms which are server platforms.
3604df
+tmpname = os.tmpname()
3604df
 tmpfile = io.open(tmpname, "w")
3604df
 tmpfile:write(script)
3604df
 tmpfile:close()
d1681e
@@ -1991,9 +2001,10 @@ if [ $? -eq 0 ]; then
3604df
 fi
3604df
 ]]
3604df
 
3604df
--- rpm in RHEL5 does not have os.tmpname()
3604df
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
3604df
-tmpname = "/tmp/python-gluster_pretrans_" .. os.date("%s")
3604df
+-- Since we run pretrans scripts only for RPMs built for a server build,
3604df
+-- we can now use os.tmpname() since it is available on RHEL6 and later
3604df
+-- platforms which are server platforms.
3604df
+tmpname = os.tmpname()
3604df
 tmpfile = io.open(tmpname, "w")
3604df
 tmpfile:write(script)
3604df
 tmpfile:close()
d1681e
@@ -2033,9 +2044,10 @@ if [ $? -eq 0 ]; then
3604df
 fi
3604df
 ]]
3604df
 
3604df
--- rpm in RHEL5 does not have os.tmpname()
3604df
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
3604df
-tmpname = "/tmp/glusterfs-rdma_pretrans_" .. os.date("%s")
3604df
+-- Since we run pretrans scripts only for RPMs built for a server build,
3604df
+-- we can now use os.tmpname() since it is available on RHEL6 and later
3604df
+-- platforms which are server platforms.
3604df
+tmpname = os.tmpname()
3604df
 tmpfile = io.open(tmpname, "w")
3604df
 tmpfile:write(script)
3604df
 tmpfile:close()
d1681e
@@ -2076,9 +2088,10 @@ if [ $? -eq 0 ]; then
3604df
 fi
3604df
 ]]
3604df
 
3604df
--- rpm in RHEL5 does not have os.tmpname()
3604df
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
3604df
-tmpname = "/tmp/glusterfs-resource-agents_pretrans_" .. os.date("%s")
3604df
+-- Since we run pretrans scripts only for RPMs built for a server build,
3604df
+-- we can now use os.tmpname() since it is available on RHEL6 and later
3604df
+-- platforms which are server platforms.
3604df
+tmpname = os.tmpname()
3604df
 tmpfile = io.open(tmpname, "w")
3604df
 tmpfile:write(script)
3604df
 tmpfile:close()
d1681e
@@ -2118,9 +2131,10 @@ if [ $? -eq 0 ]; then
3604df
 fi
3604df
 ]]
3604df
 
3604df
--- rpm in RHEL5 does not have os.tmpname()
3604df
--- io.tmpfile() can not be resolved to a filename to pass to bash :-/
3604df
-tmpname = "/tmp/glusterfs-server_pretrans_" .. os.date("%s")
3604df
+-- Since we run pretrans scripts only for RPMs built for a server build,
3604df
+-- we can now use os.tmpname() since it is available on RHEL6 and later
3604df
+-- platforms which are server platforms.
3604df
+tmpname = os.tmpname()
3604df
 tmpfile = io.open(tmpname, "w")
3604df
 tmpfile:write(script)
3604df
 tmpfile:close()
d1681e
@@ -2211,6 +2225,13 @@ end
d1681e
 * Thu Nov 24 2016 Jiffin Tony Thottan <jhottan@redhat.com>
d1681e
 - remove S31ganesha-reset.sh from hooks (#1397795)
3604df
 
3604df
+* Fri Oct 14 2016 Milind Changire <mchangir@redhat.com>
3604df
+- Changed pretrans scripts to use os.tmpname() for enhanced security
3604df
+  for server builds only (#1362044)
3604df
+
d1681e
+* Tue Sep 27 2016 Milind Changire <mchangir@redhat.com>
d1681e
+- Added systemd requirement to glusterfs-server and glusterfs-events packages
d1681e
+
d1681e
 * Thu Sep 22 2016 Kaleb S. KEITHLEY <kkeithle@redhat.com>
d1681e
 - python-ctypes no long exists, now in python stdlib (#1378436)
3604df
 
d1681e
@@ -2330,6 +2351,7 @@ end
3604df
 
3604df
 * Mon May 18 2015 Milind Changire <mchangir@redhat.com>
3604df
 - Move file peer_add_secret_pub to the server RPM to support glusterfind (#1221544)
3604df
+
3604df
 * Sun May 17 2015 Niels de Vos <ndevos@redhat.com>
3604df
 - Fix building on RHEL-5 based distributions (#1222317)
3604df
 
3604df
-- 
d1681e
1.8.3.1
3604df