- (bal) First wave of contrib/solaris/ package upgrades. Still more

work needs to be done, but it is a 190% better then the stuff we
    had before!
This commit is contained in:
Ben Lindstrom 2001-10-12 20:30:52 +00:00
parent 4a820ea750
commit 8b5ba1c39a
11 changed files with 174 additions and 686 deletions

View File

@ -18,6 +18,9 @@
- (djm) "make veryclean" fix from Tom Holroyd <tomh@po.crl.go.jp>
- (djm) Clean some autoconf-2.52 junk when doing "make distclean"
- (djm) Cleanup sshpty.c a little
- (bal) First wave of contrib/solaris/ package upgrades. Still more
work needs to be done, but it is a 190% better then the stuff we
had before!
20011010
- (djm) OpenBSD CVS Sync
@ -6716,4 +6719,4 @@
- Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1
$Id: ChangeLog,v 1.1606 2001/10/12 09:15:48 djm Exp $
$Id: ChangeLog,v 1.1607 2001/10/12 20:30:52 mouring Exp $

View File

@ -1,82 +0,0 @@
README for OpenSSH Solaris packaging scripts
Rip Loomis <loomisg@saic.com> - 2000-08-02
To use, simply expand this tarball under your main
OpenSSH source directory--it will create a
contrib/solaris subdirectory. Run configure and
make in OpenSSH as before. Then, from either
that directory or the main OpenSSH source directory,
run the command "build-pkg" (specifying the
appropriate path of course.) A subdirectory
will be created as contrib/solaris/build-SSH-package,
and after the build is done the package will be
present in that build-SSH-package directory
with a name of the form
OPENssh-$SSHversion-$arch-$OSversion[-$installLocation]
The build and install scripts should take into account
most possible situations (existing SSH installation,
differences in Solaris version between build and
target systems, changes you have made to the default
configuration, etc.) I would appreciate any feedback
or comments.
Copyright information is included below, followed by the known issue list.
Both are taken verbatim from the "build-pkg" script.
# OpenSSH solaris build script and supporting data files
# Copyright (c) 2000 Rip Loomis and
# Science Applications International Corporation (SAIC)
# (http://www.cist-east.saic.com). All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Obviously, without all the hard work of the OpenBSD OpenSSH developers
# and the OpenSSH Portability Team, these scripts would be pointless...
# so thanks again folks!
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#### Known issues
# These methods are generally based on a "default" compilation of
# OpenSSH on Solaris--so the more things that you change from the default,
# the greater the chance that something in the script won't be able to
# handle the changes. In general, though, most things should be determined
# from your compile environment--the architecture, SSH version, and
# other related data should all get picked up by this script. The script
# and data files were last updated to match OpenSSH 2.1.1p4.
#
# All building and packaging is done under a temporary directory that is
# itself created under the contrib/solaris directory--so there shouldn't
# be any special security issues (or need for root access during the
# packaging process). The temporary directory is defined below as
# ${BUILDDIR}.
#
# The permissions on the installed files are based on how we prefer to
# do things here--so nothing is installed SetUID to root.
#
# The post-install script makes a good-faith attempt to install a
# functional configuration on your system. I would be interested in hearing
# of any failure modes that are found, as I tried to compensate for all
# the ones that showed up here when we started replacing all the
# different installed versions of SSH.

View File

