openssh.spec 8.3 KB

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