Commit ad6e8bf1 authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Remove chntpw and reglookup in favor of hivex*

Use hivexget and hivexregedit instead of reglookup and chntpw to browse
and alter the windows registry. The hivex utilities are better designed
and maintained
parent 882aa080
......@@ -13,9 +13,7 @@ dist_common_DATA = common.sh unattend.xml
edit = sed \
-e 's|@commondir[@]|$(commondir)|g' \
-e 's|@scriptsdir[@]|$(scriptsdir)|g' \
-e 's|@tasksdir[@]|$(tasksdir)|g' \
-e 's|@RESIZE2FS[@]|$(RESIZE2FS)|g' \
-e 's|@XMLSTARLET[@]|$(XMLSTARLET)|g'
-e 's|@tasksdir[@]|$(tasksdir)|g'
%:%.in Makefile
rm -f $@ $@.tmp
......
......@@ -29,8 +29,6 @@ SFDISK=sfdisk
MKSWAP=mkswap
BLKID=blkid
BLOCKDEV=blockdev
REGLOOKUP=reglookup
CHNTPW=chntpw
SGDISK=sgdisk
GROWFS_UFS=growfs.ufs
DUMPFS_UFS=dumpfs.ufs
......@@ -39,6 +37,8 @@ DUMPFS_OPENBSD=dumpfs.openbsd
DATE="date -u" # Time in UTC
EATMYDATA=eatmydata
MOUNT="mount -n"
HIVEXGET="hivexget"
HIVEXREGEDIT="hivexregedit"
CLEANUP=( )
ERRORS=( )
......
......@@ -29,14 +29,14 @@ if test -z "$PARTED" ; then
AC_MSG_ERROR([parted not found in $PATH])
fi
AC_PATH_PROG(REGLOOKUP, [reglookup], [], [$PATH:/usr/sbin:/sbin])
if test -z "$REGLOOKUP" ; then
AC_MSG_ERROR([reglookup not found in $PATH])
AC_PATH_PROG(HIVEXGET, [hivexget], [], [$PATH:/usr/sbin:/sbin])
if test -z "$HIVEXGET" ; then
AC_MSG_ERROR([hivexget not found in $PATH])
fi
AC_PATH_PROG(CHNTPW, [chntpw], [], [$PATH:/usr/sbin:/sbin])
if test -z "$CHNTPW" ; then
AC_MSG_ERROR([chntpw not found in $PATH])
AC_PATH_PROG(HIVEXREGEDIT, [hivexregedit], [], [$PATH:/usr/sbin:/sbin])
if test -z "$HIVEXREGEDIT" ; then
AC_MSG_ERROR([hivexregedit not found in $PATH])
fi
AC_CONFIG_FILES([
......
......@@ -26,8 +26,8 @@
#
# This task will change the value of `fDenyTSConnection' registry key located
# in `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\' to
# "true". This will disable RDP connections. The key will change back to
# under `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\'
# to "true". This will disable RDP connections. The key will change back to
# "false" during the specialize pass of the Windows setup.
#
......@@ -48,26 +48,34 @@ if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" != "windows" ]; then
exit 0
fi
# Supress a specific reglookup warning messages. In Windows 2012, although the
# command works correct, it polluts the output with hundreds of warning
# messages about not being able to interprete registry key values.
RGLKP_WRNG="^WARN: While quoting value for '.\+', warning returned: Data could not be interpreted, quoting raw buffer."
hive="$SNF_IMAGE_TARGET/Windows/System32/config/SYSTEM"
current=$($REGLOOKUP "$hive" 2> >(grep -v "$RGLKP_WRNG" >&2) | grep ^/Select/Current | cut -d, -f3)
# Change the key value.
# For a stupid reason chntpw returns 2!
chntpw -e "$hive" <<EOF || { test $? -eq 2 && chntpw_ret="success"; }
cd ControlSet${current: -3}\Control\Terminal Server
ed fDenyTSConnections
1
q
y
EOF
if [ x"$chntpw_ret" != "xsuccess" ]; then
log_error "$CHNTPW failed"
current=$($HIVEXGET "$hive" Select Current)
if [ "$current" = "" ]; then
log_error "Unable to find CurrentControlSet in the registry"
fi
# Pad the value with zeroes
current=$(printf "%03d" "$current")
#The current '\SYSTEM\CurrentContolSet\Control\Terminal Server' values
values=$($HIVEXGET "$hive" "ControlSet${current}\Control\Terminal Server")
# Remove fDenyTSConnections if present
values=$(grep -v ^'"fDenyTSConnections"=' <<< "$values")
regfile=$(mktemp)
add_cleanup rm "$regfile"
cat > "$regfile" <<EOF
Windows Registry Editor Version 5.00
[\ControlSet${current}\Control\Terminal Server]
$values
"fDenyTSConnections"=dword:00000001
EOF
$HIVEXREGEDIT --merge "$hive" "$regfile"
exit 0
......
......@@ -21,7 +21,7 @@ debootstrap=Debian GRNet Helper
aptsources=Debian
[Debian]
packages=socat iproute xenstore-utils ntfsprogs xmlstarlet python reglookup chntpw parted python-support eatmydata gdisk ntfs-3g python-passlib
packages=socat iproute xenstore-utils ntfsprogs xmlstarlet python parted python-support eatmydata gdisk ntfs-3g python-passlib libhivex-bin libwin-hivex-perl
source=http://ftp.gr.debian.org/debian
suite=wheezy
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment