From 018c8c921d981f6e105281994d5739f7a247ec00 Mon Sep 17 00:00:00 2001
From: Andrew Lewman <andrew@torproject.org>
Date: Wed, 28 Feb 2007 01:13:18 +0000
Subject: [PATCH] Fix a potential race condition on install of rpm with running
 Tor.

svn:r9673
---
 tor.spec.in | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/tor.spec.in b/tor.spec.in
index 1fc7383ba6..7888e9039f 100644
--- a/tor.spec.in
+++ b/tor.spec.in
@@ -201,6 +201,7 @@ for high-stakes anonymity.
 %__mkdir_p -m 700 ${RPM_BUILD_ROOT}%{_localstatedir}/lib/%{name}
 %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_localstatedir}/run/%{name}
 %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}
+%__mkdir_p -m 700 ${RPM_BUILD_ROOT}%{_localstatedir}/tmp/%{name}
 
 %clean
 [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
@@ -212,10 +213,10 @@ for high-stakes anonymity.
 
 # If tor is already installed and running (whether installed by RPM
 # or not), then kill it, but remember that it was running.
-%__rm -f /tmp/${name}-was-running-%{version}-%{release}
+%__rm -f /%{_localstatedir}/tmp/${name}-was-running-%{version}-%{release}
 if [ -f %{_initrddir}/%{name} ] && /sbin/service %{name} status ; then
     /sbin/service %{name} stop
-    touch /tmp/${name}-was-running-%{version}-%{release}
+    touch /%{_localstatedir}/tmp/${name}-was-running-%{version}-%{release}
 fi
 
 #
@@ -251,9 +252,9 @@ fi
 # Make sure the runtime data have the right ownership.
 %__chown -R %{toruser}.%{torgroup} %{_localstatedir}/{lib,log,run}/%{name}
 
-if [ -f /tmp/${name}-was-running-%{version}-%{release} ]; then
+if [ -f /%{_localstatedir}/tmp/${name}-was-running-%{version}-%{release} ]; then
     /sbin/service %{name} start
-    %__rm -f /tmp/${name}-was-running-%{version}-%{release}
+    %__rm -f /%{_localstatedir}/tmp/${name}-was-running-%{version}-%{release}
 fi
 exit 0
 
@@ -296,13 +297,17 @@ exit 0
 
 %changelog
 
-* Fri May 26 2006 Andrew Lewman <phobos@interloper.org>
+* Tue Feb 27 2007 Andrew Lewman <phobos@rootme.org>
+- Fix a potential race condition in how we determine the running state of tor.  Found by Stefan Nordhausen.
+- see OR-CVS for details
+
+* Fri May 26 2006 Andrew Lewman <phobos@rootme.org>
 - Add in a few "SUSEisms" to make dist-rpm actually work on suse
 - Turn Tor "on" via chkconfig
 - Update -mcpu to -mtune to make GCC happy
 - see OR-CVS for details
 
-* Tue Mar 28 2006 Andrew Lewman <phobos@interloper.org>
+* Tue Mar 28 2006 Andrew Lewman <phobos@rootme.org>
 - converted to build the specified target cpu and arch
 - override related rpm macros to build correctly
 - see OR-CVS for details
-- 
GitLab