@ -1,218 +0,0 @@
#!/bin/sh
# OpenSSH solaris build script and supporting data files
# Copyright (c) 2000 Rip Loomis and
# Science Applications International Corporation (SAIC)
# (http://www.cist-east.saic.com). All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Obviously, without all the hard work of the OpenBSD OpenSSH developers
# and the OpenSSH Portability Team, these scripts would be pointless...
# so thanks again folks!
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#### Known issues
# These methods are generally based on a "default" compilation of
# OpenSSH on Solaris--so the more things that you change from the default,
# the greater the chance that something in the script won't be able to
# handle the changes. In general, though, most things should be determined
# from your compile environment--the architecture, SSH version, and
# other related data should all get picked up by this script. The script
# and data files were last updated to match OpenSSH 2.1.1p4.
#
# All building and packaging is done under a temporary directory that is
# itself created under the contrib/solaris directory--so there shouldn't
# be any special security issues (or need for root access during the
# packaging process). The temporary directory is defined below as
# ${BUILDDIR}.
#
# The permissions on the installed files are based on how we prefer to
# do things here--so nothing is installed SetUID to root.
#
# The post-install script makes a good-faith attempt to install a
# functional configuration on your system. I would be interested in hearing
# of any failure modes that are found, as I tried to compensate for all
# the ones that showed up here when we started replacing all the
# different installed versions of SSH.
#### Body of the script (finally!)
# We expect to be building the solaris package under the contrib/solaris
# directory--but the build-package script might be run with a relative
# path by a user in the main SSH directory...so we try to handle this
# case. Note that this is still a quick and dirty solution, not robust.
if [ -f sshd.c ]; then
cd contrib/solaris >/dev/null
fi
# Locations of standard binaries
UNAME=/usr/bin/uname
SED=/usr/bin/sed
PWD=/usr/bin/pwd
CUT=/usr/bin/cut
STRIP=/usr/ccs/bin/strip
PKGMK=/usr/bin/pkgmk
PKGTRANS=/usr/bin/pkgtrans
GREP=/usr/bin/grep
DATE=/usr/bin/date
CURRDIR=`${PWD}`
BUILDDIR=${CURRDIR}/build-SSH-package
# If you really want to name the package "ssh" then go ahead, but the
# Sun convention is that the first 2-4 characters are supposed to be
# uppercase representing the company or organization that produced the
# software, and the next 3-5 characters are supposed to be lowercase
# identifying the specific software. The best package names I could
# come up with were "OBSDssh" or "OPENssh", given those constraints.
PKGNAME="OPENssh"
# PSTAMP is a standard setting in the 'pkginfo' file that helps to identify
# the time and location that the packaging was done.
PSTAMP="`${UNAME} -n`-`${DATE} +%Y-%m-%d-%H%M`"
# The several lines below are designed to pull the relevant information
# out of the Makefile. It may be simpler to hard-code this if you have
# made changes and these lines don't find them.
prefix=`${GREP} "^prefix=" ../../Makefile | ${CUT} -d = -f 2`
execprefix=`${GREP} "^execprefix=" ../../Makefile | ${CUT} -d = -f 2`
INSTROOT=${prefix:=/usr/local}
ETCDIR=`${GREP} "^ETCDIR=" ../../Makefile | ${CUT} -d = -f 2`
PIDDIR=`${GREP} "^piddir=" ../../Makefile | ${CUT} -d = -f 2`
if [ ! -f ../../sshd ]; then
echo "Unable to locate sshd binary where I expected, and can't continue."
echo "Verify that the SSH configure/make has been completed, and that"
echo " this script is being run from within the SSH source tree."
exit 1
fi
VERSION=`${GREP} "SSH_VERSION" ../../version.h | ${CUT} -f 2 | sed -e 's/"//g' -e 's/OpenSSH_//g'`
# Extra shenanigans to compensate for Sun marketeer tricks with Solaris
# version numbering...
OSMINOR=`${UNAME} -r | ${CUT} -f 2 -d .`
if [ $OSMINOR -gt 6 ]; then
OSVERSION=$OSMINOR
else
OSVERSION=`${UNAME} -r | ${SED} 's/5/2/'`
fi
ARCH=`$UNAME -p`
SHORTINSTROOT=""
if [ "$INSTROOT" = "/usr/local" ]; then
SHORTINSTROOT="-local"
else
if [ "$INSTROOT" = "/opt" ]; then
SHORTINSTROOT="-opt"
fi
fi
DESTFILE="${PKGNAME}-${VERSION}-sol${OSVERSION}-${ARCH}${SHORTINSTROOT}"
echo "Building Solaris package of OpenSSH ${VERSION} in\n\t${BUILDDIR}."
echo "Binaries were compiled for Solaris ${OSVERSION} (${ARCH})"
echo "The installable package will be named ${DESTFILE}."
echo "When installed, the package will be located under ${INSTROOT}."
echo ""
echo "Cleaning up old build files..."
rm -rf $BUILDDIR
mkdir $BUILDDIR
cd $BUILDDIR
echo "Setting up build directories..."
mkdir -p ${BUILDDIR}/man/man1
# Need manpages for sshd_config(5) and ssh_config(5), but we don't yet have.
#mkdir -p ${BUILDDIR}/man/man5
mkdir -p ${BUILDDIR}/man/man8
mkdir -p ${BUILDDIR}/etc
mkdir -p ${BUILDDIR}/bin
mkdir -p ${BUILDDIR}/libexec
mkdir -p ${BUILDDIR}/sbin
echo "Populating build directories..."
cp -p ../../../sshd sbin
cp -p ../../../ssh-keygen bin
cp -p ../../../ssh-keyscan bin
cp -p ../../../ssh bin
cp -p ../../../ssh-add bin
cp -p ../../../ssh-agent bin
cp -p ../../../scp bin
cp -p ../../../scp.1.out man/man1/scp.1
cp -p ../../../sftp bin
cp -p ../../../sftp.1.out man/man1/sftp.1
cp -p ../../../sftp-server libexec/sftp-server
cp -p ../../../sftp-server.8.out man/man8/sftp-server.8
cp -p ../../../ssh-add.1.out man/man1/ssh-add.1
cp -p ../../../ssh-agent.1.out man/man1/ssh-agent.1
cp -p ../../../ssh-keygen.1.out man/man1/ssh-keygen.1
cp -p ../../../ssh-keyscan.1.out man/man1/ssh-keyscan.1
cp -p ../../../ssh.1.out man/man1/ssh.1
cp -p ../../../sshd.8.out man/man8/sshd.8
cp -p ../../../sshd_config.out etc/sshd_config.default
cp -p ../../../ssh_config.out etc/ssh_config.default
cp -p ../../../ssh_prng_cmds etc/ssh_prng_cmds.default
cp -p ../../../primes etc/primes.default
# One of the annoying things about the Solaris packaging process is that
# there's no simple way to prototype on the fly--so make sure you edit
# the prototype file if you add/subtract files from the mix.
cp -p ../prototype .
cp -p ../preremove .
echo "Creating compile-dependent files from their prototypes"
$SED -e "s/%%PKGNAME%%/${PKGNAME}/g" -e "s|%%BASEDIR%%|${INSTROOT}|g" -e "s/%%VERSION%%/${VERSION}/g" -e "s/%%ARCH%%/${ARCH}/g" -e "s/%%OSVERSION%%/${OSVERSION}/g" <../pkginfo.in >./pkginfo
$SED -e "s/%%PKGNAME%%/${PKGNAME}/g" -e "s/%%OSMINOR%%/${OSMINOR}/g" -e "s/%%OSVERSION%%/${OSVERSION}/g" <../checkinstall.in >./checkinstall
$SED -e "s|%%PIDDIR%%|${PIDDIR}|g" <../postinstall.in >./postinstall
$SED -e "s|%%PIDDIR%%|${PIDDIR}|g" <../sshd-initscript.in > etc/sshd-initscript
echo "Stripping binaries"
${STRIP} bin/ssh
${STRIP} bin/ssh-add
${STRIP} bin/ssh-agent
${STRIP} bin/ssh-keygen
${STRIP} bin/ssh-keyscan
${STRIP} sbin/sshd
${STRIP} bin/scp
${STRIP} bin/sftp
${STRIP} libexec/sftp-server
echo ""
echo "Building Package"
cd ${BUILDDIR}
$PKGMK -o -r . -p ${PSTAMP} -d ${BUILDDIR}
if [ $? -gt 0 ]; then
echo "Error performing pkgmk--cannot continue."
exit 1
fi
echo ""
echo "Translating Package Tree into Installable Image"
$PKGTRANS -s ${BUILDDIR} ${BUILDDIR}/${DESTFILE} OPENssh
if [ $? -gt 0 ]; then
echo "Error performing pkgtrans--cannot continue."
exit 1
fi
echo "Done. Package is in ${BUILDDIR}/${DESTFILE} !"

