openssh.spec 8.2 KB

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