Fix a couple of non-cleared key issues in hidden services
[tor/rransom.git] / tor.spec.in
blob54b9be092a3341db49ecc1534d10d0af40e94acf
1 ## NOTE: tor.spec is autogenerated from tor.spec.in . Edit the latter,
2 ## not the former.
4 ## Things that need to be edited frequently
6 # This should be incremented whenever the spec file changes, but
7 # can drop back to zero at a new Tor version
9 %define specver 0
11 ## Things users may want to change
13 # User (and group) name under which the Tor daemon runs.
15 %define toruser @TORUSER@
16 %define torgroup @TORGROUP@
18 ## Target a specific arch and OS
20 # default is i386 linux
22 ## Override any system rpm macros
25 ## Version song and dance
27 # This should be the Tor version number, as it appears on the tarball,
28 # including any "pre<x>" or "rc<y>" suffix. This gets massaged to
29 # create the RPM version number, in a way that depends on the Tor
30 # numbering scheme.
31 %define native_version @VERSION@
33 %define version %(echo %{native_version} | sed -e 's/-/./g')
35 ## Define output filename
37 # This creates filenames based upon the value of target_cpu defined above
39 ## Release and OS identification song and dance
41 # This identifies the lineage of the spec file. This file is the
42 # standard one that comes with Tor; various distributions may
43 # have their own ideas about the right ways to do things.
44 %define pkgspec tor
46 # This spec is intended to build and install on multiple distributions
47 # (someday). Detect the distribution we're building on.
49 %define is_rh %(test -e /etc/redhat-release && echo 1 || echo 0)
50 %define is_fc %(test -e /etc/fedora-release && echo 1 || echo 0)
51 %define is_mdk %(test -e /etc/mandrake-release && echo 1 || echo 0)
52 %define is_suse %(test -e /etc/SuSE-release && echo 1 || echo 0)
53 %define is_rfl %(test -e /etc/redflag-release && echo 1 || echo 0)
55 %if %{is_fc}
56 %define ostag %(sed -e 's/^.*release /fc/' -e 's/ .*$//' -e 's/\\./_/g' < /etc/fedora-release)
57 %else
58 %if %{is_rh}
59 %define ostag %(sed -e 's/^.*release /rh/' -e 's/ .*$//' -e 's/\\./_/g' < /etc/redhat-release)
60 %endif
61 %endif
63 # These are probably wrong... just placeholders should we actually
64 # end up supporting these distributions
66 %if %{is_mdk}
67 %define ostag mdk
68 %endif
70 %if %{is_suse}
71 %define ostag suse%(grep openSUSE /etc/SuSE-release | awk '{print $2}' | sed -e 's/\\./_/')
72 %endif
74 %if %{is_rfl}
75 %define ostag %(sed -e 's/^.*Desktop /redflag/' -e 's/ .*$//' -e 's/\\./_/g' < /etc/redflag-release)
76 %endif
78 # Using the build date ensures that every build really does get
79 # a different release number. We use this trick for CVS versions.
80 # For release versions, we don't want or need it.
81 %define is_dev_version %(echo %{native_version} | grep 'dev' > /dev/null && echo 1 || echo 0)
83 %if %{is_dev_version}
84 %define blddate %(date -u +"%Y%m%d%H%M")
85 %define release %{pkgspec}.%{specver}.%{ostag}.%{blddate}
86 %else
87 %define release %{pkgspec}.%{specver}.%{ostag}
88 %endif
90 ## General-purpose macros
92 # Some systems don't have some macros. If a macro doesn't seem
93 # to exist on your system, add it here...
95 %if %{!?__make:1}%{?__make:0}
96 %define __make make
97 %endif
99 %if %{!?make:1}%{?make:0}
100 %define make %{__make}
101 %endif
103 %if %{!?_localstatedir:1}%{?_localstatedir:0}
104 %define _localstatedir @LOCALSTATEDIR@
105 %endif
107 ## Package information
109 Name: tor
110 Version: %{version}
111 Release: %{release}
113 Summary: Anonymizing overlay network for TCP (The onion router)
114 URL: https://www.torproject.org/
115 Group: System Environment/Daemons
117 License: 3-clause BSD
118 Vendor: The Tor Project (https://torproject.org)
119 Packager: Andrew Lewman <andrew@torproject.org>
121 %if %{is_suse}
122 Requires: openssl >= 0.9.7
123 BuildRequires: openssl-devel >= 0.9.7, rpm >= 4.0, zlib-devel
124 %else
125 Requires: openssl >= 0.9.7
126 BuildRequires: openssl-devel >= 0.9.7
127 %endif
128 %if %{is_fc}
129 BuildRequires: rpm-build >= 4.0
130 %endif
131 Requires(pre): /usr/bin/id, /bin/date, /bin/sh
132 Requires(pre): %{_sbindir}/useradd, %{_sbindir}/groupadd
134 Source0: https://www.torproject.org/dist/%{name}-%{native_version}.tar.gz
136 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
138 %description
139 Tor is a connection-based low-latency anonymous communication system.
141 This package provides the "tor" program, which serves as both a client and
142 a relay node. Scripts will automatically create a "%{toruser}" user and
143 a "%{torgroup}" group, and set tor up to run as a daemon when the system
144 is rebooted.
146 Applications connect to the local Tor proxy using the SOCKS
147 protocol. The tor client chooses a path through a set of relays, in
148 which each relay knows its predecessor and successor, but no
149 others. Traffic flowing down the circuit is unwrapped by a symmetric
150 key at each relay, which reveals the downstream relay.
152 Warnings: Tor does no protocol cleaning. That means there is a danger
153 that application protocols and associated programs can be induced to
154 reveal information about the initiator. Tor depends on Privoxy or
155 similar protocol cleaners to solve this problem. This is alpha code,
156 and is even more likely than released code to have anonymity-spoiling
157 bugs. The present network is small -- this further reduces the
158 strength of the anonymity provided. Tor is not presently suitable
159 for high-stakes anonymity.
161 %prep
162 %setup -q -n %{name}-%{native_version}
164 %build
165 %if %{is_suse}
166 %configure --with-tor-user=%{toruser} --with-tor-group=%{torgroup}
167 %else
168 %configure --with-tor-user=%{toruser} --with-tor-group=%{torgroup}
169 %endif
170 %make
172 %install
173 %makeinstall
175 # Install init script and control script
176 %__mkdir_p ${RPM_BUILD_ROOT}%{_initrddir}
177 %if %{is_suse}
178 %__install -p -m 755 contrib/suse/tor.sh ${RPM_BUILD_ROOT}%{_initrddir}/%{name}
179 %else
180 %__install -p -m 755 contrib/tor.sh ${RPM_BUILD_ROOT}%{_initrddir}/%{name}
181 %endif
182 %__install -p -m 755 contrib/torctl ${RPM_BUILD_ROOT}%{_bindir}
184 # Set up config file; "sample" file implements a basic user node.
185 %__install -p -m 644 ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/torrc.sample ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/torrc
187 # Install the logrotate control file.
188 %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d
189 %__install -p -m 644 contrib/tor.logrotate ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/%{name}
191 # Directories that don't have any preinstalled files
192 %__mkdir_p -m 700 ${RPM_BUILD_ROOT}%{_localstatedir}/lib/%{name}
193 %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_localstatedir}/run/%{name}
194 %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}
195 %__mkdir_p -m 700 ${RPM_BUILD_ROOT}%{_localstatedir}/tmp/%{name}
197 %clean
198 [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
200 # These scripts are probably wrong for Mandrake or SuSE. They're certainly
201 # wrong for Debian, but what are you doing using RPM on Debian?
203 %pre
205 # If tor is already installed and running (whether installed by RPM
206 # or not), then kill it, but remember that it was running.
207 %__rm -f /%{_localstatedir}/tmp/${name}-was-running-%{version}-%{release}
208 if [ -f %{_initrddir}/%{name} ] && /sbin/service %{name} status ; then
209 /sbin/service %{name} stop
210 touch /%{_localstatedir}/tmp/${name}-was-running-%{version}-%{release}
214 # Create a user and group if need be
216 if [ ! -n "`/usr/bin/id -g %{torgroup} 2>/dev/null`" ]; then
217 # One would like to default the GID, but doing that properly would
218 # require thought.
219 %{_sbindir}/groupadd %{torgroup} 2> /dev/null
221 if [ ! -n "`/usr/bin/id -u %{toruser} 2>/dev/null`" ]; then
222 # One would also like to default the UID, but doing that properly would
223 # also require thought.
224 if [ -x %{_sbindir}/nologin ]; then
225 %{_sbindir}/useradd -r -g %{torgroup} -d% {_localstatedir}/lib/%{name} -s %{_sbindir}/nologin %{toruser} 2> /dev/null
226 else
227 %{_sbindir}/useradd -r -g %{torgroup} -d %{_localstatedir}/lib/%{name} -s /bin/false %{toruser} 2> /dev/null
230 exit 0
232 %post
234 # If this is a new installation, use chkconfig to put tor in the
235 # default set of runlevels. If it's an upgrade, leave the existing
236 # configuration alone.
237 if [ $1 -eq 1 ]; then
238 /sbin/chkconfig --add %{name}
239 /sbin/chkconfig %{name} on
242 # Older tor RPMS used a different username for the tor daemon.
243 # Make sure the runtime data have the right ownership.
244 %__chown -R %{toruser}.%{torgroup} %{_localstatedir}/{lib,log,run}/%{name}
246 if [ -f /%{_localstatedir}/tmp/${name}-was-running-%{version}-%{release} ]; then
247 /sbin/service %{name} start
248 %__rm -f /%{_localstatedir}/tmp/${name}-was-running-%{version}-%{release}
250 exit 0
252 %preun
254 # If no instances of tor will be installed when we're done, make
255 # sure that it gets killed. We *don't* want to kill it or delete
256 # any of its data on uninstall if it's being upgraded to a new
257 # version, because the new version will actually already have
258 # been installed and started before the uninstall script for
259 # the old version is run, and we'd end up hosing it.
260 if [ $1 -le 0 ]; then
261 if [ -f %{_initrddir}/%{name} ] && /sbin/service %{name} status ; then
262 /sbin/service %{name} stop
264 %/sbin/chkconfig --del %{name}
265 %__rm -f ${_localstatedir}/lib/%{name}/cached-directory
266 %__rm -f ${_localstatedir}/lib/%{name}/bw_accounting
267 %__rm -f ${_localstatedir}/lib/%{name}/control_auth_cookie
268 %__rm -f ${_localstatedir}/lib/%{name}/router.desc
269 %__rm -f ${_localstatedir}/lib/%{name}/fingerprint
271 exit 0
273 %files
274 %defattr(-,root,root)
275 %doc AUTHORS INSTALL LICENSE README ChangeLog doc/HACKING doc/TODO
276 %{_mandir}/man*/*
277 %{_bindir}/tor
278 %{_bindir}/torctl
279 %{_bindir}/torify
280 %{_bindir}/tor-resolve
281 %{_bindir}/tor-gencert
282 %{_datadir}/tor/geoip
283 %config %{_initrddir}/%{name}
284 %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/logrotate.d/%{name}
285 %dir %attr(0755,root,%{torgroup}) %{_sysconfdir}/%{name}/
286 %config(noreplace) %attr(0644,root,%{torgroup}) %{_sysconfdir}/%{name}/*
287 %attr(0700,%{toruser},%{torgroup}) %dir %{_localstatedir}/lib/%{name}
288 %attr(0750,%{toruser},%{torgroup}) %dir %{_localstatedir}/run/%{name}
289 %attr(0750,%{toruser},%{torgroup}) %dir %{_localstatedir}/log/%{name}
291 %changelog
293 * Sun Feb 22 2009 Andrew Lewman <andrew@torproject.org>
294 - update the description, vendor, and packager
296 * Thu Sep 11 2008 Andrew Lewman <phobos@rootme.org>
297 - See r16867
298 - http://archives.seul.org/or/cvs/Sep-2008/msg00156.html
300 * Tue Feb 27 2007 Andrew Lewman <phobos@rootme.org>
301 - Fix a potential race condition in how we determine the running state of tor. Found by Stefan Nordhausen.
302 - see OR-CVS for details
304 * Fri May 26 2006 Andrew Lewman <phobos@rootme.org>
305 - Add in a few "SUSEisms" to make dist-rpm actually work on suse
306 - Turn Tor "on" via chkconfig
307 - Update -mcpu to -mtune to make GCC happy
308 - see OR-CVS for details
310 * Tue Mar 28 2006 Andrew Lewman <phobos@rootme.org>
311 - converted to build the specified target cpu and arch
312 - override related rpm macros to build correctly
313 - see OR-CVS for details
315 * Mon Jan 17 2005 John Bashinski <jbash@velvet.com>
316 - Take runtime user and group names from configure system. Default
317 user/group names are now "_tor"; blame Roger...
318 - Make logrotate control file a separate file in the source distribution,
319 rather than creating it from the spec file.
320 - Properly handle the order in which RPM executes scriptlets on upgrade.
321 The old code would kill the daemon on upgrade.
322 - Start the tor daemon after installation if and only if it was
323 running before installation. Preserve runlevel setup on upgrade.
324 - Package the torctl script; the init script is now a wrapper around it.
326 * Tue Nov 5 2004 John Bashinski <jbash@velvet.com>
327 - Add skeletal support for multiple distributions
328 - Even more ridiculous level of macro-ization
329 - Modify version numbers so RPM can determine when it has a newer version
330 - Return to including distribution name in package release number
331 - Sharply trim description
332 - Change user/group name from "tor" to "tordmn"; "tor" is a common
333 given name (reported by Marius Hjelle)
334 - Change group to "System Environment/Daemons" (suggested by Marius Hjelle)
335 - Create logrotate file (suggested by Marius Hjelle)
336 - Make Tor run as a user proxy by default (suggested by Marius Hjelle)
337 - Autogenerate spec file from GNU autotools data, substituting version
338 and whatnot
339 - Be perhaps excessively paranoid with config file and directory modes
340 - Remove auto-start and auto-stop at installation time; there's some kind
341 of weird race going on, and it's arguably a bad thing anyway.
343 * Mon Jun 06 2004 Nick Mathewson <nickm@freehaven.net> 0.0.7-0.std.0.1.rc2
344 - Make spec file more happy with fc2 packaging
346 * Sat Jan 17 2004 John Bashinski <jbash@velvet.com>
347 - Basic spec file; tested with Red Hat 9.