#
# RPM spec file for SSH Secure Shell
#
# This ssh.spec file is provided as is and for the benefit of
# academic and non-commercial SSH Secure Shell users. We are
# not promising to maintain this file in the future.
#

Summary: SSH Secure Shell
Name: ssh
Version: 3.2.5
Release: noncommercial
Copyright: Non-commercial, see LICENSE.
Group: Applications/Internet
Source: ssh-3.2.5.tar.gz
URL: http://www.ssh.com
Vendor: SSH Communications Security Corp.
Packager: SSH Secure Shell Team <http://www.ssh.com>
BuildRoot: /usr/src/redhat/BUILD/ssh-3.2.5
AutoReqProv: no
Requires: glibc >= 2.1, pam >= 0.72, libtermcap >= 2.0
#Requires: glibc >= 2.1, pam >= 0.72, libtermcap >= 2.0, ncurses >= 5.0


%description
SSH Secure Shell - a secure remote login, file transfer and much more.

This is a non-commercial version of the product and it includes no support.
If you wish to purchase a commercial version which entitles you to get
support for this product, see our Online Store at http://commerce.ssh.com

You must read the accompanied LICENSE file before use.

Upgrade will work if you have ssh-3.1.0 or newer packages installed,
in any other case you must first remove all old versions.


%prep

%setup -n ssh-3.2.5


%build
# This installs with the default /usr/local prefix.
# So, leave it alone unless you want a different directory.
# By default, we are including client SecurID support and static binaries for
# chrooting sftp (see the man page for ssh-dummy-shell and ssh-chrootmgr).
/configure --with-clientsecurid --without-x11-security
make


%install
make DESTDIR="$RPM_BUILD_ROOT" install
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
mkdir -p $RPM_BUILD_ROOT/etc/pam.d
cp startup/linux/redhat/sshd2 $RPM_BUILD_ROOT/etc/rc.d/init.d/sshd2
cp pamd.sshd2 $RPM_BUILD_ROOT/etc/pam.d/sshd2


%pre
# Move config files to safety
if test -f /etc/ssh2/ssh2_config; then
 mv -f /etc/ssh2/ssh2_config /etc/ssh2/ssh2_config.rpmtemp;
fi

if test -f /etc/ssh2/ssh_dummy_shell.out; then
 mv -f /etc/ssh2/ssh_dummy_shell.out /etc/ssh2/ssh_dummy_shell.out.rpmtemp;
fi

if test -f /etc/ssh2/sshd2_config; then
 mv -f /etc/ssh2/sshd2_config /etc/ssh2/sshd2_config.rpmtemp;
fi


%post
# Move config files back and new ones to a different name
if test -f /etc/ssh2/ssh2_config.rpmtemp; then
 if test -f /etc/ssh2/ssh2_config; then
   mv -f /etc/ssh2/ssh2_config /etc/ssh2/ssh2_config.rpmnew;
 fi
 mv -f /etc/ssh2/ssh2_config.rpmtemp /etc/ssh2/ssh2_config;
fi

if test -f /etc/ssh2/sshd2_config.rpmtemp; then
 if test -f /etc/ssh2/sshd2_config; then
   mv -f /etc/ssh2/sshd2_config /etc/ssh2/sshd2_config.rpmnew;
 fi
 mv -f /etc/ssh2/sshd2_config.rpmtemp /etc/ssh2/sshd2_config;
fi

if test -f /etc/ssh2/ssh_dummy_shell.out.rpmtemp; then
 if test -f /etc/ssh2/ssh_dummy_shell.out; then
   mv -f /etc/ssh2/ssh_dummy_shell.out /etc/ssh2/ssh_dummy_shell.out.rpmnew;
 fi
 mv -f /etc/ssh2/ssh_dummy_shell.out.rpmtemp /etc/ssh2/ssh_dummy_shell.out;
fi

# Generate hostkey if not found
if ! test -f /etc/ssh2/hostkey;
then
 echo "Hostkey not found at /etc/ssh2/hostkey.";
 umask 022;
 /usr/local/bin/ssh-keygen2 -P -t dsa /etc/ssh2/hostkey;
