Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (2 kB)

1
#! /bin/bash
2

    
3
# Copyright (C) 2011 GRNET S.A. 
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19

    
20
### BEGIN TASK INFO
21
# Provides:		DisableRemoteDesktopConnections
22
# RunBefore:            UmountImage
23
# RunAfter:		MountImage
24
# Short-Description:	Temporary Disable Remote Desktop Connections
25
### END TASK INFO
26

    
27
#
28
# This task will change the value of `fDenyTSConnection' registry key located in
29
# `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\' to
30
# "true". This will disable RDP connections. The key will change back to "false"
31
# during the specialize pass of the Windows setup.
32
#
33

    
34
set -e
35
. "@commondir@/common.sh"
36

    
37
trap task_cleanup EXIT
38
report_start_task
39

    
40
# Check if the task should be prevented from running.
41
check_if_excluded
42

    
43
if [ ! -d "$SNF_IMAGE_TARGET" ]; then
44
    log_error "Target directory \`$SNF_IMAGE_TARGET' is missing"
45
fi
46

    
47
if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" != "windows" ]; then
48
    exit 0
49
fi
50

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

    
54
# Change the key value.
55
# For a stupid reason chntpw returns 2!
56
chntpw -e "$hive" <<EOF || { test $? -eq 2 && chntpw_ret="success"; }
57
cd ControlSet${current: -3}\Control\Terminal Server
58
ed fDenyTSConnections
59
1
60
q
61
y
62
EOF
63

    
64
if [ x"$chntpw_ret" != "xsuccess" ]; then
65
    log_error "$CHNTPW failed"
66
fi
67

    
68
exit 0
69

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