openssh.spec 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. ##
  2. ## openssh.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
  4. ## Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
  5. ## Copyright (c) 2000-2002 Ralf S. Engelschall <rse@engelschall.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. %define with_pcre yes
  26. %define with_skey no
  27. # package information
  28. Name: openssh
  29. Summary: Secure Shell (SSH)
  30. URL: http://www.openssh.com/
  31. Vendor: The OpenBSD Project
  32. Packager: The OpenPKG Project
  33. Distribution: OpenPKG [REL]
  34. Group: Cryptography
  35. License: BSD
  36. Version: 3.0.2p1
  37. Release: 20020206
  38. # list of sources
  39. Source0: ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-%{version}.tar.gz
  40. Source1: fakesyslog.tar.gz
  41. Source2: rc.openssh
  42. Source3: sshd_config
  43. Source4: ssh_config
  44. Source5: ssh-askpass
  45. # build information
  46. Prefix: %{l_prefix}
  47. BuildRoot: %{l_buildroot}
  48. BuildPreReq: OpenPKG, openpkg >= 20020206, perl, openssl, zlib
  49. %if "%{with_pcre}" == "yes"
  50. BuildPreReq: pcre
  51. %endif
  52. %if "%{with_skey}" == "yes"
  53. BuildPreReq: skey
  54. %endif
  55. PreReq: OpenPKG, openpkg >= 20020206
  56. AutoReq: no
  57. AutoReqProv: no
  58. %description
  59. Secure Shell (SSH) is a facility for logging into a remote machine
  60. and for remotely executing commands on a remote machine. It is
  61. intended to replace rlogin(1) and rsh(1), and provide secure
  62. encrypted communications between two untrusted hosts over an
  63. insecure network. X11 connections and arbitrary TCP/IP ports can
  64. also be forwarded over the secure channel. OpenSSH is OpenBSD's
  65. rework of the last free version of SSH, bringing it up to date in
  66. terms of security and features, as well as removing all patented
  67. algorithms to separate libraries (OpenSSL).
  68. %prep
  69. %setup0 -q -c -a 0
  70. %setup1 -q -T -D -a 1
  71. %build
  72. # build faked syslog(3) library
  73. fakesyslogdir="`pwd`/fakesyslog"
  74. ( cd fakesyslog
  75. CC="%{l_cc}" \
  76. CFLAGS="%{l_cflags -O}" \
  77. ./configure \
  78. --with-logfile=%{l_prefix}/var/openssh/sshd.log
  79. %{l_make} %{l_mflags}
  80. )
  81. # build OpenSSH
  82. ( cd openssh-%{version}
  83. CC="%{l_cc}" \
  84. CFLAGS="%{l_cflags -O} -I%{l_prefix}/include" \
  85. CPPFLAGS="-I%{l_prefix}/include" \
  86. LDFLAGS="-L%{l_prefix}/lib -L$fakesyslogdir" \
  87. LIBS="-lcrypt -lfakesyslog" \
  88. ./configure \
  89. --prefix=%{l_prefix} \
  90. --sbindir=%{l_prefix}/bin \
  91. --mandir=%{l_prefix}/man \
  92. --infodir=%{l_prefix}/info \
  93. --sysconfdir=%{l_prefix}/etc/openssh \
  94. --libexecdir=%{l_prefix}/libexec/openssh \
  95. --localstatedir=%{l_prefix}/var/openssh \
  96. --with-pid-dir=%{l_prefix}/var/openssh \
  97. --with-ssl-dir=%{l_prefix} \
  98. %if "%{with_pcre}" == "yes"
  99. --with-pcre=%{l_prefix} \
  100. %endif
  101. %if "%{with_skey}" == "yes"
  102. --with-skey=%{l_prefix} \
  103. %endif
  104. --with-zlib=%{l_prefix} \
  105. --with-ipv4-default \
  106. --with-md5-passwords \
  107. --with-pam \
  108. --without-smartcard \
  109. --without-kerberos4 \
  110. --disable-suid-ssh \
  111. --without-rsh \
  112. --with-mantype=man \
  113. --with-default-path=%{l_prefix}/bin:/bin:/usr/bin:/usr/local/bin
  114. # build package
  115. %{l_make} %{l_mflags -O}
  116. )
  117. %install
  118. rm -rf $RPM_BUILD_ROOT
  119. # perform standard installation procedure of OpenSSH
  120. ( cd openssh-%{version}
  121. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  122. )
  123. # strip down installation tree
  124. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share
  125. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/slogin
  126. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/slogin.1
  127. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2> /dev/null || true
  128. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/* 2> /dev/null || true
  129. # install ssh-askpass wrapper
  130. %{l_shtool} install -c -m 755 -e 's;@l_prefix@;%{l_prefix};g' \
  131. %{SOURCE ssh-askpass} $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/
  132. # make sure the state directory exists
  133. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/openssh
  134. # install run-command script
  135. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  136. %{l_shtool} install -c -m 755 -e 's;@l_prefix@;%{l_prefix};g' \
  137. -e 's;@l_musr@;%{l_musr};g' -e 's;@l_mgrp@;%{l_mgrp};g' \
  138. %{SOURCE rc.openssh} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  139. # install reasonable ssh server and client configuration files
  140. case "%{l_target}" in
  141. *-freebsd* ) uselogin=yes; printmotd=no ;;
  142. *-linux* ) uselogin=yes; printmotd=no ;;
  143. *-solaris* ) uselogin=no; printmotd=yes ;; # "uselogin" does not work on Solaris!
  144. esac
  145. %{l_shtool} install -c -m 644 \
  146. -e 's;@l_prefix@;%{l_prefix};g' \
  147. -e "s;@uselogin@;$uselogin;" \
  148. -e "s;@printmotd@;$printmotd;" \
  149. %{SOURCE sshd_config} $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  150. %{l_shtool} install -c -m 644 -e 's;@l_prefix@;%{l_prefix};g' \
  151. %{SOURCE ssh_config} $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  152. # determine installation files
  153. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  154. %{l_files_std} \
  155. '%config %{l_prefix}/etc/openssh/*'
  156. %files -f files
  157. %clean
  158. rm -rf $RPM_BUILD_ROOT
  159. %post
  160. # generate server RSA key
  161. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" -o \
  162. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" ] ; then
  163. $RPM_INSTALL_PREFIX/bin/ssh-keygen -b 1024 \
  164. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key \
  165. -N '' -C `hostname` 1>&2
  166. fi
  167. # generate server DSA key
  168. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" -o \
  169. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" ] ; then
  170. $RPM_INSTALL_PREFIX/bin/ssh-keygen -d \
  171. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key \
  172. -N '' -C `hostname` 1>&2
  173. fi
  174. # add PAM configuration entry
  175. if [ -f /etc/pam.conf ]; then
  176. ( case "%{l_target}" in
  177. *-freebsd* )
  178. echo "sshd auth sufficient pam_skey.so"
  179. echo "sshd auth required pam_unix.so try_first_pass"
  180. echo "sshd account required pam_unix.so"
  181. echo "sshd password required pam_permit.so"
  182. echo "sshd session required pam_permit.so"
  183. ;;
  184. *-linux* )
  185. echo "sshd auth required /lib/security/pam_unix_auth.so shadow nodelay"
  186. echo "sshd auth required /lib/security/pam_nologin.so"
  187. echo "sshd account required /lib/security/pam_unix_acct.so"
  188. echo "sshd password required /lib/security/pam_unix_passwd.so shadow nullok use_authtok"
  189. echo "sshd session required /lib/security/pam_unix_session.so"
  190. echo "sshd session required /lib/security/pam_limits.so"
  191. ;;
  192. *-solaris* )
  193. echo "sshd auth required /usr/lib/security/pam_unix.so try_first_pass"
  194. echo "sshd account required /usr/lib/security/pam_unix.so"
  195. echo "sshd password required /usr/lib/security/pam_unix.so"
  196. echo "sshd session required /usr/lib/security/pam_unix.so"
  197. ;;
  198. esac
  199. ) |\
  200. $RPM_INSTALL_PREFIX/sbin/rpmtool config \
  201. -a -s -i "$RPM_INSTALL_PREFIX:openssh" /etc/pam.conf
  202. fi
  203. %preun
  204. # remove PAM configuration entry
  205. if [ -f /etc/pam.conf ]; then
  206. $RPM_INSTALL_PREFIX/sbin/rpmtool config \
  207. -r -s -i "$RPM_INSTALL_PREFIX:openssh" /etc/pam.conf
  208. fi