82
contrib/solaris/buildpkg.sh Executable file
View File

@ -0,0 +1,82 @@
#!/bin/sh
#
# Fake Root Solaris Build System - Prototype
#
# The following code has been provide under Public Domain License. I really
# don't care what you use it for. Just as long as you don't complain to me
# nor my employer if you break it. - Ben Lindstrom (mouring@eviladmin.org)
#
umask 022
PKGNAME=OpenSSH
## Extract common info requires for the 'info' part of the package.
VERSION=`tail -1 ../../version.h | sed -e 's/.*_\([0-9]\)/\1/g' | sed 's/\"$//'`
ARCH=`uname -p`
## Start by faking root install
echo "Faking root install..."
START=`pwd`
FAKE_ROOT=$START/package
mkdir $FAKE_ROOT
cd ../..
make install-nokeys DESTDIR=$FAKE_ROOT
## Fill in some details, like prefix and sysconfdir
ETCDIR=`grep "^sysconfdir=" Makefile | sed 's/sysconfdir=//'`
PREFIX=`grep "^prefix=" Makefile | cut -d = -f 2`
cd $FAKE_ROOT
## Setup our run level stuff while we are at it.
mkdir -p $FAKE_ROOT/etc/init.d
mkdir -p $FAKE_ROOT/etc/rcS.d
mkdir -p $FAKE_ROOT/etc/rc0.d
mkdir -p $FAKE_ROOT/etc/rc1.d
mkdir -p $FAKE_ROOT/etc/rc2.d
## setup our initscript correctly
sed -e "s#%%configDir%%#$ETCDIR#g" \
-e "s#%%openSSHDir%%#$PREFIX#g" \
../opensshd.in > $FAKE_ROOT/etc/init.d/opensshd
chmod 711 $FAKE_ROOT/etc/init.d/opensshd
ln -s $FAKE_ROOT/etc/init.d/opensshd $FAKE_ROOT/etc/rcS.d/K30opensshd
ln -s $FAKE_ROOT/etc/init.d/opensshd $FAKE_ROOT/etc/rc1.d/K30opensshd
ln -s $FAKE_ROOT/etc/init.d/opensshd $FAKE_ROOT/etc/rc2.d/S98opensshd
## Ok, this is outright wrong, but it will work. I'm tired of pkgmk
## whining.
for i in *; do
PROTO_ARGS="$PROTO_ARGS $i=/$i";
done
## Build info file
echo "Building pkginfo file..."
cat > pkginfo << _EOF
PKG=$PKGNAME
NAME=OpenSSH Portable for Solaris
DESC="Secure Shell remote access utility; replaces telnet and rlogin/rsh."
VENDOR="OpenSSH Portable Team - http://www.openssh.com/portable.html"
BASEDIR=$FAKE_ROOT
ARCH=$ARCH
VERSION=$VERSION
CATEGORY=Security
BASEDIR=/
_EOF
## Next Build our prototype
echo "Building prototype file..."
find . | egrep -v "prototype|pkginfo" | sort | pkgproto $PROTO_ARGS | \
awk '
BEGIN { print "i pkginfo" }
{ $5="root"; $6="sys"; }
{ print; }' > prototype
## Step back a directory and now build the package.
echo "Building package.."
cd ..
pkgmk -d . -f $FAKE_ROOT/prototype -o
rm -rf $FAKE_ROOT
echo | pkgtrans -os . $PKGNAME-$ARCH-$VERSION.pkg
rm -rf $PKGNAME

View File

@ -1,37 +0,0 @@
#!/bin/sh
echo "Checking SunOS revision..."
MINOR=`/bin/uname -r | /bin/cut -d "." -f 2`
if [ ${MINOR} -lt %%OSMINOR%% ]; then
echo "This package was created on Solaris %%OSVERSION%%, and will probably"
echo " not function correctly on older versions of Solaris."
echo "** Unable to continue. **"
exit 3
fi
echo "\t...revision okay."
echo "Checking for existing SSH installation..."
if [ -f /etc/sshd_config -o -f /usr/local/etc/sshd_config ]; then
UPDATE=1
fi
if [ -f /etc/ssh_host_key -o -f /usr/local/etc/ssh_host_key ]; then
UPDATE=1
fi
if [ ${UPDATE} -eq 1 ]; then
echo "Performing an \"update\" installation of %%PKGNAME%%"
else
echo "Performing a \"fresh\" installation of %%PKGNAME%%"
fi
echo ""
# We derive these at install time in case the package is relocated.
CONFDIR="${BASEDIR}/etc"
DESTBIN="${BASEDIR}/bin"
# make parameters available to installation service, and
# so to any other packaging scripts
cat >$1 <<!
CONFDIR='$CONFDIR'
DESTBIN='$DESTBIN'
UPDATE='$UPDATE'
!

88
contrib/solaris/opensshd.in Executable file
View File

@ -0,0 +1,88 @@
#!/sbin/sh
# Donated code that was put under PD license.
#
# Stripped PRNGd out of it for the time being.
AWK=/usr/bin/awk
CAT=/usr/bin/cat
EGREP=/usr/bin/egrep
KILL=/usr/bin/kill
PS=/usr/bin/ps
PREFIX=%%openSSHDir%%
ETCDIR=%%configDir%%
SSHD=$PREFIX/sbin/sshd
SSH_KEYGEN=$PREFIX/bin/ssh-keygen
HOST_KEY_RSA1=$ETCDIR/ssh_host_key
HOST_KEY_DSA=$ETCDIR/ssh_host_dsa_key
HOST_KEY_RSA=$ETCDIR/ssh_host_rsa_key
killproc() {
_procname=$1
_signal=$2
${PGREP} ${_procname} | ${HEAD} -1 | ${XARGS} -t -I {} ${KILL} -${_signal} {}
}
checkkeys() {
if [ ! -f $HOST_KEY_RSA1 ]; then
$SSH_KEYGEN -t rsa1 -f $HOST_KEY_RSA1 -N ""
fi
if [ ! -f $HOST_KEY_DSA ]; then
$SSH_KEYGEN -t dsa -f $HOST_KEY_DSA -N ""
fi
if [ ! -f $HOST_KEY_RSA ]; then
$SSH_KEYGEN -t rsa -f $HOST_KEY_RSA -N ""
fi
}
stop_service() {
if [ -r $PIDFILE -a ! -z ${PIDFILE} ]; then
PID=`cat ${PIDFILE}`
fi
if [ ${PID:=0} -gt 1 -a ! "X$PID" = "X " ]; then
$KILL $PID
else
echo "Unable to read PID file, killing using alternate method"
killproc sshd TERM
fi
}
start_service() {
# XXX We really should check if the service is already going, but
# XXX we will opt out at this time. - Bal
# Check to see if we have keys that need to be made
checkkeys
# Start SSHD
echo "starting $SSHD... \c" ; $SSHD
sshd_rc=$?
if [ $sshd_rc -ne 0 ]; then
echo "$0: Error ${sshd_rc} starting ${SSHD}... bailing."
exit $sshd_rc
fi
echo done.
}
case $1 in
'start')
start_service
;;
'stop')
stop_service
;;
'restart')
stop_service
start_service
;;
*)
echo "$0: usage: $0 {start|stop|restart}"
;;
esac

