openssh.spec 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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 %{l_test -p x11}
  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: 20021003
  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 >= 20021002, fsl, perl, openssl, zlib
  70. PreReq: OpenPKG, openpkg >= 20021002, 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:
  98. --define 'with_pam %{with_pam}'
  99. --define 'with_pcre %{with_pcre}'
  100. --define 'with_skey %{with_skey}'
  101. --define 'with_x11 %{with_x11}'
  102. --define 'with_chroot %{with_chroot}'
  103. %prep
  104. %setup0 -q -c
  105. %if "%{with_chroot}" == "yes"
  106. cd openssh-%{version}
  107. %{l_patch} -p1 <%{SOURCE osshChroot-%{V_base}.diff}
  108. %endif
  109. %build
  110. # build OpenSSH
  111. ( cd openssh-%{version}
  112. inc="-I%{l_prefix}/include"
  113. lib="-L%{l_prefix}/lib"
  114. %if "%{with_pam}" == "yes"
  115. inc="$inc -I`%{l_prefix}/etc/rc --query pam_incdir`"
  116. lib="$lib -L`%{l_prefix}/etc/rc --query pam_libdir`"
  117. %endif
  118. CC="%{l_cc}" \
  119. CFLAGS="`%{l_prefix}/bin/fsl-config --all --cflags` $inc" \
  120. CFLAGS="$inc" \
  121. LDFLAGS="`%{l_prefix}/bin/fsl-config --all --ldflags` $lib" \
  122. LIBS="`%{l_prefix}/bin/fsl-config --all --libs`" \
  123. ./configure \
  124. --prefix=%{l_prefix} \
  125. --sbindir=%{l_prefix}/bin \
  126. --mandir=%{l_prefix}/man \
  127. --infodir=%{l_prefix}/info \
  128. --sysconfdir=%{l_prefix}/etc/openssh \
  129. --libexecdir=%{l_prefix}/libexec/openssh \
  130. --localstatedir=%{l_prefix}/var/openssh \
  131. --with-pid-dir=%{l_prefix}/var/openssh \
  132. --with-ssl-dir=%{l_prefix} \
  133. %if "%{with_pcre}" == "yes"
  134. --with-pcre=%{l_prefix} \
  135. %endif
  136. %if "%{with_skey}" == "yes"
  137. --with-skey=%{l_prefix} \
  138. %endif
  139. %if "%{with_pam}" == "yes"
  140. --with-pam \
  141. %else
  142. --without-pam \
  143. %endif
  144. %if "%{with_x11}" == "yes"
  145. --with-xauth="`%{l_prefix}/etc/rc --query x11_bindir`/xauth" \
  146. %endif
  147. --with-md5-passwords \
  148. --with-zlib=%{l_prefix} \
  149. --with-ipv4-default \
  150. --without-smartcard \
  151. --without-kerberos4 \
  152. --disable-suid-ssh \
  153. --without-rsh \
  154. --with-mantype=man \
  155. --with-default-path=%{l_prefix}/bin:/bin:/usr/bin:/usr/local/bin \
  156. --with-privsep-user=%{l_nusr} \
  157. --with-privsep-path=%{l_prefix}/var/openssh/empty
  158. # build package
  159. %{l_make} %{l_mflags -O}
  160. )
  161. %install
  162. rm -rf $RPM_BUILD_ROOT
  163. # perform standard installation procedure of OpenSSH
  164. ( cd openssh-%{version}
  165. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  166. )
  167. # strip down installation tree
  168. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share
  169. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/slogin
  170. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/slogin.1
  171. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2> /dev/null || true
  172. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/* 2> /dev/null || true
  173. # install ssh-askpass wrapper
  174. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/
  175. %{l_shtool} install -c -m 755 -e 's;@l_prefix@;%{l_prefix};g' \
  176. %{SOURCE ssh-askpass} $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/
  177. # make sure the state directory exists
  178. %{l_shtool} mkdir -f -p -m 755 \
  179. $RPM_BUILD_ROOT%{l_prefix}/var/openssh \
  180. $RPM_BUILD_ROOT%{l_prefix}/var/openssh/empty
  181. # install addons
  182. %{l_shtool} mkdir -f -p -m 755 \
  183. $RPM_BUILD_ROOT%{l_prefix}/bin/ \
  184. $RPM_BUILD_ROOT%{l_prefix}/man/man1/
  185. %{l_shtool} install -c -m 755 -e 's;@l_prefix@;%{l_prefix};g' \
  186. %{SOURCE ssh-keyman} $RPM_BUILD_ROOT%{l_prefix}/bin/
  187. %{l_shtool} install -c -m 644 -e 's;@l_prefix@;%{l_prefix};g' \
  188. %{SOURCE ssh-keyman.1} $RPM_BUILD_ROOT%{l_prefix}/man/man1/
  189. # install run-command script
  190. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  191. %{l_shtool} install -c -m 755 -e 's;@l_prefix@;%{l_prefix};g' \
  192. -e 's;@l_musr@;%{l_musr};g' -e 's;@l_mgrp@;%{l_mgrp};g' \
  193. %{SOURCE rc.openssh} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  194. # install fsl configuration file
  195. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  196. %{l_shtool} install -c -m 644 -e 's;@l_prefix@;%{l_prefix};g' \
  197. %{SOURCE fsl.openssh} $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  198. # install reasonable ssh server and client configuration files
  199. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  200. %{l_shtool} install -c -m 644 \
  201. -e 's;@l_prefix@;%{l_prefix};g' \
  202. -e 's;@l_x11forwarding@;%{with_x11};' \
  203. %{SOURCE sshd_config} $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  204. %{l_shtool} install -c -m 644 -e 's;@l_prefix@;%{l_prefix};g' \
  205. %{SOURCE ssh_config} $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  206. # determine installation files
  207. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  208. %{l_files_std} \
  209. '%config %{l_prefix}/etc/openssh/*' \
  210. '%attr(4711,root,%{l_mgrp}) %{l_prefix}/libexec/openssh/ssh-keysign' \
  211. '%dir %attr(700,root,root) %{l_prefix}/var/openssh/empty' \
  212. '%config %{l_prefix}/etc/fsl/fsl.openssh' \
  213. '%not %dir %{l_prefix}/etc/fsl'
  214. %files -f files
  215. %clean
  216. rm -rf $RPM_BUILD_ROOT
  217. %post
  218. # generate server RSA1 (SSHv1) key
  219. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" -o \
  220. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" ] ; then
  221. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa1 -b 2048 \
  222. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key \
  223. -N '' -C `hostname` 1>&2
  224. fi
  225. # generate server RSA (SSHv2) key
  226. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key" -o \
  227. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key" ] ; then
  228. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa -b 2048 \
  229. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key \
  230. -N '' -C `hostname` 1>&2
  231. fi
  232. # generate server DSA (SSHv2) key
  233. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" -o \
  234. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" ] ; then
  235. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t dsa -b 2048 \
  236. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key \
  237. -N '' -C `hostname` 1>&2
  238. fi
  239. # add PAM configuration entry
  240. %if "%{with_pam}" == "yes"
  241. $RPM_INSTALL_PREFIX/sbin/pamtool --add --smart --name=openssh
  242. %endif
  243. %preun
  244. # remove PAM configuration entry
  245. %if "%{with_pam}" == "yes"
  246. $RPM_INSTALL_PREFIX/sbin/pamtool --remove --smart --name=openssh
  247. %endif