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.5
  27. %define V_portable p1
  28. %define V_chroot 3.5
  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: 20030103
  40. # package options
  41. %option with_pam no
  42. %option with_pcre no
  43. %option with_skey no
  44. %option with_x11 %{l_test -p x11}
  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/patches/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. cd openssh-%{version}
  94. %{l_patch} -p1 <%{SOURCE osshChroot-%{V_chroot}.diff}
  95. %endif
  96. # prevent in advance "make install" from running sshd
  97. %{l_shtool} subst \
  98. -e 's;^\(install:.*\)check-config\(.*\)$;\1 \2;' \
  99. Makefile.in
  100. %build
  101. # configure package
  102. inc="%{l_cppflags}"
  103. lib="%{l_ldflags}"
  104. %if "%{with_pam}" == "yes"
  105. inc="$inc -I`%{l_prefix}/etc/rc --query pam_incdir`"
  106. lib="$lib -L`%{l_prefix}/etc/rc --query pam_libdir`"
  107. %endif
  108. CC="%{l_cc}" \
  109. CFLAGS="%{l_cflags -O} `%{l_prefix}/bin/fsl-config --all --cflags` $inc" \
  110. LDFLAGS="%{l_ldflags} `%{l_prefix}/bin/fsl-config --all --ldflags` $lib" \
  111. LIBS="`%{l_prefix}/bin/fsl-config --all --libs`" \
  112. ./configure \
  113. --prefix=%{l_prefix} \
  114. --sbindir=%{l_prefix}/bin \
  115. --mandir=%{l_prefix}/man \
  116. --infodir=%{l_prefix}/info \
  117. --sysconfdir=%{l_prefix}/etc/openssh \
  118. --libexecdir=%{l_prefix}/libexec/openssh \
  119. --localstatedir=%{l_prefix}/var/openssh \
  120. --with-pid-dir=%{l_prefix}/var/openssh \
  121. --with-ssl-dir=%{l_prefix} \
  122. %if "%{with_pcre}" == "yes"
  123. --with-pcre=%{l_prefix} \
  124. %endif
  125. %if "%{with_skey}" == "yes"
  126. --with-skey=%{l_prefix} \
  127. %endif
  128. %if "%{with_pam}" == "yes"
  129. --with-pam \
  130. %else
  131. --without-pam \
  132. %endif
  133. %if "%{with_x11}" == "yes"
  134. --with-xauth="`%{l_prefix}/etc/rc --query x11_bindir`/xauth" \
  135. %endif
  136. --with-md5-passwords \
  137. --with-zlib=%{l_prefix} \
  138. --with-ipv4-default \
  139. --without-smartcard \
  140. --without-kerberos4 \
  141. --disable-suid-ssh \
  142. --without-rsh \
  143. --with-mantype=man \
  144. --with-default-path=%{l_prefix}/bin:/bin:/usr/bin:/usr/local/bin \
  145. --with-privsep-user=%{l_nusr} \
  146. --with-privsep-path=%{l_prefix}/var/openssh/empty
  147. # build package
  148. %{l_make} %{l_mflags -O}
  149. %install
  150. rm -rf $RPM_BUILD_ROOT
  151. # perform standard installation procedure of OpenSSH
  152. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  153. # strip down installation tree
  154. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share
  155. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/slogin
  156. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/slogin.1
  157. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2> /dev/null || true
  158. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/* 2> /dev/null || true
  159. # install ssh-askpass wrapper
  160. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh
  161. %{l_shtool} install -c -m 755 -e 's;@l_prefix@;%{l_prefix};g' \
  162. %{SOURCE ssh-askpass} $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/
  163. # make sure the state directory exists
  164. %{l_shtool} mkdir -f -p -m 755 \
  165. $RPM_BUILD_ROOT%{l_prefix}/var/openssh \
  166. $RPM_BUILD_ROOT%{l_prefix}/var/openssh/empty
  167. # install addons
  168. %{l_shtool} mkdir -f -p -m 755 \
  169. $RPM_BUILD_ROOT%{l_prefix}/bin \
  170. $RPM_BUILD_ROOT%{l_prefix}/man/man1
  171. %{l_shtool} install -c -m 755 -e 's;@l_prefix@;%{l_prefix};g' \
  172. %{SOURCE ssh-keyman} $RPM_BUILD_ROOT%{l_prefix}/bin/
  173. %{l_shtool} install -c -m 644 -e 's;@l_prefix@;%{l_prefix};g' \
  174. %{SOURCE ssh-keyman.1} $RPM_BUILD_ROOT%{l_prefix}/man/man1/
  175. # install run-command script
  176. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  177. %{l_shtool} install -c -m 755 -e 's;@l_prefix@;%{l_prefix};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,root,%{l_mgrp}) %{l_prefix}/libexec/openssh/ssh-keysign' \
  197. '%dir %attr(700,root,root) %{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