openssh.spec 11 KB

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