else
 echo "Hostkey found at /etc/ssh2/hostkey, not regenerating.";
fi

# Make the symlinks
ln -sf /usr/local/bin/scp2 /usr/local/bin/scp
ln -sf /usr/local/bin/sftp2 /usr/local/bin/sftp
ln -sf /usr/local/bin/sftp-server2 /usr/local/bin/sftp-server
ln -sf /usr/local/bin/ssh2 /usr/local/bin/ssh
ln -sf /usr/local/bin/ssh-add2 /usr/local/bin/ssh-add
ln -sf /usr/local/bin/ssh-agent2 /usr/local/bin/ssh-agent
ln -sf /usr/local/bin/ssh-keygen2 /usr/local/bin/ssh-keygen
ln -sf /usr/local/bin/ssh-probe2 /usr/local/bin/ssh-probe
ln -sf /usr/local/bin/ssh-signer2 /usr/local/bin/ssh-signer
ln -sf /usr/local/sbin/sshd2 /usr/local/sbin/sshd

# Make the symlinks for init
if test -x /sbin/chkconfig;
then
 /sbin/chkconfig --add sshd2;
else
 ln -sf /etc/rc.d/init.d/sshd2 /etc/rc.d/rc0.d/K15sshd2;
 ln -sf /etc/rc.d/init.d/sshd2 /etc/rc.d/rc1.d/K15sshd2;
 ln -sf /etc/rc.d/init.d/sshd2 /etc/rc.d/rc2.d/K15sshd2;
 ln -sf /etc/rc.d/init.d/sshd2 /etc/rc.d/rc3.d/S85sshd2;
 ln -sf /etc/rc.d/init.d/sshd2 /etc/rc.d/rc4.d/S85sshd2;
 ln -sf /etc/rc.d/init.d/sshd2 /etc/rc.d/rc5.d/S85sshd2;
 ln -sf /etc/rc.d/init.d/sshd2 /etc/rc.d/rc6.d/K15sshd2;
fi
echo "";
echo "Please note that you have to start (or restart) sshd2 manually.";


%preun
# Copy config files to safety
if test -f /etc/ssh2/ssh2_config; then
 cp -f /etc/ssh2/ssh2_config /etc/ssh2/ssh2_config.rpmtemp;
fi

if test -f /etc/ssh2/ssh_dummy_shell.out; then
 cp -f /etc/ssh2/ssh_dummy_shell.out /etc/ssh2/ssh_dummy_shell.out.rpmtemp;
fi

if test -f /etc/ssh2/sshd2_config; then
 cp -f /etc/ssh2/sshd2_config /etc/ssh2/sshd2_config.rpmtemp;
fi

# Upgrading? Ok, we're done.
[ $1 = 0 ] || exit 0;

# Remove the init symlinks
if test -x /sbin/chkconfig;
then
 /sbin/chkconfig --del sshd2;
else
 rm -f /etc/rc.d/rc0.d/K15sshd2;
 rm -f /etc/rc.d/rc1.d/K15sshd2;
 rm -f /etc/rc.d/rc2.d/K15sshd2;
 rm -f /etc/rc.d/rc3.d/S85sshd2;
 rm -f /etc/rc.d/rc4.d/S85sshd2;
 rm -f /etc/rc.d/rc5.d/S85sshd2;
 rm -f /etc/rc.d/rc6.d/K15sshd2;
fi
echo "";
echo "Your configuration files have not been deleted.";
echo "Please note that you have to stop sshd2 manually.";


%postun
# Copy config files back and new ones to a different name
if test -f /etc/ssh2/ssh2_config.rpmtemp; then
 mv -f /etc/ssh2/ssh2_config.rpmtemp /etc/ssh2/ssh2_config;
fi

if test -f /etc/ssh2/sshd2_config.rpmtemp; then
 mv -f /etc/ssh2/sshd2_config.rpmtemp /etc/ssh2/sshd2_config;
fi

