openssh.spec 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. ##
  2. ## openssh.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2008 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ##
  5. ## Permission to use, copy, modify, and distribute this software for
  6. ## any purpose with or without fee is hereby granted, provided that
  7. ## the above copyright notice and this permission notice appear in all
  8. ## copies.
  9. ##
  10. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  11. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  12. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  13. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  14. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  15. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  16. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  17. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  19. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  20. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  21. ## SUCH DAMAGE.
  22. ##
  23. # package versions
  24. %define V_base 5.1
  25. %define V_portable p1
  26. %define V_watchdog 4.4p1
  27. %define V_ldap_base 4.6p1
  28. %define V_ldap_vers 0.3.9
  29. %define V_connect 100
  30. %define V_hpn 5.1p1-hpn13v5
  31. # package information
  32. Name: openssh
  33. Summary: Secure Shell (SSH)
  34. URL: http://www.openssh.com/
  35. Vendor: The OpenBSD Project
  36. Packager: OpenPKG Foundation e.V.
  37. Distribution: OpenPKG Community
  38. Class: CORE
  39. Group: SSH
  40. License: BSD
  41. Version: %{V_base}%{V_portable}
  42. Release: 20080730
  43. # package options
  44. %option with_fsl yes
  45. %option with_connect no
  46. %option with_alias no
  47. %option with_chroot no
  48. %option with_ldap no
  49. %option with_pam no
  50. %option with_kerberos no
  51. %option with_sftplogging no
  52. %option with_skey no
  53. %option with_watchdog no
  54. %option with_wrap no
  55. %option with_x11 no
  56. %option with_trysetpath no
  57. %option with_libedit no
  58. %option with_hpn no
  59. # list of sources
  60. Source0: ftp://ftp.openssh.com/pub/OpenBSD/OpenSSH/portable/openssh-%{version}.tar.gz
  61. Source1: rc.openssh
  62. Source2: fsl.openssh
  63. Source3: sshd_config
  64. Source4: ssh_config
  65. Source5: ssh-askpass
  66. Source6: ssh-keyman
  67. Source7: ssh-keyman.1
  68. Source8: ssh-keyman.pod
  69. Source9: ftp://ftp.openpkg.org/sources/CPY/VERSIONED/openssh-connect/openssh-connect-%{V_connect}.tar.gz
  70. Patch0: openssh.patch
  71. Patch1: openssh.patch.chroot
  72. Patch2: openssh.patch.alias
  73. Patch3: http://www.sc.isc.tohoku.ac.jp/~hgot/sources/openssh-%{V_watchdog}-watchdog.patch.tgz
  74. Patch4: http://dev.inversepath.com/openssh-lpk/openssh-lpk-%{V_ldap_base}-%{V_ldap_vers}.patch
  75. Patch5: openssh.patch.sftplogging
  76. Patch6: openssh.patch.scpbindir
  77. Patch7: http://www.psc.edu/networking/projects/hpn-ssh/openssh-%{V_hpn}.diff.gz
  78. # build information
  79. Prefix: %{l_prefix}
  80. BuildRoot: %{l_buildroot}
  81. BuildPreReq: OpenPKG, openpkg >= 20060823, perl
  82. PreReq: OpenPKG, openpkg >= 20060823
  83. BuildPreReq: openssl, zlib
  84. PreReq: openssl, zlib
  85. %if "%{with_pam}" == "yes"
  86. BuildPreReq: PAM
  87. PreReq: PAM
  88. %endif
  89. %if "%{with_kerberos}" == "yes"
  90. BuildPreReq: KERBEROS
  91. PreReq: KERBEROS
  92. %endif
  93. %if "%{with_fsl}" == "yes"
  94. BuildPreReq: fsl
  95. PreReq: fsl
  96. %endif
  97. %if "%{with_skey}" == "yes"
  98. BuildPreReq: skey
  99. PreReq: skey
  100. %endif
  101. %if "%{with_x11}" == "yes"
  102. BuildPreReq: X11
  103. PreReq: X11
  104. %endif
  105. %if "%{with_ldap}" == "yes"
  106. BuildPreReq: openldap
  107. PreReq: openldap
  108. %endif
  109. %if "%{with_wrap}" == "yes"
  110. BuildPreReq: tcpwrappers
  111. PreReq: tcpwrappers
  112. %endif
  113. %if "%{with_libedit}" == "yes"
  114. BuildPreReq: libedit
  115. PreReq: libedit
  116. %endif
  117. AutoReq: no
  118. AutoReqProv: no
  119. %description
  120. Secure Shell (SSH) is a facility for logging into a remote machine
  121. and for remotely executing commands on a remote machine. It is
  122. intended to replace rlogin(1) and rsh(1), and provide secure
  123. encrypted communications between two untrusted hosts over an
  124. insecure network. X11 connections and arbitrary TCP/IP ports can
  125. also be forwarded over the secure channel. OpenSSH is OpenBSD's
  126. rework of the last free version of SSH, bringing it up to date in
  127. terms of security and features, as well as removing all patented
  128. algorithms to separate libraries (OpenSSL).
  129. %track
  130. prog openssh = {
  131. version = %{version}
  132. url = ftp://ftp.openssh.com/pub/OpenBSD/OpenSSH/portable/
  133. regex = openssh-(__VER__)\.tar\.gz
  134. }
  135. prog openssh:watchdog = {
  136. version = %{V_watchdog}
  137. url = http://www.sc.isc.tohoku.ac.jp/~hgot/sources/openssh-watchdog.html
  138. regex = HREF=.openssh-(__VER__)-watchdog\.patch\.tgz
  139. }
  140. prog openssh:ldap = {
  141. version = %{V_ldap_base}-%{V_ldap_vers}
  142. url = http://dev.inversepath.com/openssh-lpk/
  143. regex = openssh-lpk-(__VER__)\.patch
  144. }
  145. prog openssh:hpn = {
  146. version = %{V_hpn}
  147. url = http://www.psc.edu/networking/projects/hpn-ssh/
  148. regex = openssh-(__VER__-hpn__VER__)\.diff\.gz
  149. }
  150. %prep
  151. # unpack and patch distribution
  152. %setup -q
  153. %if "%{with_connect}" == "yes"
  154. %setup -q -D -T -a 9
  155. %endif
  156. %patch -p0 -P 0
  157. %{l_shtool} subst \
  158. -e 's;@l_openpkg_release@;%{l_openpkg_release -F "OpenPKG-%%t"};' \
  159. version.h
  160. %if "%{with_chroot}" == "yes"
  161. %patch -p0 -P 1
  162. %endif
  163. %if "%{with_alias}" == "yes"
  164. %patch -p0 -P 2
  165. %endif
  166. %if "%{with_watchdog}" == "yes"
  167. %{l_gzip} -d -c %{SOURCE openssh-%{V_watchdog}-watchdog.patch.tgz} | %{l_tar} xf -
  168. %{l_patch} -p0 -b <openssh-%{V_watchdog}-watchdog.patch
  169. %endif
  170. %if "%{with_ldap}" == "yes"
  171. %{l_patch} -p2 -b <%{SOURCE openssh-lpk-%{V_ldap_base}-%{V_ldap_vers}.patch}
  172. %{l_prefix}/bin/perl -pi -e 's/(#include <stdio\.h>)/$1\n#include <stdarg.h>/' ldapauth.c
  173. %endif
  174. %if "%{with_sftplogging}" == "yes"
  175. %patch -p0 -P 5
  176. %endif
  177. %if "%{with_hpn}" == "yes"
  178. %{l_gzip} -d -c %{SOURCE openssh-%{V_hpn}.diff.gz} |\
  179. sed -e '/^diff.*\/version\.h/,$d' | %{l_patch} -p1 -b
  180. %{l_shtool} subst -e 's;\(SSH_VERSION SSH_PORTABLE\);\1 "-hpn";' version.h
  181. %endif
  182. sed -e 's;@l_prefix@;%{l_prefix};g' %{SOURCE openssh.patch.scpbindir} | %{l_patch} -p0 -b
  183. case "%{l_platform -t}" in
  184. *-darwin* )
  185. %{l_shtool} subst \
  186. -e 's;LIBS="-lcrypto $LIBS";LIBS="%{l_prefix}/lib/libcrypto.a $LIBS";' \
  187. configure
  188. ;;
  189. esac
  190. %build
  191. # configure package
  192. cflags=""
  193. ldflags=""
  194. %if "%{with_chroot}" == "yes"
  195. cflags="$cflags -DUSE_CHROOT"
  196. %endif
  197. %if "%{with_alias}" == "yes"
  198. cflags="$cflags -DUSE_ALIAS"
  199. %endif
  200. %if "%{with_pam}" == "yes"
  201. cflags="$cflags -I`%{l_rc} --query pam_incdir`"
  202. ldflags="$ldflags -L`%{l_rc} --query pam_libdir`"
  203. %endif
  204. %if "%{with_ldap}" == "yes"
  205. cflags="$cflags -DLDAP_DEPRECATED"
  206. ldflags="$ldflags -lldap -llber -lcrypto -lssl"
  207. %endif
  208. strip="--enable-strip"; %{l_shtool} path strip || strip="--disable-strip"
  209. CC="%{l_cc}" \
  210. CFLAGS="%{l_cflags -O} %{l_cppflags} $cflags" \
  211. LDFLAGS="%{l_ldflags} %{l_fsl_ldflags} $ldflags" \
  212. LIBS="%{l_fsl_libs}" \
  213. GREP="grep" \
  214. ./configure \
  215. --prefix=%{l_prefix} \
  216. --sbindir=%{l_prefix}/bin \
  217. --mandir=%{l_prefix}/man \
  218. --infodir=%{l_prefix}/info \
  219. --sysconfdir=%{l_prefix}/etc/openssh \
  220. --libexecdir=%{l_prefix}/libexec/openssh \
  221. --localstatedir=%{l_prefix}/var/openssh \
  222. --with-pid-dir=%{l_prefix}/var/openssh \
  223. --with-ssl-dir=%{l_prefix} \
  224. %if "%{with_skey}" == "yes"
  225. --with-skey=%{l_prefix} \
  226. %endif
  227. %if "%{with_pam}" == "yes"
  228. --with-pam \
  229. %else
  230. --without-pam \
  231. %endif
  232. %if "%{with_x11}" == "yes"
  233. --with-xauth="`%{l_rc} --query x11_bindir`/xauth" \
  234. %endif
  235. %if "%{with_wrap}" == "yes"
  236. --with-tcp-wrappers=%{l_prefix} \
  237. %endif
  238. %if "%{with_ldap}" == "yes"
  239. --with-ldap=%{l_prefix} \
  240. %endif
  241. %if "%{with_libedit}" == "yes"
  242. --with-libedit=%{l_prefix} \
  243. %endif
  244. --with-md5-passwords \
  245. --with-zlib=%{l_prefix} \
  246. %if "%{with_kerberos}" == "yes"
  247. --with-kerberos5=%{l_prefix} \
  248. %else
  249. --without-kerberos5 \
  250. %endif
  251. --with-mantype=man \
  252. %if "%{with_trysetpath}" == "yes"
  253. --enable-etc-default-login \
  254. --with-default-path=%{l_prefix}/bin:/bin:/usr/bin \
  255. --with-superuser-path=%{l_prefix}/bin:/bin:/usr/bin:%{l_prefix}/sbin:/sbin:/usr/sbin \
  256. %else
  257. --disable-etc-default-login \
  258. --with-default-path=/bin:/usr/bin \
  259. --with-superuser-path=/bin:/usr/bin:/sbin:/usr/sbin \
  260. %endif
  261. --with-privsep-user=%{l_nusr} \
  262. --with-privsep-path=%{l_prefix}/var/openssh/empty \
  263. $strip
  264. # build package
  265. %{l_make} %{l_mflags -O}
  266. %if "%{with_connect}" == "yes"
  267. # build proxy connect utility
  268. ( cd openssh-connect
  269. CC="%{l_cc}" \
  270. CFLAGS="%{l_cflags -O}" \
  271. CPPFLAGS="%{l_cppflags}" \
  272. LDFLAGS="%{l_ldflags}" \
  273. ./configure \
  274. --prefix=%{l_prefix}
  275. %{l_make} %{l_mflags}
  276. ) || exit $?
  277. %endif
  278. %install
  279. rm -rf $RPM_BUILD_ROOT
  280. # perform standard installation procedure of OpenSSH
  281. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  282. # strip down installation tree
  283. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share
  284. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/slogin
  285. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/slogin.1
  286. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  287. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/* 2>/dev/null || true
  288. %if "%{with_connect}" == "yes"
  289. # install proxy connect utility
  290. ( cd openssh-connect
  291. strip connect 2>/dev/null || true
  292. %{l_shtool} install -c -m 755 connect \
  293. $RPM_BUILD_ROOT%{l_prefix}/bin/ssh-connect
  294. ) || exit $?
  295. %endif
  296. # install ssh-askpass wrapper
  297. %{l_shtool} mkdir -f -p -m 755 \
  298. $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh
  299. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  300. %{SOURCE ssh-askpass} \
  301. $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/
  302. # make sure the state directory exists
  303. %{l_shtool} mkdir -f -p -m 755 \
  304. $RPM_BUILD_ROOT%{l_prefix}/var/openssh \
  305. $RPM_BUILD_ROOT%{l_prefix}/var/openssh/empty
  306. # install addons
  307. %{l_shtool} mkdir -f -p -m 755 \
  308. $RPM_BUILD_ROOT%{l_prefix}/bin \
  309. $RPM_BUILD_ROOT%{l_prefix}/man/man1
  310. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  311. %{SOURCE ssh-keyman} \
  312. $RPM_BUILD_ROOT%{l_prefix}/bin/
  313. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  314. %{SOURCE ssh-keyman.1} \
  315. $RPM_BUILD_ROOT%{l_prefix}/man/man1/
  316. # install run-command script
  317. %{l_shtool} mkdir -f -p -m 755 \
  318. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  319. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  320. %{SOURCE rc.openssh} \
  321. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  322. # install reasonable ssh server and client configuration files
  323. %{l_shtool} mkdir -f -p -m 755 \
  324. $RPM_BUILD_ROOT%{l_prefix}/etc/openssh
  325. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  326. -e 's;@l_x11forwarding@;%{with_x11};' \
  327. %{SOURCE sshd_config} \
  328. $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  329. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  330. %{SOURCE ssh_config} \
  331. $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  332. # install OSSP fsl configuration
  333. %{l_shtool} mkdir -f -p -m 755 \
  334. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  335. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  336. %{SOURCE fsl.openssh} \
  337. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  338. # determine installation files
  339. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  340. %{l_files_std} \
  341. '%config %{l_prefix}/etc/fsl/fsl.openssh' \
  342. '%config %{l_prefix}/etc/openssh/*' \
  343. '%attr(4711,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/openssh/ssh-keysign' \
  344. '%dir %attr(700,%{l_susr},%{l_mgrp}) %{l_prefix}/var/openssh/empty'
  345. %files -f files
  346. %clean
  347. rm -rf $RPM_BUILD_ROOT
  348. %post
  349. # generate server RSA1 (SSH1) key
  350. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" -o \
  351. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" ]; then
  352. rm -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key 2>/dev/null || true
  353. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa1 -b 2048 \
  354. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key \
  355. -N '' -C `hostname` 1>&2
  356. fi
  357. # generate server RSA (SSH2) key
  358. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key" -o \
  359. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key" ]; then
  360. rm -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key 2>/dev/null || true
  361. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa -b 2048 \
  362. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key \
  363. -N '' -C `hostname` 1>&2
  364. fi
  365. # generate server DSA (SSH2) key
  366. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" -o \
  367. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" ]; then
  368. rm -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key 2>/dev/null || true
  369. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t dsa -b 1024 \
  370. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key \
  371. -N '' -C `hostname` 1>&2
  372. fi
  373. %if "%{with_pam}" == "yes"
  374. # add PAM configuration entry
  375. if [ $1 -eq 1 ]; then
  376. $RPM_INSTALL_PREFIX/sbin/pamtool --add --smart --name=openssh
  377. fi
  378. %endif
  379. # on install, warn about PATH issues
  380. if [ $1 -eq 1 ]; then
  381. ( echo "Make sure sshd users have the proper PATH set to find"
  382. echo "utilities like scp, sftp-server, rsync, cvs, svn etc."
  383. %if "%{with_trysetpath}" == "yes"
  384. echo "This package tries to set the PATH for users and"
  385. echo "root properly. The success of this attempt is platform"
  386. echo "specific and out of OpenPKG scope. Please verify"
  387. echo "whether it works as expected."
  388. %endif
  389. ) | %{l_rpmtool} msg -b -t warn
  390. fi
  391. # after upgrade, restart service
  392. [ $1 -eq 2 ] || exit 0
  393. eval `%{l_rc} openssh status 2>/dev/null`
  394. [ ".$openssh_active" = .yes ] && %{l_rc} openssh restart
  395. exit 0
  396. %preun
  397. # before erase, stop service and remove log files
  398. [ $1 -eq 0 ] || exit 0
  399. %{l_rc} openssh stop 2>/dev/null
  400. rm -f $RPM_INSTALL_PREFIX/var/openssh/openssh.log* >/dev/null 2>&1 || true
  401. %if "%{with_pam}" == "yes"
  402. # remove PAM configuration entry
  403. $RPM_INSTALL_PREFIX/sbin/pamtool --remove --smart --name=openssh
  404. %endif
  405. exit 0