Corinna Vinschen
2003-Oct-30 10:20 UTC
[PATCH] contrib/cygwin/ssh-host-config: Fix a CRLF/LF issue
Hi, could somebody apply the below patch to contrib/cygwin/ssh-host-config? The patch solves a problem with the way, the Windows pendant of the /etc/services file is used. This file has (obviously) CRLF line endings. The ssh-host-config file tries to accomodate that when adding the ssh service entries but I never reviewed this functionality in the light of some major changes in the Cygwin DLL. The result is, that on recent Cygwin releases (with "recent" probably around a year or so), the script fails under specific conditions to create CRLF line endings, just adding these entries with LFs. Funny enough, the related Winsock functions getservbyname and getservbyport have no problems to read these entries on all versions of Windows... except on the good old Windows 95, which tends to SEGV when trying to read these entries. Oh boy... Anyway, the below patch to ssh-host-config accomplishes CRLFs again under all conditions. Thanks in advance, Corinna Index: contrib/cygwin/ssh-host-config ==================================================================RCS file: /cvs/openssh_cvs/contrib/cygwin/ssh-host-config,v retrieving revision 1.11 diff -p -u -r1.11 ssh-host-config --- contrib/cygwin/ssh-host-config 22 Sep 2003 02:32:01 -0000 1.11 +++ contrib/cygwin/ssh-host-config 30 Oct 2003 10:18:22 -0000 @@ -468,19 +468,21 @@ then fi # Care for services file +_my_etcdir="/ssh-host-config.$$" if [ $_nt -gt 0 ] then - _wservices="${SYSTEMROOT}\\system32\\drivers\\etc\\services" - _wserv_tmp="${SYSTEMROOT}\\system32\\drivers\\etc\\srv.out.$$" + _win_etcdir="${SYSTEMROOT}\\system32\\drivers\\etc" + _services="${_my_etcdir}/services" else - _wservices="${WINDIR}\\SERVICES" - _wserv_tmp="${WINDIR}\\SERV.$$" + _win_etcdir="${WINDIR}" + _services="${_my_etcdir}/SERVICES" fi -_services=`cygpath -u "${_wservices}"` -_serv_tmp=`cygpath -u "${_wserv_tmp}"` +_serv_tmp="${_my_etcdir}/srv.out.$$" -mount -t -f "${_wservices}" "${_services}" -mount -t -f "${_wserv_tmp}" "${_serv_tmp}" +mount -t -f "${_win_etcdir}" "${_my_etcdir}" + +# Depends on the above mount +_wservices=`cygpath -w "${_services}"` # Remove sshd 22/port from services if [ `grep -q 'sshd[ \t][ \t]*22' "${_services}"; echo $?` -eq 0 ] @@ -490,13 +492,13 @@ then then if mv "${_serv_tmp}" "${_services}" then - echo "Removing sshd from ${_services}" + echo "Removing sshd from ${_wservices}" else - echo "Removing sshd from ${_services} failed\!" + echo "Removing sshd from ${_wservices} failed\!" fi rm -f "${_serv_tmp}" else - echo "Removing sshd from ${_services} failed\!" + echo "Removing sshd from ${_wservices} failed\!" fi fi @@ -508,18 +510,17 @@ then then if mv "${_serv_tmp}" "${_services}" then - echo "Added ssh to ${_services}" + echo "Added ssh to ${_wservices}" else - echo "Adding ssh to ${_services} failed\!" + echo "Adding ssh to ${_wservices} failed\!" fi rm -f "${_serv_tmp}" else - echo "Adding ssh to ${_services} failed\!" + echo "Adding ssh to ${_wservices} failed\!" fi fi -umount "${_services}" -umount "${_serv_tmp}" +umount "${_my_etcdir}" # Care for inetd.conf file _inetcnf="${SYSCONFDIR}/inetd.conf" -- Corinna Vinschen Cygwin Developer Red Hat, Inc.