openssh.spec 9.3 KB

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