if test -f /etc/ssh2/ssh_dummy_shell.out.rpmtemp; then
 mv -f /etc/ssh2/ssh_dummy_shell.out.rpmtemp /etc/ssh2/ssh_dummy_shell.out;
fi

# Upgrading? Ok, we're done.
[ $1 = 0 ] || exit 0;

# Remove symlinks
rm -f /usr/local/bin/ssh;
rm -f /usr/local/bin/scp;
rm -f /usr/local/bin/ssh-agent;
rm -f /usr/local/bin/ssh-keygen;
rm -f /usr/local/bin/ssh-add;
rm -f /usr/local/bin/sftp
rm -f /usr/local/bin/sftp-server
rm -f /usr/local/bin/ssh-probe
rm -f /usr/local/bin/ssh-signer
rm -f /usr/local/sbin/sshd;

# Check if ssh1 versions exist and if so, make symlinks back to them
if test -f /usr/local/bin/ssh1; then
 ln -sf /usr/local/bin/ssh1 /usr/local/bin/ssh;
fi

if test -f /usr/local/bin/ssh-add1; then
 ln -sf /usr/local/bin/ssh-add1 /usr/local/bin/ssh-add;
fi

if test -f /usr/local/bin/ssh-agent1; then
 ln -sf /usr/local/bin/ssh-agent1 /usr/local/bin/ssh-agent;
fi

if test -f /usr/local/bin/scp1; then
 ln -sf /usr/local/bin/scp1 /usr/local/bin/scp;
fi

if test -f /usr/local/bin/ssh-keygen1; then
 ln -sf /usr/local/bin/ssh-keygen1 /usr/local/bin/ssh-keygen;
fi

if test -f /usr/local/sbin/sshd1; then
 ln -sf /usr/local/sbin/sshd1 /usr/local/sbin/sshd;
fi


%files
%doc CHANGES
%doc FAQ
%doc HOWTO.anonymous.sftp
%doc INSTALL
%doc LICENSE
%doc MANIFEST
%doc NEWS
%doc README
%doc README.SSH-F-CONFIGD
%doc REGEX-SYNTAX
%doc SSH2.QUICKSTART
%doc RFC.authorization_program_protocol
%doc RFC.kbdint_plugin_protocol
%doc drafts/draft-ietf-secsh-architecture-12.txt
%doc drafts/draft-ietf-secsh-auth-kbdinteract-03.txt
%doc drafts/draft-ietf-secsh-connect-15.txt
%doc drafts/draft-ietf-secsh-dh-group-exchange-02.txt
%doc drafts/draft-ietf-secsh-dns-key-format-00.txt
%doc drafts/draft-ietf-secsh-filexfer-02.txt
%doc drafts/draft-ietf-secsh-fingerprint-00.txt
%doc drafts/draft-ietf-secsh-gsskeyex-03.txt
%doc drafts/draft-ietf-secsh-publickeyfile-02.txt
%doc drafts/draft-ietf-secsh-transport-14.txt
%doc drafts/draft-ietf-secsh-userauth-15.txt
%config /etc/ssh2/ssh2_config
%config /etc/ssh2/ssh_dummy_shell.out
%config /etc/ssh2/sshd2_config
/etc/ssh2/subconfig/host_ext.example
/etc/ssh2/subconfig/host_int.example
/etc/ssh2/subconfig/anonymous.example
/etc/ssh2/subconfig/user.example
/etc/ssh2/sshd2_config.example
/etc/ssh2/ssh2_config.example
/etc/rc.d/init.d/sshd2
/etc/pam.d/sshd2
/usr/local/bin/scp2
/usr/local/bin/sftp2
/usr/local/bin/sftp-server2
/usr/local/bin/ssh2
/usr/local/bin/ssh-add2
/usr/local/bin/ssh-agent2
/usr/local/bin/ssh-dummy-shell
/usr/local/bin/ssh-keygen2
/usr/local/bin/ssh-probe2
/usr/local/bin/ssh-signer2
/usr/local/sbin/sshd2
/usr/local/sbin/sshd-check-conf
/usr/local/man/man1/*
/usr/local/man/man5/*
/usr/local/man/man8/*


%changelog