openssh.spec 11 KB

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