View File

@ -1,17 +0,0 @@
CLASSES=none
BASEDIR="%%BASEDIR%%"
PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin
OAMBASE=/usr/sadm/sysadm
PKG=%%PKGNAME%%
NAME="OpenSSH %%VERSION%% %%ARCH%%"
DESC="Secure Shell remote access utility; replaces telnet and rlogin/rsh. OpenBSD version ported to Solaris. Compiled on Solaris %%OSVERSION%%"
ARCH="%%ARCH%%"
VERSION="%%VERSION%%"
CATEGORY=utility,application
VENDOR="Software produced by OpenSSH Portability Team, http://www.openssh.com/portable.html"
EMAIL="OpenSSH Development List <openssh-unix-dev@mindrot.org>"
PKGINST=%%PKGNAME%%
PKGSAV=/var/sadm/pkg/%%PKGNAME%%/save
ISTATES="S s 1 2 3"
RSTATES="S s 1 2 3"
UPDATE=0

View File

@ -1,243 +0,0 @@
# PostInstall script for OPENssh
INSTALLF="/usr/sbin/installf"
instbackup() {
_DIRECTORY=$1
_FILEBASE=$2
$INSTALLF $PKGINST ${_DIRECTORY}/${_FILEBASE}
_SUFFIX=`/usr/bin/date +%Y-%m-%d-%H%M`
if [ -f ${_DIRECTORY}/${_FILEBASE} ]; then
echo " Backing up file ${_FILEBASE}..."
if [ -f ${_DIRECTORY}/${_FILEBASE}.orig ]; then
$INSTALLF $PKGINST ${_DIRECTORY}/${_FILEBASE}.orig.${_SUFFIX}
cp -p ${_DIRECTORY}/${_FILEBASE} ${_DIRECTORY}/${_FILEBASE}.orig.${_SUFFIX}
echo " Saved as ${_DIRECTORY}/${_FILEBASE}.orig.${_SUFFIX}."
else
$INSTALLF $PKGINST ${_DIRECTORY}/${_FILEBASE}.orig
cp -p ${_DIRECTORY}/${_FILEBASE} ${_DIRECTORY}/${_FILEBASE}.orig
echo " Saved as ${_DIRECTORY}/${_FILEBASE}.orig."
fi
fi
cp -p ${_DIRECTORY}/${_FILEBASE}.default ${_DIRECTORY}/${_FILEBASE}
echo "Installed new ${_DIRECTORY}/${_FILEBASE} configuration file."
}
### Main body of script
echo ""
echo "Beginning postinstall script--this script should leave you with a"
echo "functional and operational configuration of OpenSSH."
echo ""
if [ ! "${UPDATE}" = "1" ]; then
echo "Performing a \"fresh\" installation of OpenSSH."
### Install init script and create symlinks
$INSTALLF $PKGINST ${PKG_INSTALL_ROOT}/etc/init.d/sshd f 0500 root sys || exit 2
cp -p ${CONFDIR}/sshd-initscript ${PKG_INSTALL_ROOT}/etc/init.d/sshd
$INSTALLF $PKGINST ${PKG_INSTALL_ROOT}/etc/rc2.d/S72local_sshd=/etc/init.d/sshd s || exit 2
$INSTALLF $PKGINST ${PKG_INSTALL_ROOT}/etc/rc1.d/K30local_sshd=/etc/init.d/sshd s || exit 2
$INSTALLF $PKGINST ${PKG_INSTALL_ROOT}/etc/rc0.d/K30local_sshd=/etc/init.d/sshd s || exit 2
### The initial package installation leaves default versions of
### ssh_prng_cmds, ssh_config, and sshd_config in ${CONFDIR}. Now
### we need to decide whether to install them. Since this is *not*
### an update install, we don't ask, but simply back up the old ones
### and put the new ones in their place.
instbackup ${CONFDIR} ssh_prng_cmds
instbackup ${CONFDIR} ssh_config
instbackup ${CONFDIR} sshd_config
instbackup ${CONFDIR} primes
### If no existing sshd_config and host key, then create
if [ ! -f "${CONFDIR}/ssh_host_key" ]; then
echo "Creating new RSA public/private host key pair for SSH-1."
$INSTALLF $PKGINST ${CONFDIR}/ssh_host_key
$INSTALLF $PKGINST ${CONFDIR}/ssh_host_key.pub
### If there is *anything* there then leave it, otherwise look
### in some reasonable alternate locations before giving up.
### It's worth spending some extra time looking for the old one
### to avoid a bunch of "host identification has changed" warnings.
### Note that some old keys from the commercial SSH might not
### be compatible, but we don't test for that.
if [ -f "${PKG_INSTALL_ROOT}/etc/ssh_host_key" ]; then
mv ${PKG_INSTALL_ROOT}/etc/ssh_host_key ${CONFDIR}
elif [ -f "${PKG_INSTALL_ROOT}/usr/local/etc/ssh_host_key" ]; then
mv ${PKG_INSTALL_ROOT}/usr/local/etc/ssh_host_key ${CONFDIR}
else
${DESTBIN}/ssh-keygen -b 1024 -f ${CONFDIR}/ssh_host_key -N ''
fi
else
echo "Using existing RSA public/private host key pair for SSH-1."
fi
if [ ! -f "${CONFDIR}/ssh_host_dsa_key" ]; then
echo "Creating new DSA public/private host key pair for SSH-2."
$INSTALLF $PKGINST ${CONFDIR}/ssh_host_dsa_key
$INSTALLF $PKGINST ${CONFDIR}/ssh_host_dsa_key.pub
### If there is *anything* there then leave it, otherwise look
### in some reasonable alternate locations before giving up.
### It's worth spending some extra time looking for the old one
### to avoid a bunch of "host identification has changed" warnings.
### Note that some old keys from the commercial SSH2 might not
### be compatible, but we don't test for that.
if [ -f "${PKG_INSTALL_ROOT}/etc/ssh_host_dsa_key" ]; then
mv ${PKG_INSTALL_ROOT}/etc/ssh_host_dsa_key ${CONFDIR}
elif [ -f "${PKG_INSTALL_ROOT}/usr/local/etc/ssh_host_dsa_key" ]; then
mv ${PKG_INSTALL_ROOT}/usr/local/etc/ssh_host_dsa_key ${CONFDIR}
else
${DESTBIN}/ssh-keygen -d -f ${CONFDIR}/ssh_host_dsa_key -N ''
fi
else
echo "Using existing DSA public/private host key pair for SSH-2."
fi
if [ ! -f "${CONFDIR}/ssh_host_rsa_key" ]; then
echo "Creating new RSA public/private host key pair for SSH-2."
$INSTALLF $PKGINST ${CONFDIR}/ssh_host_rsa_key
$INSTALLF $PKGINST ${CONFDIR}/ssh_host_rsa_key.pub
### If there is *anything* there then leave it, otherwise look
### in some reasonable alternate locations before giving up.
### It's worth spending some extra time looking for the old one
### to avoid a bunch of "host identification has changed" warnings.
### Note that some old keys from the commercial SSH2 might not
### be compatible, but we don't test for that.
if [ -f "${PKG_INSTALL_ROOT}/etc/ssh_host_rsa_key" ]; then
mv ${PKG_INSTALL_ROOT}/etc/ssh_host_rsa_key ${CONFDIR}
elif [ -f "${PKG_INSTALL_ROOT}/usr/local/etc/ssh_host_rsa_key" ]; then
mv ${PKG_INSTALL_ROOT}/usr/local/etc/ssh_host_rsa_key ${CONFDIR}
else
${DESTBIN}/ssh-keygen -t rsa -f ${CONFDIR}/ssh_host_rsa_key -N ''
fi
else
echo "Using existing RSA public/private host key pair for SSH-2."
fi
else
echo "Performing an \"update\" installation of OpenSSH."
### Okay, this part *is* an update install...so we need to ensure
### we don't overwrite any of the existing files.
### Install init script and create symlinks
if [ ! -f ${PKG_INSTALL_ROOT}/etc/init.d/sshd ]; then
echo "Installing init script in ${PKG_INSTALL_ROOT}/etc/init.d/sshd"
$INSTALLF $PKGINST ${PKG_INSTALL_ROOT}/etc/init.d/sshd || exit 2
cp -p ${CONFDIR}/sshd-initscript ${PKG_INSTALL_ROOT}/etc/init.d/sshd
chown root:root ${PKG_INSTALL_ROOT}/etc/init.d/sshd
chmod 500 ${PKG_INSTALL_ROOT}/etc/init.d/sshd
fi
if [ ! -r ${PKG_INSTALL_ROOT}/etc/rc2.d/S72local_sshd ]; then
$INSTALLF $PKGINST ${PKG_INSTALL_ROOT}/etc/rc2.d/S72local_sshd=/etc/init.d/sshd s || exit 2
fi
if [ ! -r ${PKG_INSTALL_ROOT}/etc/rc2.d/K30local_sshd ]; then
$INSTALLF $PKGINST /etc/rc0.d/K30local_sshd=/etc/init.d/sshd s || exit 2
fi
### The initial package installation leaves default versions of
### ssh_prng_cmds, ssh_config, and sshd_config in ${CONFDIR}. Now
### we need to decide whether to install them. Since this is
### an update install, we only install the new files if the old
### files somehow don't exist.
NEWCONF=0
if [ ! -r "${CONFDIR}/ssh_prng_cmds" ]; then
instbackup ${CONFDIR} ssh_prng_cmds
NEWCONF=1
fi
if [ ! -r "${CONFDIR}/ssh_config" ]; then
instbackup ${CONFDIR} ssh_config
NEWCONF=1
fi
if [ ! -r "${CONFDIR}/sshd_config" ]; then
instbackup ${CONFDIR} sshd_config
NEWCONF=1
fi
if [ ! -r "${CONFDIR}/primes" ]; then
instbackup ${CONFDIR} primes
NEWCONF=1
fi
if [ $NEWCONF -eq 0 ]; then
echo "Your existing SSH configuration files have not been altered."
else
echo "Your other existing SSH configuration files have not been altered."
fi
### If no existing sshd_config and host key, then create
if [ ! -f "${CONFDIR}/ssh_host_key" ]; then
echo "Creating new RSA public/private host key pair for SSH-1."
$INSTALLF $PKGINST ${CONFDIR}/ssh_host_key
$INSTALLF $PKGINST ${CONFDIR}/ssh_host_key.pub
### If there is *anything* there then leave it, otherwise look
### in some reasonable alternate locations before giving up.
### It's worth spending some extra time looking for the old one
### to avoid a bunch of "host identification has changed" warnings.
### Note that some old keys from the commercial SSH might not
### be compatible, but we don't test for that.
if [ -f "${PKG_INSTALL_ROOT}/etc/ssh_host_key" ]; then
mv ${PKG_INSTALL_ROOT}/etc/ssh_host_key ${CONFDIR}
elif [ -f "${PKG_INSTALL_ROOT}/usr/local/etc/ssh_host_key" ]; then
mv ${PKG_INSTALL_ROOT}/usr/local/etc/ssh_host_key ${CONFDIR}
else
${DESTBIN}/ssh-keygen -b 1024 -f ${CONFDIR}/ssh_host_key -N ''
fi
else
echo "Using existing RSA public/private host key pair for SSH-1."
fi
if [ ! -f "${CONFDIR}/ssh_host_dsa_key" ]; then
echo "Creating new DSA public/private host key pair for SSH-2."
$INSTALLF $PKGINST ${CONFDIR}/ssh_host_dsa_key
$INSTALLF $PKGINST ${CONFDIR}/ssh_host_dsa_key.pub
### If there is *anything* there then leave it, otherwise look
### in some reasonable alternate locations before giving up.
### It's worth spending some extra time looking for the old one
### to avoid a bunch of "host identification has changed" warnings.
### Note that some old keys from the commercial SSH2 might not
### be compatible, but we don't test for that.
if [ -f "${PKG_INSTALL_ROOT}/etc/ssh_host_dsa_key" ]; then
mv ${PKG_INSTALL_ROOT}/etc/ssh_host_dsa_key ${CONFDIR}
elif [ -f "${PKG_INSTALL_ROOT}/usr/local/etc/ssh_host_dsa_key" ]; then
mv ${PKG_INSTALL_ROOT}/usr/local/etc/ssh_host_dsa_key ${CONFDIR}
else
${DESTBIN}/ssh-keygen -d -f ${CONFDIR}/ssh_host_dsa_key -N ''
fi
else
echo "Using existing DSA public/private host key pair for SSH-2."
fi
if [ ! -f "${CONFDIR}/ssh_host_rsa_key" ]; then
echo "Creating new RSA public/private host key pair for SSH-2."
$INSTALLF $PKGINST ${CONFDIR}/ssh_host_rsa_key
$INSTALLF $PKGINST ${CONFDIR}/ssh_host_rsa_key.pub
### If there is *anything* there then leave it, otherwise look
### in some reasonable alternate locations before giving up.
### It's worth spending some extra time looking for the old one
### to avoid a bunch of "host identification has changed" warnings.
### Note that some old keys from the commercial SSH2 might not
### be compatible, but we don't test for that.
if [ -f "${PKG_INSTALL_ROOT}/etc/ssh_host_rsa_key" ]; then
mv ${PKG_INSTALL_ROOT}/etc/ssh_host_rsa_key ${CONFDIR}
elif [ -f "${PKG_INSTALL_ROOT}/usr/local/etc/ssh_host_rsa_key" ]; then
mv ${PKG_INSTALL_ROOT}/usr/local/etc/ssh_host_rsa_key ${CONFDIR}
else
${DESTBIN}/ssh-keygen -d -f ${CONFDIR}/ssh_host_rsa_key -N ''
fi
else
echo "Using existing RSA public/private host key pair for SSH-2."
fi
fi
if [ ! -d %%PIDDIR%% ]; then
$INSTALLF $PKGINST %%PIDDIR%%
mkdir -p %%PIDDIR%%
chown root:sys %%PIDDIR%%
chmod 755 %%PIDDIR%%
fi
$INSTALLF -f $PKGINST || exit 2
if [ "X${PKG_INSTALL_ROOT}" = "X" ]; then
### We're doing a local install, rather than an install for
### old-style diskless clients.
echo "Stopping any current sshd process, and then starting the new sshd."
/etc/init.d/sshd stop
/etc/init.d/sshd start
else
echo "Not restarting sshd, since this appears to be a remote install"
echo "for support of diskless clients."
fi
exit 0

