Statistics
| Branch: | Tag: | Revision:

root / snf-image-helper / tasks / 40DisableRemoteDesktopConnections.in @ ec728294

History | View | Annotate | Download (1.2 kB)

1
#! /bin/bash
2

    
3
### BEGIN TASK INFO
4
# Provides:		DisableRemoteDesktopConnections
5
# RunBefore:            UmountImage
6
# RunAfter:		MountImage
7
# Short-Description:	Temporary Disable Remote Desktop Connections
8
### END TASK INFO
9

    
10
#
11
# This task will change the value of `fDenyTSConnection' registry key located in
12
# `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\' to
13
# "true". This will disable RDP connections. The key will change back to "false"
14
# during the specialize pass of the Windows setup.
15
#
16

    
17
set -e
18
. "@commondir@/common.sh"
19

    
20
if [ ! -d "$SNF_IMAGE_TARGET" ]; then
21
    log_error "Target directory \`$SNF_IMAGE_TARGET' is missing"
22
fi
23

    
24
if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" != "windows" ]; then
25
    exit 0
26
fi
27

    
28
hive="$SNF_IMAGE_TARGET/Windows/System32/config/SYSTEM"
29
current=$($REGLOOKUP "$hive" | grep ^/Select/Current | cut -d, -f3)
30

    
31
# Change the key value.
32
# For a stupid reason chntpw returns 2!
33
chntpw -e "$hive" <<EOF || { test $? -eq 2 && chntpw_ret="success"; }
34
cd ControlSet${current: -3}\Control\Terminal Server
35
ed fDenyTSConnections
36
1
37
q
38
y
39
EOF
40

    
41
if [ x"$chntpw_ret" != "xsuccess" ]; then
42
    log_error "$CHNTPW failed"
43
fi
44

    
45
exit 0
46

    
47
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :