openssh.spec 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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: 20040912
  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. %build
  151. # configure package
  152. cflags=""
  153. ldflags=""
  154. %if "%{with_chroot}" == "yes"
  155. cflags="$cflags -DUSE_CHROOT"
  156. %endif
  157. %if "%{with_alias}" == "yes"
  158. cflags="$cflags -DUSE_ALIAS"
  159. %endif
  160. %if "%{with_pam}" == "yes"
  161. cflags="$cflags -I`%{l_prefix}/etc/rc --query pam_incdir`"
  162. ldflags="$ldflags -L`%{l_prefix}/etc/rc --query pam_libdir`"
  163. %endif
  164. %if "%{with_ldap}" == "yes"
  165. cflags="$cflags -DWITH_LDAP_PUBKEY"
  166. ldflags="$ldflags -lldap -llber -lcrypto -lssl"
  167. %endif
  168. CC="%{l_cc}" \
  169. CFLAGS="%{l_cflags -O} %{l_cppflags} $cflags" \
  170. LDFLAGS="%{l_ldflags} %{l_fsl_ldflags} $ldflags" \
  171. LIBS="%{l_fsl_libs}" \
  172. ./configure \
  173. --prefix=%{l_prefix} \
  174. --sbindir=%{l_prefix}/bin \
  175. --mandir=%{l_prefix}/man \
  176. --infodir=%{l_prefix}/info \
  177. --sysconfdir=%{l_prefix}/etc/openssh \
  178. --libexecdir=%{l_prefix}/libexec/openssh \
  179. --localstatedir=%{l_prefix}/var/openssh \
  180. --with-pid-dir=%{l_prefix}/var/openssh \
  181. --with-ssl-dir=%{l_prefix} \
  182. %if "%{with_skey}" == "yes"
  183. --with-skey=%{l_prefix} \
  184. %endif
  185. %if "%{with_pam}" == "yes"
  186. --with-pam \
  187. %else
  188. --without-pam \
  189. %endif
  190. %if "%{with_x11}" == "yes"
  191. --with-xauth="`%{l_prefix}/etc/rc --query x11_bindir`/xauth" \
  192. %endif
  193. %if "%{with_wrap}" == "yes"
  194. --with-tcp-wrappers=%{l_prefix} \
  195. %endif
  196. --with-md5-passwords \
  197. --with-zlib=%{l_prefix} \
  198. --with-ipv4-default \
  199. --without-smartcard \
  200. --without-kerberos4 \
  201. --disable-suid-ssh \
  202. --without-rsh \
  203. --with-mantype=man \
  204. --with-default-path=%{l_prefix}/bin:/bin:/usr/bin:/usr/local/bin \
  205. --with-privsep-user=%{l_nusr} \
  206. --with-privsep-path=%{l_prefix}/var/openssh/empty
  207. # build package
  208. %{l_make} %{l_mflags -O}
  209. %install
  210. rm -rf $RPM_BUILD_ROOT
  211. # perform standard installation procedure of OpenSSH
  212. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  213. # strip down installation tree
  214. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share
  215. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/slogin
  216. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/slogin.1
  217. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  218. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/* 2>/dev/null || true
  219. # install ssh-askpass wrapper
  220. %{l_shtool} mkdir -f -p -m 755 \
  221. $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh
  222. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  223. %{SOURCE ssh-askpass} \
  224. $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/
  225. # make sure the state directory exists
  226. %{l_shtool} mkdir -f -p -m 755 \
  227. $RPM_BUILD_ROOT%{l_prefix}/var/openssh \
  228. $RPM_BUILD_ROOT%{l_prefix}/var/openssh/empty
  229. # install addons
  230. %{l_shtool} mkdir -f -p -m 755 \
  231. $RPM_BUILD_ROOT%{l_prefix}/bin \
  232. $RPM_BUILD_ROOT%{l_prefix}/man/man1
  233. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  234. %{SOURCE ssh-keyman} \
  235. $RPM_BUILD_ROOT%{l_prefix}/bin/
  236. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  237. %{SOURCE ssh-keyman.1} \
  238. $RPM_BUILD_ROOT%{l_prefix}/man/man1/
  239. # install run-command script
  240. %{l_shtool} mkdir -f -p -m 755 \
  241. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  242. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  243. %{SOURCE rc.openssh} \
  244. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  245. # install reasonable ssh server and client configuration files
  246. %{l_shtool} mkdir -f -p -m 755 \
  247. $RPM_BUILD_ROOT%{l_prefix}/etc/openssh
  248. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  249. -e 's;@l_x11forwarding@;%{with_x11};' \
  250. %{SOURCE sshd_config} \
  251. $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  252. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  253. %{SOURCE ssh_config} \
  254. $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  255. # install OSSP fsl configuration
  256. %{l_shtool} mkdir -f -p -m 755 \
  257. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  258. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  259. %{SOURCE fsl.openssh} \
  260. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  261. # determine installation files
  262. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  263. %{l_files_std} \
  264. '%not %dir %{l_prefix}/etc/fsl' \
  265. '%config %{l_prefix}/etc/fsl/fsl.openssh' \
  266. '%config %{l_prefix}/etc/openssh/*' \
  267. '%attr(4711,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/openssh/ssh-keysign' \
  268. '%dir %attr(700,%{l_susr},%{l_sgrp}) %{l_prefix}/var/openssh/empty'
  269. %files -f files
  270. %clean
  271. rm -rf $RPM_BUILD_ROOT
  272. %post
  273. # generate server RSA1 (SSH1) key
  274. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" -o \
  275. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" ]; then
  276. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa1 -b 2048 \
  277. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key \
  278. -N '' -C `hostname` 1>&2
  279. fi
  280. # generate server RSA (SSH2) key
  281. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key" -o \
  282. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key" ]; then
  283. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa -b 2048 \
  284. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key \
  285. -N '' -C `hostname` 1>&2
  286. fi
  287. # generate server DSA (SSH2) key
  288. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" -o \
  289. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" ]; then
  290. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t dsa -b 2048 \
  291. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key \
  292. -N '' -C `hostname` 1>&2
  293. fi
  294. %if "%{with_pam}" == "yes"
  295. # add PAM configuration entry
  296. if [ $1 -eq 1 ]; then
  297. $RPM_INSTALL_PREFIX/sbin/pamtool --add --smart --name=openssh
  298. fi
  299. %endif
  300. # after upgrade, restart service
  301. [ $1 -eq 2 ] || exit 0
  302. eval `%{l_rc} openssh status 2>/dev/null`
  303. [ ".$openssh_active" = .yes ] && %{l_rc} openssh restart
  304. exit 0
  305. %preun
  306. # before erase, stop service and remove log files
  307. [ $1 -eq 0 ] || exit 0
  308. %{l_rc} openssh stop 2>/dev/null
  309. rm -f $RPM_INSTALL_PREFIX/var/openssh/openssh.log* >/dev/null 2>&1 || true
  310. %if "%{with_pam}" == "yes"
  311. # remove PAM configuration entry
  312. $RPM_INSTALL_PREFIX/sbin/pamtool --remove --smart --name=openssh
  313. %endif
  314. exit 0