View File

@ -1,2 +0,0 @@
# pre-removal script for OPENssh
/etc/init.d/sshd stop

View File

@ -1,36 +0,0 @@
i pkginfo
i checkinstall
i postinstall
i preremove
d none man 0755 root sys
d none man/man1 0755 root sys
f none man/man1/scp.1 0644 root sys
f none man/man1/sftp.1 0644 root sys
f none man/man1/ssh-add.1 0644 root sys
f none man/man1/ssh-agent.1 0644 root sys
f none man/man1/ssh-keygen.1 0644 root sys
f none man/man1/ssh-keyscan.1 0644 root sys
f none man/man1/ssh.1 0644 root sys
s none man/man1/slogin.1=ssh.1
d none man/man8 0755 root sys
f none man/man8/sftp-server.8 0644 root sys
f none man/man8/sshd.8 0644 root sys
d none etc 0755 root sys
f none etc/sshd_config.default 0644 root sys
f none etc/ssh_config.default 0644 root sys
f none etc/ssh_prng_cmds.default 0644 root sys
f none etc/primes.default 0644 root sys
f none etc/sshd-initscript 0755 root sys
d none bin 0755 root sys
f none bin/ssh-keygen 0755 root sys
f none bin/ssh 0755 root sys
s none bin/slogin=ssh 0755 root sys
f none bin/ssh-add 0755 root sys
f none bin/ssh-agent 0755 root sys
f none bin/ssh-keyscan 0755 root sys
f none bin/scp 0755 root sys
f none bin/sftp 0755 root sys
d none libexec 0755 root sys
f none libexec/sftp-server 0755 root sys
d none sbin 0755 root sys
f none sbin/sshd 0755 root sys

