openssh.spec 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. ##
  2. ## openssh.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
  4. ## Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
  5. ## Copyright (c) 2000-2002 Ralf S. Engelschall <rse@engelschall.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.4
  27. %define V_portable p1
  28. # package options
  29. %ifndef with_pam
  30. %define with_pam no
  31. %endif
  32. %ifndef with_pcre
  33. %define with_pcre no
  34. %endif
  35. %ifndef with_skey
  36. %define with_skey no
  37. %endif
  38. %ifndef with_x11
  39. %define with_x11 no
  40. %endif
  41. %ifndef with_chroot
  42. %define with_chroot no
  43. %endif
  44. # package information
  45. Name: openssh
  46. Summary: Secure Shell (SSH)
  47. URL: http://www.openssh.com/
  48. Vendor: The OpenBSD Project
  49. Packager: The OpenPKG Project
  50. Distribution: OpenPKG [CORE]
  51. Group: Security
  52. License: BSD
  53. Version: %{V_base}%{V_portable}
  54. Release: 20020912
  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. Source9: http://chrootssh.sourceforge.net/patches/osshChroot-%{V_base}.diff
  66. # build information
  67. Prefix: %{l_prefix}
  68. BuildRoot: %{l_buildroot}
  69. BuildPreReq: OpenPKG, openpkg >= 20020206, fsl, perl, openssl, zlib
  70. PreReq: OpenPKG, openpkg >= 20020206, fsl
  71. %if "%{with_pam}" == "yes"
  72. BuildPreReq: PAM
  73. PreReq: PAM
  74. %endif
  75. %if "%{with_pcre}" == "yes"
  76. BuildPreReq: pcre
  77. %endif
  78. %if "%{with_skey}" == "yes"
  79. BuildPreReq: skey
  80. %endif
  81. %if "%{with_x11}" == "yes"
  82. BuildPreReq: X11
  83. PreReq: X11
  84. %endif
  85. AutoReq: no
  86. AutoReqProv: no
  87. %description
  88. Secure Shell (SSH) is a facility for logging into a remote machine
  89. and for remotely executing commands on a remote machine. It is
  90. intended to replace rlogin(1) and rsh(1), and provide secure
  91. encrypted communications between two untrusted hosts over an
  92. insecure network. X11 connections and arbitrary TCP/IP ports can
  93. also be forwarded over the secure channel. OpenSSH is OpenBSD's
  94. rework of the last free version of SSH, bringing it up to date in
  95. terms of security and features, as well as removing all patented
  96. algorithms to separate libraries (OpenSSL).
  97. Options: with_pam=%{with_pam} with_pcre=%{with_pcre}
  98. Options: with_skey=%{with_skey} with_x11=%{with_x11}
  99. Options: with_chroot=%{with_chroot}
  100. %prep
  101. %setup0 -q -c
  102. %if "%{with_chroot}" == "yes"
  103. cd openssh-%{version}
  104. %{l_patch} -p1 <%{SOURCE osshChroot-%{V_base}.diff}
  105. %endif
  106. %build
  107. # build OpenSSH
  108. ( cd openssh-%{version}
  109. inc="-I%{l_prefix}/include"
  110. lib="-L%{l_prefix}/lib"
  111. %if "%{with_pam}" == "yes"
  112. inc="$inc -I`%{l_prefix}/etc/rc --query pam_incdir`"
  113. lib="$lib -L`%{l_prefix}/etc/rc --query pam_libdir`"
  114. %endif
  115. CC="%{l_cc}" \
  116. CFLAGS="`%{l_prefix}/bin/fsl-config --all --cflags` $inc" \
  117. CFLAGS="$inc" \
  118. LDFLAGS="`%{l_prefix}/bin/fsl-config --all --ldflags` $lib" \
  119. LIBS="`%{l_prefix}/bin/fsl-config --all --libs`" \
  120. ./configure \
  121. --prefix=%{l_prefix} \
  122. --sbindir=%{l_prefix}/bin \
  123. --mandir=%{l_prefix}/man \
  124. --infodir=%{l_prefix}/info \
  125. --sysconfdir=%{l_prefix}/etc/openssh \
  126. --libexecdir=%{l_prefix}/libexec/openssh \
  127. --localstatedir=%{l_prefix}/var/openssh \
  128. --with-pid-dir=%{l_prefix}/var/openssh \
  129. --with-ssl-dir=%{l_prefix} \
  130. %if "%{with_pcre}" == "yes"
  131. --with-pcre=%{l_prefix} \
  132. %endif
  133. %if "%{with_skey}" == "yes"
  134. --with-skey=%{l_prefix} \
  135. %endif
  136. %if "%{with_pam}" == "yes"
  137. --with-pam \
  138. %else
  139. --without-pam \
  140. %endif
  141. %if "%{with_x11}" == "yes"
  142. --with-xauth="`%{l_prefix}/etc/rc --query x11_bindir`/xauth" \
  143. %endif
  144. --with-md5-passwords \
  145. --with-zlib=%{l_prefix} \
  146. --with-ipv4-default \
  147. --without-smartcard \
  148. --without-kerberos4 \
  149. --disable-suid-ssh \
  150. --without-rsh \
  151. --with-mantype=man \
  152. --with-default-path=%{l_prefix}/bin:/bin:/usr/bin:/usr/local/bin \
  153. --with-privsep-user=%{l_nusr} \
  154. --with-privsep-path=%{l_prefix}/var/openssh/empty
  155. # build package
  156. %{l_make} %{l_mflags -O}
  157. )
  158. %install
  159. rm -rf $RPM_BUILD_ROOT
  160. # perform standard installation procedure of OpenSSH
  161. ( cd openssh-%{version}
  162. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  163. )
  164. # strip down installation tree
  165. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share
  166. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/slogin
  167. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/slogin.1
  168. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2> /dev/null || true
  169. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/* 2> /dev/null || true
  170. # install ssh-askpass wrapper
  171. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/
  172. %{l_shtool} install -c -m 755 -e 's;@l_prefix@;%{l_prefix};g' \
  173. %{SOURCE ssh-askpass} $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/
  174. # make sure the state directory exists
  175. %{l_shtool} mkdir -f -p -m 755 \
  176. $RPM_BUILD_ROOT%{l_prefix}/var/openssh \
  177. $RPM_BUILD_ROOT%{l_prefix}/var/openssh/empty
  178. # install addons
  179. %{l_shtool} mkdir -f -p -m 755 \
  180. $RPM_BUILD_ROOT%{l_prefix}/bin/ \
  181. $RPM_BUILD_ROOT%{l_prefix}/man/man1/
  182. %{l_shtool} install -c -m 755 -e 's;@l_prefix@;%{l_prefix};g' \
  183. %{SOURCE ssh-keyman} $RPM_BUILD_ROOT%{l_prefix}/bin/
  184. %{l_shtool} install -c -m 644 -e 's;@l_prefix@;%{l_prefix};g' \
  185. %{SOURCE ssh-keyman.1} $RPM_BUILD_ROOT%{l_prefix}/man/man1/
  186. # install run-command script
  187. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  188. %{l_shtool} install -c -m 755 -e 's;@l_prefix@;%{l_prefix};g' \
  189. -e 's;@l_musr@;%{l_musr};g' -e 's;@l_mgrp@;%{l_mgrp};g' \
  190. %{SOURCE rc.openssh} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  191. # install fsl configuration file
  192. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  193. %{l_shtool} install -c -m 644 -e 's;@l_prefix@;%{l_prefix};g' \
  194. %{SOURCE fsl.openssh} $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  195. # install reasonable ssh server and client configuration files
  196. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  197. %{l_shtool} install -c -m 644 \
  198. -e 's;@l_prefix@;%{l_prefix};g' \
  199. -e 's;@l_x11forwarding@;%{with_x11};' \
  200. %{SOURCE sshd_config} $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  201. %{l_shtool} install -c -m 644 -e 's;@l_prefix@;%{l_prefix};g' \
  202. %{SOURCE ssh_config} $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  203. # determine installation files
  204. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  205. %{l_files_std} \
  206. '%config %{l_prefix}/etc/openssh/*' \
  207. '%attr(4711,root,%{l_mgrp}) %{l_prefix}/libexec/openssh/ssh-keysign' \
  208. '%dir %attr(700,root,root) %{l_prefix}/var/openssh/empty' \
  209. '%config %{l_prefix}/etc/fsl/fsl.openssh' \
  210. '%not %dir %{l_prefix}/etc/fsl'
  211. %files -f files
  212. %clean
  213. rm -rf $RPM_BUILD_ROOT
  214. %post
  215. # generate server RSA1 (SSHv1) key
  216. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" -o \
  217. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" ] ; then
  218. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa1 -b 2048 \
  219. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key \
  220. -N '' -C `hostname` 1>&2
  221. fi
  222. # generate server RSA (SSHv2) key
  223. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key" -o \
  224. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key" ] ; then
  225. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa -b 2048 \
  226. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key \
  227. -N '' -C `hostname` 1>&2
  228. fi
  229. # generate server DSA (SSHv2) key
  230. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" -o \
  231. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" ] ; then
  232. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t dsa -b 2048 \
  233. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key \
  234. -N '' -C `hostname` 1>&2
  235. fi
  236. # add PAM configuration entry
  237. %if "%{with_pam}" == "yes"
  238. $RPM_INSTALL_PREFIX/sbin/pamtool -a -s -n "openssh"
  239. %endif
  240. %preun
  241. # remove PAM configuration entry
  242. %if "%{with_pam}" == "yes"
  243. $RPM_INSTALL_PREFIX/sbin/pamtool -r -s -n "openssh"
  244. %endif