2006-11-27 14:05:54 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# cyglsa-config, Copyright 2006 Red Hat Inc.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# A copy of the GNU General Public License can be found at
|
|
|
|
# http://www.gnu.org/
|
|
|
|
#
|
|
|
|
# This file is part of the Cygwin LSA authentication package.
|
|
|
|
|
|
|
|
request()
|
|
|
|
{
|
|
|
|
if [ "${auto_answer}" = "yes" ]
|
|
|
|
then
|
|
|
|
echo "$1 (yes/no) yes"
|
|
|
|
return 0
|
|
|
|
elif [ "${auto_answer}" = "no" ]
|
|
|
|
then
|
|
|
|
echo "$1 (yes/no) no"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
answer=""
|
|
|
|
while [ "X${answer}" != "Xyes" -a "X${answer}" != "Xno" ]
|
|
|
|
do
|
|
|
|
echo -n "$1 (yes/no) "
|
|
|
|
read -e answer
|
|
|
|
done
|
|
|
|
if [ "X${answer}" = "Xyes" ]
|
|
|
|
then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-07-16 21:33:54 +02:00
|
|
|
# Check if running under at least Windows 2000
|
2006-11-27 14:05:54 +01:00
|
|
|
_nt_too_old=`uname | awk -F- '{print ( $2 < 5.0 ) ? 1 : 0;}'`
|
|
|
|
if [ ${_nt_too_old} -eq 1 ]
|
|
|
|
then
|
|
|
|
echo "Cygwin LSA authentication not supported on Windows NT4 or older. Exiting."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Directory in which cyglsa DLL is installed as DOS path.
|
|
|
|
bindir=`cygpath -w /`\\bin
|
|
|
|
|
|
|
|
# Check if we're running on 64 bit Windows. If so, we need the 64 bit
|
|
|
|
# cyglsa DLL.
|
|
|
|
dll=cyglsa.dll
|
|
|
|
test -d `cygpath -p ${SYSTEMROOT}`/SysWOW64 && dll=cyglsa64.dll
|
|
|
|
|
|
|
|
# Check if the DLL is actually installed. If not, bail out.
|
|
|
|
if [ ! -f /bin/${dll} ]
|
|
|
|
then
|
|
|
|
echo "Required Cygwin authentication DLL /bin/${dll} doesn't exist. Exiting."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Warning: Registering the Cygwin LSA authentication package requires"
|
|
|
|
echo "administrator privileges! You also have to reboot the machine to"
|
|
|
|
echo "activate the change."
|
|
|
|
echo
|
|
|
|
request "Are you sure you want to continue?" || exit 0
|
|
|
|
|
|
|
|
# The registry value which keeps the authentication packages.
|
|
|
|
value='/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Lsa/Authentication Packages'
|
|
|
|
|
2008-07-16 21:33:54 +02:00
|
|
|
[ -f /bin/cyglsa -a ! -d /bin/cyglsa ] && rm -rf /bin/cyglsa
|
|
|
|
if [ ! -d /bin/cyglsa ]
|
|
|
|
then
|
|
|
|
if ! mkdir -m 755 /bin/cyglsa
|
|
|
|
then
|
|
|
|
echo "Creating the /bin/cyglsa directory failed. Exiting."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2008-08-13 13:05:25 +02:00
|
|
|
if ! cp -b "/bin/${dll}" "/bin/cyglsa/${dll}"
|
2008-07-16 21:33:54 +02:00
|
|
|
then
|
|
|
|
echo "Copying the new LSA authentication package /bin/${dll} to"
|
|
|
|
echo "/bin/cyglsa/${dll} failed. Exiting."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Get old content, remove every trace of "cyglsa" from it and write the
|
2006-11-27 14:05:54 +01:00
|
|
|
# content back to the registry with the new, correct path to the cyglsa DLL.
|
|
|
|
old=`regtool get "${value}"`
|
|
|
|
new=`for i in ${old}
|
|
|
|
do
|
|
|
|
echo $i | grep -v cyglsa
|
|
|
|
done`
|
2008-07-16 21:33:54 +02:00
|
|
|
if ! regtool set "${value}" ${new} "${bindir}\\cyglsa\\${dll}"
|
2006-11-27 14:05:54 +01:00
|
|
|
then
|
2008-07-16 21:33:54 +02:00
|
|
|
echo "Setting the new registry value failed. Exiting."
|
2006-11-27 14:05:54 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Cygwin LSA authentication package registered."
|
|
|
|
echo
|
2008-07-16 21:33:54 +02:00
|
|
|
echo "Activating Cygwin's LSA authentication package requires to reboot."
|
2006-11-27 14:05:54 +01:00
|
|
|
if [ -x /bin/shutdown ]
|
|
|
|
then
|
|
|
|
if request "Do you want to do this immediately?"
|
|
|
|
then
|
|
|
|
echo
|
|
|
|
echo "Other users might still be working on this machine."
|
|
|
|
echo
|
|
|
|
if request "Are you sure?"
|
|
|
|
then
|
|
|
|
echo
|
|
|
|
echo "Ok, will reboot in 30 seconds."
|
|
|
|
echo
|
|
|
|
echo "If you change your mind, call 'shutdown -a' within 30 seconds"
|
|
|
|
shutdown -r 30
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|