View File

@ -1,50 +0,0 @@
#! /sbin/sh
# SSHd startup/shutdown script, based on uucp script.
PIDFILE="%%PIDDIR%%/sshd.pid"
PGREP="/usr/bin/pgrep"
HEAD="/usr/bin/head"
XARGS="/usr/bin/xargs"
KILL="/usr/bin/kill"
killproc() {
_procname=$1
_signal=$2
${PGREP} ${_procname} | ${HEAD} -1 | ${XARGS} -t -I {} ${KILL} -${_signal} {}
}
case $1 in
'start')
/usr/local/sbin/sshd
;;
'stop')
if [ -r $PIDFILE -a ! -z ${PIDFILE} ]; then
PID=`cat ${PIDFILE}`
fi
if [ ${PID:=0} -gt 1 -a ! "X$PID" = "X " ]; then
/usr/bin/kill $PID
else
echo "Unable to read PID file, killing using alternate method"
killproc sshd TERM
fi
;;
'restart')
if [ -r $PIDFILE -a ! -z ${PIDFILE} ]; then
PID=`cat ${PIDFILE}`
fi
if [ ${PID:=0} -gt 1 -a ! "X$PID" = "X " ]; then
/usr/bin/kill -HUP $PID
else
echo "Unable to read PID file, trying alternate method"
killproc sshd HUP
/usr/local/sbin/sshd
fi
;;
*)
echo "usage: /etc/init.d/sshd {start|stop|restart}"
;;
esac