openssh.spec 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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.8.1
  27. %define V_portable p1
  28. %define V_watchdog 3.8p1
  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: 20040419
  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. # build information
  72. Prefix: %{l_prefix}
  73. BuildRoot: %{l_buildroot}
  74. BuildPreReq: OpenPKG, openpkg >= 20040130, perl
  75. PreReq: OpenPKG, openpkg >= 20040130
  76. BuildPreReq: openssl, zlib
  77. PreReq: openssl, zlib
  78. %if "%{with_pam}" == "yes"
  79. BuildPreReq: PAM
  80. PreReq: PAM
  81. %endif
  82. %if "%{with_fsl}" == "yes"
  83. BuildPreReq: fsl >= 1.2.0
  84. PreReq: fsl >= 1.2.0
  85. %endif
  86. %if "%{with_skey}" == "yes"
  87. BuildPreReq: skey
  88. PreReq: skey
  89. %endif
  90. %if "%{with_x11}" == "yes"
  91. BuildPreReq: X11
  92. PreReq: X11
  93. %endif
  94. %if "%{with_ldap}" == "yes"
  95. BuildPreReq: openldap
  96. PreReq: openldap
  97. %endif
  98. %if "%{with_wrap}" == "yes"
  99. BuildPreReq: tcpwrappers
  100. PreReq: tcpwrappers
  101. %endif
  102. AutoReq: no
  103. AutoReqProv: no
  104. %description
  105. Secure Shell (SSH) is a facility for logging into a remote machine
  106. and for remotely executing commands on a remote machine. It is
  107. intended to replace rlogin(1) and rsh(1), and provide secure
  108. encrypted communications between two untrusted hosts over an
  109. insecure network. X11 connections and arbitrary TCP/IP ports can
  110. also be forwarded over the secure channel. OpenSSH is OpenBSD's
  111. rework of the last free version of SSH, bringing it up to date in
  112. terms of security and features, as well as removing all patented
  113. algorithms to separate libraries (OpenSSL).
  114. %track
  115. prog openssh = {
  116. version = %{version}
  117. url = ftp://ftp.openssh.com/pub/OpenBSD/OpenSSH/portable/
  118. regex = openssh-(__VER__)\.tar\.gz
  119. }
  120. prog openssh:watchdog = {
  121. version = %{V_watchdog}
  122. url = http://www.sc.isc.tohoku.ac.jp/~hgot/sources/openssh-watchdog.html
  123. regex = HREF=.openssh-(__VER__)-watchdog\.patch\.tgz
  124. }
  125. %prep
  126. # unpack and patch distribution
  127. %setup -q
  128. %patch -p0 -P 0
  129. %{l_shtool} subst \
  130. -e 's;@l_openpkg_release@;%{l_openpkg_release -F "OpenPKG-%s"};' \
  131. version.h
  132. %if "%{with_chroot}" == "yes"
  133. %patch -p0 -P 1
  134. %endif
  135. %if "%{with_alias}" == "yes"
  136. %patch -p0 -P 2
  137. %endif
  138. %if "%{with_watchdog}" == "yes"
  139. %{l_gzip} -d -c %{SOURCE openssh-%{V_watchdog}-watchdog.patch.tgz} | %{l_tar} xf -
  140. %{l_patch} -p0 <openssh-%{V_watchdog}-watchdog.patch
  141. %endif
  142. %if "%{with_ldap}" == "yes"
  143. %{l_gzip} -d -c %{SOURCE ldappubkey-ossh%{V_ldap_base}-%{V_ldap_vers2}.patch} | %{l_patch} -p0
  144. %endif
  145. %if "%{with_sftplogging}" == "yes"
  146. %patch -p1 -P 5
  147. %endif
  148. %build
  149. # configure package
  150. cflags=""
  151. ldflags=""
  152. %if "%{with_chroot}" == "yes"
  153. cflags="$cflags -DUSE_CHROOT"
  154. %endif
  155. %if "%{with_alias}" == "yes"
  156. cflags="$cflags -DUSE_ALIAS"
  157. %endif
  158. %if "%{with_pam}" == "yes"
  159. cflags="$cflags -I`%{l_prefix}/etc/rc --query pam_incdir`"
  160. ldflags="$ldflags -L`%{l_prefix}/etc/rc --query pam_libdir`"
  161. %endif
  162. %if "%{with_ldap}" == "yes"
  163. cflags="$cflags -DWITH_LDAP_PUBKEY"
  164. ldflags="$ldflags -lldap -llber -lcrypto -lssl"
  165. %endif
  166. CC="%{l_cc}" \
  167. CFLAGS="%{l_cflags -O} %{l_cppflags} $cflags" \
  168. LDFLAGS="%{l_ldflags} %{l_fsl_ldflags} $ldflags" \
  169. LIBS="%{l_fsl_libs}" \
  170. ./configure \
  171. --prefix=%{l_prefix} \
  172. --sbindir=%{l_prefix}/bin \
  173. --mandir=%{l_prefix}/man \
  174. --infodir=%{l_prefix}/info \
  175. --sysconfdir=%{l_prefix}/etc/openssh \
  176. --libexecdir=%{l_prefix}/libexec/openssh \
  177. --localstatedir=%{l_prefix}/var/openssh \
  178. --with-pid-dir=%{l_prefix}/var/openssh \
  179. --with-ssl-dir=%{l_prefix} \
  180. %if "%{with_skey}" == "yes"
  181. --with-skey=%{l_prefix} \
  182. %endif
  183. %if "%{with_pam}" == "yes"
  184. --with-pam \
  185. %else
  186. --without-pam \
  187. %endif
  188. %if "%{with_x11}" == "yes"
  189. --with-xauth="`%{l_prefix}/etc/rc --query x11_bindir`/xauth" \
  190. %endif
  191. %if "%{with_wrap}" == "yes"
  192. --with-tcp-wrappers=%{l_prefix} \
  193. %endif
  194. --with-md5-passwords \
  195. --with-zlib=%{l_prefix} \
  196. --with-ipv4-default \
  197. --without-smartcard \
  198. --without-kerberos4 \
  199. --disable-suid-ssh \
  200. --without-rsh \
  201. --with-mantype=man \
  202. --with-default-path=%{l_prefix}/bin:/bin:/usr/bin:/usr/local/bin \
  203. --with-privsep-user=%{l_nusr} \
  204. --with-privsep-path=%{l_prefix}/var/openssh/empty
  205. # build package
  206. %{l_make} %{l_mflags -O}
  207. %install
  208. rm -rf $RPM_BUILD_ROOT
  209. # perform standard installation procedure of OpenSSH
  210. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  211. # strip down installation tree
  212. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share
  213. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/slogin
  214. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/slogin.1
  215. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  216. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/* 2>/dev/null || true
  217. # install ssh-askpass wrapper
  218. %{l_shtool} mkdir -f -p -m 755 \
  219. $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh
  220. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  221. %{SOURCE ssh-askpass} \
  222. $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/
  223. # make sure the state directory exists
  224. %{l_shtool} mkdir -f -p -m 755 \
  225. $RPM_BUILD_ROOT%{l_prefix}/var/openssh \
  226. $RPM_BUILD_ROOT%{l_prefix}/var/openssh/empty
  227. # install addons
  228. %{l_shtool} mkdir -f -p -m 755 \
  229. $RPM_BUILD_ROOT%{l_prefix}/bin \
  230. $RPM_BUILD_ROOT%{l_prefix}/man/man1
  231. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  232. %{SOURCE ssh-keyman} \
  233. $RPM_BUILD_ROOT%{l_prefix}/bin/
  234. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  235. %{SOURCE ssh-keyman.1} \
  236. $RPM_BUILD_ROOT%{l_prefix}/man/man1/
  237. # install run-command script
  238. %{l_shtool} mkdir -f -p -m 755 \
  239. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  240. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  241. %{SOURCE rc.openssh} \
  242. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  243. # install reasonable ssh server and client configuration files
  244. %{l_shtool} mkdir -f -p -m 755 \
  245. $RPM_BUILD_ROOT%{l_prefix}/etc/openssh
  246. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  247. -e 's;@l_x11forwarding@;%{with_x11};' \
  248. %{SOURCE sshd_config} \
  249. $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  250. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  251. %{SOURCE ssh_config} \
  252. $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  253. # install OSSP fsl configuration
  254. %{l_shtool} mkdir -f -p -m 755 \
  255. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  256. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  257. %{SOURCE fsl.openssh} \
  258. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  259. # determine installation files
  260. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  261. %{l_files_std} \
  262. '%not %dir %{l_prefix}/etc/fsl' \
  263. '%config %{l_prefix}/etc/fsl/fsl.openssh' \
  264. '%config %{l_prefix}/etc/openssh/*' \
  265. '%attr(4711,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/openssh/ssh-keysign' \
  266. '%dir %attr(700,%{l_susr},%{l_sgrp}) %{l_prefix}/var/openssh/empty'
  267. %files -f files
  268. %clean
  269. rm -rf $RPM_BUILD_ROOT
  270. %post
  271. # generate server RSA1 (SSH1) key
  272. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" -o \
  273. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" ]; then
  274. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa1 -b 2048 \
  275. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key \
  276. -N '' -C `hostname` 1>&2
  277. fi
  278. # generate server RSA (SSH2) key
  279. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key" -o \
  280. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key" ]; then
  281. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa -b 2048 \
  282. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key \
  283. -N '' -C `hostname` 1>&2
  284. fi
  285. # generate server DSA (SSH2) key
  286. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" -o \
  287. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" ]; then
  288. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t dsa -b 2048 \
  289. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key \
  290. -N '' -C `hostname` 1>&2
  291. fi
  292. %if "%{with_pam}" == "yes"
  293. # add PAM configuration entry
  294. if [ $1 -eq 1 ]; then
  295. $RPM_INSTALL_PREFIX/sbin/pamtool --add --smart --name=openssh
  296. fi
  297. %endif
  298. # after upgrade, restart service
  299. [ $1 -eq 2 ] || exit 0
  300. eval `%{l_rc} openssh status 2>/dev/null`
  301. [ ".$openssh_active" = .yes ] && %{l_rc} openssh restart
  302. exit 0
  303. %preun
  304. # before erase, stop service and remove log files
  305. [ $1 -eq 0 ] || exit 0
  306. %{l_rc} openssh stop 2>/dev/null
  307. rm -f $RPM_INSTALL_PREFIX/var/openssh/openssh.log* >/dev/null 2>&1 || true
  308. %if "%{with_pam}" == "yes"
  309. # remove PAM configuration entry
  310. $RPM_INSTALL_PREFIX/sbin/pamtool --remove --smart --name=openssh
  311. %endif
  312. exit 0