openssh.spec 8.6 KB

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