]> sourceware.org Git - newlib-cygwin.git/blob - winsup/lsaauth/cyglsa-config
0e911c27820f2c6c348dd80adc6a9d400dad8268
[newlib-cygwin.git] / winsup / lsaauth / cyglsa-config
1 #!/bin/bash
2 #
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # A copy of the GNU General Public License can be found at
9 # http://www.gnu.org/
10 #
11 # This file is part of the Cygwin LSA authentication package.
12
13 request()
14 {
15 if [ "${auto_answer}" = "yes" ]
16 then
17 echo "$1 (yes/no) yes"
18 return 0
19 elif [ "${auto_answer}" = "no" ]
20 then
21 echo "$1 (yes/no) no"
22 return 1
23 fi
24
25 answer=""
26 while [ "X${answer}" != "Xyes" -a "X${answer}" != "Xno" ]
27 do
28 echo -n "$1 (yes/no) "
29 read -e answer
30 done
31 if [ "X${answer}" = "Xyes" ]
32 then
33 return 0
34 else
35 return 1
36 fi
37 }
38
39 # Check if running under at least Windows 2000
40 _nt_too_old=`uname | awk -F- '{print ( $2 < 5.0 ) ? 1 : 0;}'`
41 if [ ${_nt_too_old} -eq 1 ]
42 then
43 echo "Cygwin LSA authentication not supported on Windows NT4 or older. Exiting."
44 exit 1
45 fi
46
47 # Directory in which cyglsa DLL is installed as DOS path.
48 bindir=`cygpath -w /`\\bin
49
50 # Check if we're running on 64 bit Windows. If so, we need the 64 bit
51 # cyglsa DLL.
52 dll=cyglsa.dll
53 test -d `cygpath -p ${SYSTEMROOT}`/SysWOW64 && dll=cyglsa64.dll
54
55 # Check if the DLL is actually installed. If not, bail out.
56 if [ ! -f /bin/${dll} ]
57 then
58 echo "Required Cygwin authentication DLL /bin/${dll} doesn't exist. Exiting."
59 exit 1
60 fi
61
62 echo
63 echo "Warning: Registering the Cygwin LSA authentication package requires"
64 echo "administrator privileges! You also have to reboot the machine to"
65 echo "activate the change."
66 echo
67 request "Are you sure you want to continue?" || exit 0
68
69 # The registry value which keeps the authentication packages.
70 value='/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Lsa/Authentication Packages'
71
72 [ -f /bin/cyglsa -a ! -d /bin/cyglsa ] && rm -rf /bin/cyglsa
73 if [ ! -d /bin/cyglsa ]
74 then
75 if ! mkdir -m 755 /bin/cyglsa
76 then
77 echo "Creating the /bin/cyglsa directory failed. Exiting."
78 exit 1
79 fi
80 fi
81 if ! cp -b "/bin/${dll}" "/bin/cyglsa/${dll}"
82 then
83 echo "Copying the new LSA authentication package /bin/${dll} to"
84 echo "/bin/cyglsa/${dll} failed. Exiting."
85 exit 1
86 fi
87
88 # Get old content, remove every trace of "cyglsa" from it and write the
89 # content back to the registry with the new, correct path to the cyglsa DLL.
90 old=`regtool get "${value}"`
91 new=`for i in ${old}
92 do
93 echo $i | GREP_OPTIONS="" grep -v cyglsa
94 done`
95 if ! regtool set "${value}" ${new} "${bindir}\\cyglsa\\${dll}"
96 then
97 echo "Setting the new registry value failed. Exiting."
98 exit 1
99 fi
100
101 echo
102 echo "Cygwin LSA authentication package registered."
103 echo
104 echo "Activating Cygwin's LSA authentication package requires to reboot."
105 if [ -x /bin/shutdown ]
106 then
107 if request "Do you want to do this immediately?"
108 then
109 echo
110 echo "Other users might still be working on this machine."
111 echo
112 if request "Are you sure?"
113 then
114 echo
115 echo "Ok, will reboot in 30 seconds."
116 echo
117 echo "If you change your mind, call 'shutdown -a' within 30 seconds"
118 shutdown -r 30
119 fi
120 fi
121 fi
This page took 0.043686 seconds and 4 git commands to generate.