openssh.spec 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. ##
  2. ## openssh.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2004 The OpenPKG Project <http://www.openpkg.org/>
  4. ## Copyright (c) 2000-2004 Ralf S. Engelschall <rse@engelschall.com>
  5. ## Copyright (c) 2000-2004 Cable & Wireless <http://www.cw.com/>
  6. ##
  7. ## Permission to use, copy, modify, and distribute this software for
  8. ## any purpose with or without fee is hereby granted, provided that
  9. ## the above copyright notice and this permission notice appear in all
  10. ## copies.
  11. ##
  12. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  13. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  16. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  19. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  21. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. ## SUCH DAMAGE.
  24. ##
  25. # package versions
  26. %define V_base 3.9
  27. %define V_portable p1
  28. %define V_watchdog 3.9p1
  29. %define V_ldap_base 3.7.1p2
  30. %define V_ldap_vers1 v2.01
  31. %define V_ldap_vers2 v201
  32. # package information
  33. Name: openssh
  34. Summary: Secure Shell (SSH)
  35. URL: http://www.openssh.com/
  36. Vendor: The OpenBSD Project
  37. Packager: The OpenPKG Project
  38. Distribution: OpenPKG
  39. Class: CORE
  40. Group: Security
  41. License: BSD
  42. Version: %{V_base}%{V_portable}
  43. Release: 20041230
  44. # package options
  45. %option with_fsl yes
  46. %option with_alias no
  47. %option with_chroot no
  48. %option with_ldap no
  49. %option with_pam no
  50. %option with_sftplogging no
  51. %option with_skey no
  52. %option with_watchdog no
  53. %option with_wrap no
  54. %option with_x11 no
  55. # list of sources
  56. Source0: ftp://ftp.openssh.com/pub/OpenBSD/OpenSSH/portable/openssh-%{version}.tar.gz
  57. Source1: rc.openssh
  58. Source2: fsl.openssh
  59. Source3: sshd_config
  60. Source4: ssh_config
  61. Source5: ssh-askpass
  62. Source6: ssh-keyman
  63. Source7: ssh-keyman.1
  64. Source8: ssh-keyman.pod
  65. Patch0: openssh.patch
  66. Patch1: openssh.patch.chroot
  67. Patch2: openssh.patch.alias
  68. Patch3: http://www.sc.isc.tohoku.ac.jp/~hgot/sources/openssh-%{V_watchdog}-watchdog.patch.tgz
  69. Patch4: http://ldappubkey.gcu-squad.org/%{V_ldap_vers1}/ldappubkey-ossh%{V_ldap_base}-%{V_ldap_vers2}.patch
  70. Patch5: openssh.patch.sftplogging
  71. Patch6: openssh.patch.scpbindir
  72. # build information
  73. Prefix: %{l_prefix}
  74. BuildRoot: %{l_buildroot}
  75. BuildPreReq: OpenPKG, openpkg >= 20040130, perl
  76. PreReq: OpenPKG, openpkg >= 20040130
  77. BuildPreReq: openssl, zlib
  78. PreReq: openssl, zlib
  79. %if "%{with_pam}" == "yes"
  80. BuildPreReq: PAM
  81. PreReq: PAM
  82. %endif
  83. %if "%{with_fsl}" == "yes"
  84. BuildPreReq: fsl >= 1.2.0
  85. PreReq: fsl >= 1.2.0
  86. %endif
  87. %if "%{with_skey}" == "yes"
  88. BuildPreReq: skey
  89. PreReq: skey
  90. %endif
  91. %if "%{with_x11}" == "yes"
  92. BuildPreReq: X11
  93. PreReq: X11
  94. %endif
  95. %if "%{with_ldap}" == "yes"
  96. BuildPreReq: openldap
  97. PreReq: openldap
  98. %endif
  99. %if "%{with_wrap}" == "yes"
  100. BuildPreReq: tcpwrappers
  101. PreReq: tcpwrappers
  102. %endif
  103. AutoReq: no
  104. AutoReqProv: no
  105. %description
  106. Secure Shell (SSH) is a facility for logging into a remote machine
  107. and for remotely executing commands on a remote machine. It is
  108. intended to replace rlogin(1) and rsh(1), and provide secure
  109. encrypted communications between two untrusted hosts over an
  110. insecure network. X11 connections and arbitrary TCP/IP ports can
  111. also be forwarded over the secure channel. OpenSSH is OpenBSD's
  112. rework of the last free version of SSH, bringing it up to date in
  113. terms of security and features, as well as removing all patented
  114. algorithms to separate libraries (OpenSSL).
  115. %track
  116. prog openssh = {
  117. version = %{version}
  118. url = ftp://ftp.openssh.com/pub/OpenBSD/OpenSSH/portable/
  119. regex = openssh-(__VER__)\.tar\.gz
  120. }
  121. prog openssh:watchdog = {
  122. version = %{V_watchdog}
  123. url = http://www.sc.isc.tohoku.ac.jp/~hgot/sources/openssh-watchdog.html
  124. regex = HREF=.openssh-(__VER__)-watchdog\.patch\.tgz
  125. }
  126. %prep
  127. # unpack and patch distribution
  128. %setup -q
  129. %patch -p0 -P 0
  130. %{l_shtool} subst \
  131. -e 's;@l_openpkg_release@;%{l_openpkg_release -F "OpenPKG-%s"};' \
  132. version.h
  133. %if "%{with_chroot}" == "yes"
  134. %patch -p0 -P 1
  135. %endif
  136. %if "%{with_alias}" == "yes"
  137. %patch -p0 -P 2
  138. %endif
  139. %if "%{with_watchdog}" == "yes"
  140. %{l_gzip} -d -c %{SOURCE openssh-%{V_watchdog}-watchdog.patch.tgz} | %{l_tar} xf -
  141. %{l_patch} -p0 -b <openssh-%{V_watchdog}-watchdog.patch
  142. %endif
  143. %if "%{with_ldap}" == "yes"
  144. %{l_gzip} -d -c %{SOURCE ldappubkey-ossh%{V_ldap_base}-%{V_ldap_vers2}.patch} | %{l_patch} -p0 -b
  145. %endif
  146. %if "%{with_sftplogging}" == "yes"
  147. %patch -p0 -P 5
  148. %endif
  149. sed -e 's;@l_prefix@;%{l_prefix};g' %{SOURCE openssh.patch.scpbindir} | %{l_patch} -p0 -b
  150. case "%{l_platform -t}" in
  151. *-darwin* )
  152. %{l_shtool} subst \
  153. -e 's;LIBS="-lcrypto $LIBS";LIBS="%{l_prefix}/lib/libcrypto.a $LIBS";' \
  154. configure
  155. ;;
  156. esac
  157. %build
  158. # configure package
  159. cflags=""
  160. ldflags=""
  161. %if "%{with_chroot}" == "yes"
  162. cflags="$cflags -DUSE_CHROOT"
  163. %endif
  164. %if "%{with_alias}" == "yes"
  165. cflags="$cflags -DUSE_ALIAS"
  166. %endif
  167. %if "%{with_pam}" == "yes"
  168. cflags="$cflags -I`%{l_rc} --query pam_incdir`"
  169. ldflags="$ldflags -L`%{l_rc} --query pam_libdir`"
  170. %endif
  171. %if "%{with_ldap}" == "yes"
  172. cflags="$cflags -DWITH_LDAP_PUBKEY"
  173. ldflags="$ldflags -lldap -llber -lcrypto -lssl"
  174. %endif
  175. CC="%{l_cc}" \
  176. CFLAGS="%{l_cflags -O} %{l_cppflags} $cflags" \
  177. LDFLAGS="%{l_ldflags} %{l_fsl_ldflags} $ldflags" \
  178. LIBS="%{l_fsl_libs}" \
  179. ./configure \
  180. --prefix=%{l_prefix} \
  181. --sbindir=%{l_prefix}/bin \
  182. --mandir=%{l_prefix}/man \
  183. --infodir=%{l_prefix}/info \
  184. --sysconfdir=%{l_prefix}/etc/openssh \
  185. --libexecdir=%{l_prefix}/libexec/openssh \
  186. --localstatedir=%{l_prefix}/var/openssh \
  187. --with-pid-dir=%{l_prefix}/var/openssh \
  188. --with-ssl-dir=%{l_prefix} \
  189. %if "%{with_skey}" == "yes"
  190. --with-skey=%{l_prefix} \
  191. %endif
  192. %if "%{with_pam}" == "yes"
  193. --with-pam \
  194. %else
  195. --without-pam \
  196. %endif
  197. %if "%{with_x11}" == "yes"
  198. --with-xauth="`%{l_rc} --query x11_bindir`/xauth" \
  199. %endif
  200. %if "%{with_wrap}" == "yes"
  201. --with-tcp-wrappers=%{l_prefix} \
  202. %endif
  203. --with-md5-passwords \
  204. --with-zlib=%{l_prefix} \
  205. --with-ipv4-default \
  206. --without-smartcard \
  207. --without-kerberos4 \
  208. --disable-suid-ssh \
  209. --without-rsh \
  210. --with-mantype=man \
  211. --disable-etc-default-login \
  212. --with-default-path=/bin:/usr/bin \
  213. --with-superuser-path=/bin:/usr/bin:/sbin:/usr/sbin \
  214. --with-privsep-user=%{l_nusr} \
  215. --with-privsep-path=%{l_prefix}/var/openssh/empty
  216. # build package
  217. %{l_make} %{l_mflags -O}
  218. %install
  219. rm -rf $RPM_BUILD_ROOT
  220. # perform standard installation procedure of OpenSSH
  221. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  222. # strip down installation tree
  223. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share
  224. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/slogin
  225. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/slogin.1
  226. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  227. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/* 2>/dev/null || true
  228. # install ssh-askpass wrapper
  229. %{l_shtool} mkdir -f -p -m 755 \
  230. $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh
  231. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  232. %{SOURCE ssh-askpass} \
  233. $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/
  234. # make sure the state directory exists
  235. %{l_shtool} mkdir -f -p -m 755 \
  236. $RPM_BUILD_ROOT%{l_prefix}/var/openssh \
  237. $RPM_BUILD_ROOT%{l_prefix}/var/openssh/empty
  238. # install addons
  239. %{l_shtool} mkdir -f -p -m 755 \
  240. $RPM_BUILD_ROOT%{l_prefix}/bin \
  241. $RPM_BUILD_ROOT%{l_prefix}/man/man1
  242. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  243. %{SOURCE ssh-keyman} \
  244. $RPM_BUILD_ROOT%{l_prefix}/bin/
  245. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  246. %{SOURCE ssh-keyman.1} \
  247. $RPM_BUILD_ROOT%{l_prefix}/man/man1/
  248. # install run-command script
  249. %{l_shtool} mkdir -f -p -m 755 \
  250. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  251. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  252. %{SOURCE rc.openssh} \
  253. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  254. # install reasonable ssh server and client configuration files
  255. %{l_shtool} mkdir -f -p -m 755 \
  256. $RPM_BUILD_ROOT%{l_prefix}/etc/openssh
  257. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  258. -e 's;@l_x11forwarding@;%{with_x11};' \
  259. %{SOURCE sshd_config} \
  260. $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  261. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  262. %{SOURCE ssh_config} \
  263. $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  264. # install OSSP fsl configuration
  265. %{l_shtool} mkdir -f -p -m 755 \
  266. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  267. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  268. %{SOURCE fsl.openssh} \
  269. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  270. # determine installation files
  271. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  272. %{l_files_std} \
  273. '%not %dir %{l_prefix}/etc/fsl' \
  274. '%config %{l_prefix}/etc/fsl/fsl.openssh' \
  275. '%config %{l_prefix}/etc/openssh/*' \
  276. '%attr(4711,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/openssh/ssh-keysign' \
  277. '%dir %attr(700,%{l_susr},%{l_mgrp}) %{l_prefix}/var/openssh/empty'
  278. %files -f files
  279. %clean
  280. rm -rf $RPM_BUILD_ROOT
  281. %post
  282. # generate server RSA1 (SSH1) key
  283. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" -o \
  284. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" ]; then
  285. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa1 -b 2048 \
  286. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key \
  287. -N '' -C `hostname` 1>&2
  288. fi
  289. # generate server RSA (SSH2) key
  290. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key" -o \
  291. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key" ]; then
  292. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa -b 2048 \
  293. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key \
  294. -N '' -C `hostname` 1>&2
  295. fi
  296. # generate server DSA (SSH2) key
  297. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" -o \
  298. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" ]; then
  299. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t dsa -b 2048 \
  300. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key \
  301. -N '' -C `hostname` 1>&2
  302. fi
  303. %if "%{with_pam}" == "yes"
  304. # add PAM configuration entry
  305. if [ $1 -eq 1 ]; then
  306. $RPM_INSTALL_PREFIX/sbin/pamtool --add --smart --name=openssh
  307. fi
  308. %endif
  309. # after upgrade, restart service
  310. [ $1 -eq 2 ] || exit 0
  311. eval `%{l_rc} openssh status 2>/dev/null`
  312. [ ".$openssh_active" = .yes ] && %{l_rc} openssh restart
  313. exit 0
  314. %preun
  315. # before erase, stop service and remove log files
  316. [ $1 -eq 0 ] || exit 0
  317. %{l_rc} openssh stop 2>/dev/null
  318. rm -f $RPM_INSTALL_PREFIX/var/openssh/openssh.log* >/dev/null 2>&1 || true
  319. %if "%{with_pam}" == "yes"
  320. # remove PAM configuration entry
  321. $RPM_INSTALL_PREFIX/sbin/pamtool --remove --smart --name=openssh
  322. %endif
  323. exit 0