Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cyglsa-config « lsaauth « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0a749f7ceb1d25b1064572f6261463a3f5c2471f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/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
}

# Check if running under at least Windows 2000
_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'

[ -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
if ! cp -b "/bin/${dll}" "/bin/cyglsa/${dll}"
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
# 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`
if ! regtool set "${value}" ${new} "${bindir}\\cyglsa\\${dll}"
then
  echo "Setting the new registry value failed.  Exiting."
  exit 1
fi

echo
echo "Cygwin LSA authentication package registered."
echo
echo "Activating Cygwin's LSA authentication package requires to reboot."
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