summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2001-03-07 21:38:19 +1100
committerDamien Miller <djm@mindrot.org>2001-03-07 21:38:19 +1100
commit8ac0a7ec448764036e1a1657013a9fd9179be860 (patch)
tree4db958c3fa4b9982b37a362d9e65b5dd94ed5b5b
parentb29e34d1e491ac07ed294c51462e3611951a8379 (diff)
- Cygwin contrib improvements from Corinna Vinschen <vinschen@redhat.com>
-rw-r--r--ChangeLog3
-rw-r--r--contrib/cygwin/README9
-rw-r--r--contrib/cygwin/ssh-host-config89
3 files changed, 82 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 9dad0832..38d6be3d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,7 @@
- deraadt@cvs.openbsd.org 2001/03/07 04:05:58
[ssh.1]
removed dated comment
+ - Cygwin contrib improvements from Corinna Vinschen <vinschen@redhat.com>
20010306
- (bal) OpenBSD CVS Sync
@@ -4429,4 +4430,4 @@
- Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1
-$Id: ChangeLog,v 1.923 2001/03/07 06:08:50 mouring Exp $
+$Id: ChangeLog,v 1.924 2001/03/07 10:38:19 djm Exp $
diff --git a/contrib/cygwin/README b/contrib/cygwin/README
index ac095583..dd237f2c 100644
--- a/contrib/cygwin/README
+++ b/contrib/cygwin/README
@@ -15,12 +15,8 @@ filesystem (which is recommended) due to the lack of any basic security
features of the FAT/FAT32 filesystems.
===========================================================================
-Since this package is part of the base distribution now, the location
-of the files has changed from /usr/local to /usr. The global configuration
-files are in /etc now.
-
-If you are installing OpenSSH the first time, you can generate
-global config files and server keys by running
+If you are installing OpenSSH the first time, you can generate global config
+files and server keys by running
/usr/bin/ssh-host-config
@@ -39,6 +35,7 @@ Options:
--debug -d Enable shell's debug output.
--yes -y Answer all questions with "yes" automatically.
--no -n Answer all questions with "no" automatically.
+ --port -p <n> sshd listens on port n.
You can create the private and public keys for a user now by running
diff --git a/contrib/cygwin/ssh-host-config b/contrib/cygwin/ssh-host-config
index 6fe2c779..70bbafdb 100644
--- a/contrib/cygwin/ssh-host-config
+++ b/contrib/cygwin/ssh-host-config
@@ -16,6 +16,7 @@ OLDSYSCONFDIR=${OLDPREFIX}/etc
progname=$0
auto_answer=""
+port_number=22
request()
{
@@ -67,6 +68,11 @@ do
auto_answer=no
;;
+ -p | --port )
+ port_number=$1
+ shift
+ ;;
+
*)
echo "usage: ${progname} [OPTION]..."
echo
@@ -76,6 +82,7 @@ do
echo " --debug -d Enable shell's debug output."
echo " --yes -y Answer all questions with \"yes\" automatically."
echo " --no -n Answer all questions with \"no\" automatically."
+ echo " --port -p <n> sshd listens on port n."
echo
exit 1
;;
@@ -254,6 +261,11 @@ Host *
IdentityFile ~/.ssh/id_rsa
IdentityFile ~/.ssh/id_dsa
EOF
+ if [ "$port_number" != "22" ]
+ then
+ echo "Host localhost" >> ${SYSCONFDIR}/ssh_config
+ echo " Port $port_number" >> ${SYSCONFDIR}/ssh_config
+ fi
fi
# Check if sshd_config exists. If yes, ask for overwriting
@@ -278,7 +290,7 @@ then
cat > ${SYSCONFDIR}/sshd_config << EOF
# This is ssh server systemwide configuration file.
-Port 22
+Port $port_number
#
Protocol 2,1
ListenAddress 0.0.0.0
@@ -330,7 +342,7 @@ UseLogin no
EOF
fi
-# Add port 22/tcp to services
+# Care for services file
_sys="`uname -a`"
_nt=`expr "$_sys" : "CYGWIN_NT"`
if [ $_nt -gt 0 ]
@@ -344,33 +356,86 @@ fi
_services=`cygpath -u "${_wservices}"`
_serv_tmp=`cygpath -u "${_wserv_tmp}"`
-mount -b -f "${_wservices}" "${_services}"
-mount -b -f "${_wserv_tmp}" "${_serv_tmp}"
+mount -t -f "${_wservices}" "${_services}"
+mount -t -f "${_wserv_tmp}" "${_serv_tmp}"
+
+# Remove sshd 22/port from services
+if [ `grep -q 'sshd[ \t][ \t]*22' "${_services}"; echo $?` -eq 0 ]
+then
+ grep -v 'sshd[ \t][ \t]*22' "${_services}" > "${_serv_tmp}"
+ if [ -f "${_serv_tmp}" ]
+ then
+ if mv "${_serv_tmp}" "${_services}"
+ then
+ echo "Removing sshd from ${_services}"
+ else
+ echo "Removing sshd from ${_services} failed\!"
+ fi
+ rm -f "${_serv_tmp}"
+ else
+ echo "Removing sshd from ${_services} failed\!"
+ fi
+fi
-if [ `grep -q 'sshd[ \t][ \t]*22' "${_services}"; echo $?` -ne 0 ]
+# Add ssh 22/tcp and ssh 22/udp to services
+if [ `grep -q 'ssh[ \t][ \t]*22' "${_services}"; echo $?` -ne 0 ]
then
- awk '{ if ( $2 ~ /^23\/tcp/ ) print "sshd 22/tcp #SSH daemon\r"; print $0; }' < "${_services}" > "${_serv_tmp}"
+ awk '{ if ( $2 ~ /^23\/tcp/ ) print "ssh 22/tcp #SSH Remote Login Protocol\nssh 22/udp #SSH Remote Login Protocol"; print $0; }' < "${_services}" > "${_serv_tmp}"
if [ -f "${_serv_tmp}" ]
then
if mv "${_serv_tmp}" "${_services}"
then
- echo "Added sshd to ${_services}"
+ echo "Added ssh to ${_services}"
else
- echo "Adding sshd to ${_services} failed\!"
+ echo "Adding ssh to ${_services} failed\!"
fi
rm -f "${_serv_tmp}"
else
- echo "Adding sshd to ${_services} failed\!"
+ echo "Adding ssh to ${_services} failed\!"
fi
fi
umount "${_services}"
umount "${_serv_tmp}"
-# Add sshd line to inetd.conf
-if [ -f /etc/inetd.conf ]
+# Care for inetd.conf file
+_inetcnf="/etc/inetd.conf"
+_inetcnf_tmp="/etc/inetd.conf.$$"
+
+if [ -f "${_inetcnf}" ]
then
- grep -q "^[# \t]*sshd" /etc/inetd.conf || echo "# sshd stream tcp nowait root /usr/sbin/sshd -i" >> /etc/inetd.conf
+ # Check if ssh service is already in use as sshd
+ with_comment=1
+ grep -q '^[ \t]*sshd' "${_inetcnf}" && with_comment=0
+ # Remove sshd line from inetd.conf
+ if [ `grep -q '^[# \t]*sshd' "${_inetcnf}"; echo $?` -eq 0 ]
+ then
+ grep -v '^[# \t]*sshd' "${_inetcnf}" >> "${_inetcnf_tmp}"
+ if [ -f "${_inetcnf_tmp}" ]
+ then
+ if mv "${_inetcnf_tmp}" "${_inetcnf}"
+ then
+ echo "Removed sshd from ${_inetcnf}"
+ else
+ echo "Removing sshd from ${_inetcnf} failed\!"
+ fi
+ rm -f "${_inetcnf_tmp}"
+ else
+ echo "Removing sshd from ${_inetcnf} failed\!"
+ fi
+ fi
+
+ # Add ssh line to inetd.conf
+ if [ `grep -q '^[# \t]*ssh' "${_inetcnf}"; echo $?` -ne 0 ]
+ then
+ if [ "${with_comment}" -eq 0 ]
+ then
+ echo 'ssh stream tcp nowait root /usr/sbin/sshd -i' >> "${_inetcnf}"
+ else
+ echo '# ssh stream tcp nowait root /usr/sbin/sshd -i' >> "${_inetcnf}"
+ fi
+ echo "Added ssh to ${_inetcnf}"
+ fi
fi
if [ "${old_install}" = "1" ]