openssh.spec 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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_watchdog 3.7.1p1
  29. %define V_ldap_base 3.7.1p2
  30. %define V_ldap_vers1 v2.01
  31. %define V_ldap_vers2 v201
  32. # package information
  33. Name: openssh
  34. Summary: Secure Shell (SSH)
  35. URL: http://www.openssh.com/
  36. Vendor: The OpenBSD Project
  37. Packager: The OpenPKG Project
  38. Distribution: OpenPKG [CORE]
  39. Group: Security
  40. License: BSD
  41. Version: %{V_base}%{V_portable}
  42. Release: 20031231
  43. # package options
  44. %option with_fsl yes
  45. %option with_pam no
  46. %option with_skey no
  47. %option with_x11 no
  48. %option with_chroot no
  49. %option with_watchdog no
  50. %option with_ldap no
  51. %option with_wrap no
  52. # list of sources
  53. Source0: ftp://ftp.openssh.com/pub/OpenBSD/OpenSSH/portable/openssh-%{version}.tar.gz
  54. Source1: rc.openssh
  55. Source2: fsl.openssh
  56. Source3: sshd_config
  57. Source4: ssh_config
  58. Source5: ssh-askpass
  59. Source6: ssh-keyman
  60. Source7: ssh-keyman.1
  61. Source8: ssh-keyman.pod
  62. Patch0: openssh.patch
  63. Patch1: http://www.sc.isc.tohoku.ac.jp/~hgot/sources/openssh-%{V_watchdog}-watchdog.patch.tgz
  64. Patch2: http://ldappubkey.gcu-squad.org/%{V_ldap_vers1}/ldappubkey-ossh%{V_ldap_base}-%{V_ldap_vers2}.patch
  65. # build information
  66. Prefix: %{l_prefix}
  67. BuildRoot: %{l_buildroot}
  68. BuildPreReq: OpenPKG, openpkg >= 20030927, perl
  69. PreReq: OpenPKG, openpkg >= 20030927
  70. BuildPreReq: openssl, zlib
  71. PreReq: openssl, zlib
  72. %if "%{with_pam}" == "yes"
  73. BuildPreReq: PAM
  74. PreReq: PAM
  75. %endif
  76. %if "%{with_fsl}" == "yes"
  77. BuildPreReq: fsl >= 1.2.0
  78. PreReq: fsl >= 1.2.0
  79. %endif
  80. %if "%{with_skey}" == "yes"
  81. BuildPreReq: skey
  82. PreReq: skey
  83. %endif
  84. %if "%{with_x11}" == "yes"
  85. BuildPreReq: X11
  86. PreReq: X11
  87. %endif
  88. %if "%{with_ldap}" == "yes"
  89. BuildPreReq: openldap
  90. PreReq: openldap
  91. %endif
  92. %if "%{with_wrap}" == "yes"
  93. BuildPreReq: tcpwrappers
  94. PreReq: tcpwrappers
  95. %endif
  96. AutoReq: no
  97. AutoReqProv: no
  98. %description
  99. Secure Shell (SSH) is a facility for logging into a remote machine
  100. and for remotely executing commands on a remote machine. It is
  101. intended to replace rlogin(1) and rsh(1), and provide secure
  102. encrypted communications between two untrusted hosts over an
  103. insecure network. X11 connections and arbitrary TCP/IP ports can
  104. also be forwarded over the secure channel. OpenSSH is OpenBSD's
  105. rework of the last free version of SSH, bringing it up to date in
  106. terms of security and features, as well as removing all patented
  107. algorithms to separate libraries (OpenSSL).
  108. %prep
  109. # unpack and patch distribution
  110. %setup -q
  111. %patch -p0
  112. %{l_shtool} subst \
  113. -e 's;@l_openpkg_release@;%{l_openpkg_release -F "OpenPKG-%s"};' \
  114. version.h
  115. %if "%{with_watchdog}" == "yes"
  116. %{l_gzip} -d -c %{SOURCE openssh-%{V_watchdog}-watchdog.patch.tgz} | %{l_tar} xf -
  117. %{l_patch} -p0 <openssh-%{V_watchdog}-watchdog.patch
  118. %endif
  119. %if "%{with_ldap}" == "yes"
  120. %{l_gzip} -d -c %{SOURCE ldappubkey-ossh%{V_ldap_base}-%{V_ldap_vers2}.patch} | %{l_patch} -p0
  121. %endif
  122. %build
  123. # configure package
  124. cflags=""
  125. ldflags=""
  126. %if "%{with_chroot}" == "yes"
  127. cflags="$cflags -DUSE_CHROOT"
  128. %endif
  129. %if "%{with_pam}" == "yes"
  130. cflags="$cflags -I`%{l_prefix}/etc/rc --query pam_incdir`"
  131. ldflags="$ldflags -L`%{l_prefix}/etc/rc --query pam_libdir`"
  132. %endif
  133. %if "%{with_ldap}" == "yes"
  134. cflags="$cflags -DWITH_LDAP_PUBKEY"
  135. ldflags="$ldflags -lldap -llber -lcrypto -lssl"
  136. %endif
  137. CC="%{l_cc}" \
  138. CFLAGS="%{l_cflags -O} %{l_cppflags} $cflags" \
  139. LDFLAGS="%{l_ldflags} %{l_fsl_ldflags} $ldflags" \
  140. LIBS="%{l_fsl_libs}" \
  141. ./configure \
  142. --prefix=%{l_prefix} \
  143. --sbindir=%{l_prefix}/bin \
  144. --mandir=%{l_prefix}/man \
  145. --infodir=%{l_prefix}/info \
  146. --sysconfdir=%{l_prefix}/etc/openssh \
  147. --libexecdir=%{l_prefix}/libexec/openssh \
  148. --localstatedir=%{l_prefix}/var/openssh \
  149. --with-pid-dir=%{l_prefix}/var/openssh \
  150. --with-ssl-dir=%{l_prefix} \
  151. %if "%{with_skey}" == "yes"
  152. --with-skey=%{l_prefix} \
  153. %endif
  154. %if "%{with_pam}" == "yes"
  155. --with-pam \
  156. %else
  157. --without-pam \
  158. %endif
  159. %if "%{with_x11}" == "yes"
  160. --with-xauth="`%{l_prefix}/etc/rc --query x11_bindir`/xauth" \
  161. %endif
  162. %if "%{with_wrap}" == "yes"
  163. --with-tcp-wrappers=%{l_prefix} \
  164. %endif
  165. --with-md5-passwords \
  166. --with-zlib=%{l_prefix} \
  167. --with-ipv4-default \
  168. --without-smartcard \
  169. --without-kerberos4 \
  170. --disable-suid-ssh \
  171. --without-rsh \
  172. --with-mantype=man \
  173. --with-default-path=%{l_prefix}/bin:/bin:/usr/bin:/usr/local/bin \
  174. --with-privsep-user=%{l_nusr} \
  175. --with-privsep-path=%{l_prefix}/var/openssh/empty
  176. # build package
  177. %{l_make} %{l_mflags -O}
  178. %install
  179. rm -rf $RPM_BUILD_ROOT
  180. # perform standard installation procedure of OpenSSH
  181. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  182. # strip down installation tree
  183. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share
  184. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/slogin
  185. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/slogin.1
  186. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  187. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/* 2>/dev/null || true
  188. # install ssh-askpass wrapper
  189. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh
  190. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  191. %{SOURCE ssh-askpass} $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/
  192. # make sure the state directory exists
  193. %{l_shtool} mkdir -f -p -m 755 \
  194. $RPM_BUILD_ROOT%{l_prefix}/var/openssh \
  195. $RPM_BUILD_ROOT%{l_prefix}/var/openssh/empty
  196. # install addons
  197. %{l_shtool} mkdir -f -p -m 755 \
  198. $RPM_BUILD_ROOT%{l_prefix}/bin \
  199. $RPM_BUILD_ROOT%{l_prefix}/man/man1
  200. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  201. %{SOURCE ssh-keyman} $RPM_BUILD_ROOT%{l_prefix}/bin/
  202. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  203. %{SOURCE ssh-keyman.1} $RPM_BUILD_ROOT%{l_prefix}/man/man1/
  204. # install run-command script
  205. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  206. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  207. %{SOURCE rc.openssh} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  208. # install reasonable ssh server and client configuration files
  209. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/openssh
  210. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  211. -e 's;@l_x11forwarding@;%{with_x11};' \
  212. %{SOURCE sshd_config} $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  213. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  214. %{SOURCE ssh_config} $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  215. # install OSSP fsl configuration
  216. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  217. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  218. %{SOURCE fsl.openssh} \
  219. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  220. # determine installation files
  221. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  222. %{l_files_std} \
  223. '%not %dir %{l_prefix}/etc/fsl' \
  224. '%config %{l_prefix}/etc/fsl/fsl.openssh' \
  225. '%config %{l_prefix}/etc/openssh/*' \
  226. '%attr(4711,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/openssh/ssh-keysign' \
  227. '%dir %attr(700,%{l_susr},%{l_sgrp}) %{l_prefix}/var/openssh/empty'
  228. %files -f files
  229. %clean
  230. rm -rf $RPM_BUILD_ROOT
  231. %post
  232. # generate server RSA1 (SSHv1) key
  233. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" -o \
  234. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" ] ; then
  235. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa1 -b 2048 \
  236. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key \
  237. -N '' -C `hostname` 1>&2
  238. fi
  239. # generate server RSA (SSHv2) key
  240. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key" -o \
  241. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key" ] ; then
  242. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa -b 2048 \
  243. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key \
  244. -N '' -C `hostname` 1>&2
  245. fi
  246. # generate server DSA (SSHv2) key
  247. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" -o \
  248. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" ] ; then
  249. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t dsa -b 2048 \
  250. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key \
  251. -N '' -C `hostname` 1>&2
  252. fi
  253. %if "%{with_pam}" == "yes"
  254. # add PAM configuration entry
  255. if [ $1 -eq 1 ]; then
  256. $RPM_INSTALL_PREFIX/sbin/pamtool --add --smart --name=openssh
  257. fi
  258. %endif
  259. # after upgrade, restart service
  260. [ $1 -eq 2 ] || exit 0
  261. eval `%{l_rc} openssh status 2>/dev/null`
  262. [ ".$openssh_active" = .yes ] && %{l_rc} openssh restart
  263. exit 0
  264. %preun
  265. # before erase, stop service and remove log files
  266. [ $1 -eq 0 ] || exit 0
  267. %{l_rc} openssh stop 2>/dev/null
  268. rm -f $RPM_INSTALL_PREFIX/var/openssh/openssh.log* >/dev/null 2>&1 || true
  269. %if "%{with_pam}" == "yes"
  270. # remove PAM configuration entry
  271. $RPM_INSTALL_PREFIX/sbin/pamtool --remove --smart --name=openssh
  272. %endif
  273. exit 0