openssh.spec 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. ##
  2. ## openssh.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
  4. ## Copyright (c) 2000-2003 Ralf S. Engelschall <rse@engelschall.com>
  5. ## Copyright (c) 2000-2003 Cable & Wireless <http://www.cw.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.7.1
  27. %define V_portable p2
  28. %define V_chroot 3.7
  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: 20030923
  40. # package options
  41. %option with_fsl yes
  42. %option with_pam no
  43. %option with_pcre no
  44. %option with_skey no
  45. %option with_x11 no
  46. %option with_chroot no
  47. # list of sources
  48. Source0: ftp://ftp.openssh.com/pub/OpenBSD/OpenSSH/portable/openssh-%{version}.tar.gz
  49. Source1: rc.openssh
  50. Source2: fsl.openssh
  51. Source3: sshd_config
  52. Source4: ssh_config
  53. Source5: ssh-askpass
  54. Source6: ssh-keyman
  55. Source7: ssh-keyman.1
  56. Source8: ssh-keyman.pod
  57. Source9: http://chrootssh.sourceforge.net/download/osshChroot-%{V_chroot}.diff
  58. # build information
  59. Prefix: %{l_prefix}
  60. BuildRoot: %{l_buildroot}
  61. BuildPreReq: OpenPKG, openpkg >= 20030718, perl
  62. PreReq: OpenPKG, openpkg >= 20030718
  63. BuildPreReq: openssl, zlib
  64. PreReq: openssl, zlib
  65. %if "%{with_pam}" == "yes"
  66. BuildPreReq: PAM
  67. PreReq: PAM
  68. %endif
  69. %if "%{with_fsl}" == "yes"
  70. BuildPreReq: fsl >= 1.2.0
  71. PreReq: fsl >= 1.2.0
  72. %endif
  73. %if "%{with_pcre}" == "yes"
  74. BuildPreReq: pcre
  75. PreReq: pcre
  76. %endif
  77. %if "%{with_skey}" == "yes"
  78. BuildPreReq: skey
  79. PreReq: 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. %prep
  98. # unpack distribution
  99. %setup -q
  100. # optionally apply chroot(2) patch
  101. %if "%{with_chroot}" == "yes"
  102. %{l_patch} -p1 <%{SOURCE osshChroot-%{V_chroot}.diff}
  103. %endif
  104. # enforce "openssh" and the PAM identification string
  105. %if "%{with_pam}" == "yes"
  106. %{l_shtool} subst \
  107. -e 's;\(define *SSHD_PAM_SERVICE\).*;\1 "openssh";' \
  108. auth-pam.h
  109. %endif
  110. # prevent in advance "make install" from running sshd
  111. %{l_shtool} subst \
  112. -e 's;^\(install:.*\)check-config\(.*\)$;\1 \2;' \
  113. Makefile.in
  114. %build
  115. # configure package
  116. inc="%{l_cppflags}"
  117. lib="%{l_ldflags}"
  118. %if "%{with_pam}" == "yes"
  119. inc="$inc -I`%{l_prefix}/etc/rc --query pam_incdir`"
  120. lib="$lib -L`%{l_prefix}/etc/rc --query pam_libdir`"
  121. %endif
  122. CC="%{l_cc}" \
  123. CFLAGS="%{l_cflags -O} $inc" \
  124. LDFLAGS="%{l_ldflags} %{l_fsl_ldflags} $lib" \
  125. LIBS="%{l_fsl_libs}" \
  126. ./configure \
  127. --prefix=%{l_prefix} \
  128. --sbindir=%{l_prefix}/bin \
  129. --mandir=%{l_prefix}/man \
  130. --infodir=%{l_prefix}/info \
  131. --sysconfdir=%{l_prefix}/etc/openssh \
  132. --libexecdir=%{l_prefix}/libexec/openssh \
  133. --localstatedir=%{l_prefix}/var/openssh \
  134. --with-pid-dir=%{l_prefix}/var/openssh \
  135. --with-ssl-dir=%{l_prefix} \
  136. %if "%{with_pcre}" == "yes"
  137. --with-pcre=%{l_prefix} \
  138. %endif
  139. %if "%{with_skey}" == "yes"
  140. --with-skey=%{l_prefix} \
  141. %endif
  142. %if "%{with_pam}" == "yes"
  143. --with-pam \
  144. %else
  145. --without-pam \
  146. %endif
  147. %if "%{with_x11}" == "yes"
  148. --with-xauth="`%{l_prefix}/etc/rc --query x11_bindir`/xauth" \
  149. %endif
  150. --with-md5-passwords \
  151. --with-zlib=%{l_prefix} \
  152. --with-ipv4-default \
  153. --without-smartcard \
  154. --without-kerberos4 \
  155. --disable-suid-ssh \
  156. --without-rsh \
  157. --with-mantype=man \
  158. --with-default-path=%{l_prefix}/bin:/bin:/usr/bin:/usr/local/bin \
  159. --with-privsep-user=%{l_nusr} \
  160. --with-privsep-path=%{l_prefix}/var/openssh/empty
  161. # build package
  162. %{l_make} %{l_mflags -O}
  163. %install
  164. rm -rf $RPM_BUILD_ROOT
  165. # perform standard installation procedure of OpenSSH
  166. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  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 %{l_value -s -a} \
  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 %{l_value -s -a} \
  186. %{SOURCE ssh-keyman} $RPM_BUILD_ROOT%{l_prefix}/bin/
  187. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  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 %{l_value -s -a} \
  192. %{SOURCE rc.openssh} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  193. # install reasonable ssh server and client configuration files
  194. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/openssh
  195. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  196. -e 's;@l_x11forwarding@;%{with_x11};' \
  197. %{SOURCE sshd_config} $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  198. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  199. %{SOURCE ssh_config} $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  200. # install OSSP fsl configuration
  201. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  202. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  203. %{SOURCE fsl.openssh} \
  204. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  205. # determine installation files
  206. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  207. %{l_files_std} \
  208. '%not %dir %{l_prefix}/etc/fsl' \
  209. '%config %{l_prefix}/etc/fsl/fsl.openssh' \
  210. '%config %{l_prefix}/etc/openssh/*' \
  211. '%attr(4711,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/openssh/ssh-keysign' \
  212. '%dir %attr(700,%{l_susr},%{l_sgrp}) %{l_prefix}/var/openssh/empty'
  213. %files -f files
  214. %clean
  215. rm -rf $RPM_BUILD_ROOT
  216. %post
  217. # generate server RSA1 (SSHv1) key
  218. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" -o \
  219. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" ] ; then
  220. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa1 -b 2048 \
  221. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key \
  222. -N '' -C `hostname` 1>&2
  223. fi
  224. # generate server RSA (SSHv2) key
  225. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key" -o \
  226. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key" ] ; then
  227. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa -b 2048 \
  228. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key \
  229. -N '' -C `hostname` 1>&2
  230. fi
  231. # generate server DSA (SSHv2) key
  232. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" -o \
  233. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" ] ; then
  234. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t dsa -b 2048 \
  235. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key \
  236. -N '' -C `hostname` 1>&2
  237. fi
  238. %if "%{with_pam}" == "yes"
  239. # add PAM configuration entry
  240. if [ $1 -eq 1 ]; then
  241. $RPM_INSTALL_PREFIX/sbin/pamtool --add --smart --name=openssh
  242. fi
  243. %endif
  244. # after upgrade, restart service
  245. [ $1 -eq 2 ] || exit 0
  246. eval `%{l_rc} openssh status 2>/dev/null`
  247. [ ".$openssh_active" = .yes ] && %{l_rc} openssh restart
  248. exit 0
  249. %preun
  250. # before erase, stop service and remove log files
  251. [ $1 -eq 0 ] || exit 0
  252. %{l_rc} openssh stop 2>/dev/null
  253. rm -f $RPM_INSTALL_PREFIX/var/openssh/openssh.log* >/dev/null 2>&1 || true
  254. %if "%{with_pam}" == "yes"
  255. # remove PAM configuration entry
  256. $RPM_INSTALL_PREFIX/sbin/pamtool --remove --smart --name=openssh
  257. %endif
  258. exit 0