openssh.spec 9.6 KB

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