openssh.spec 14 KB

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