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

Set Administrator password in sysprep.inf

The administrator password in Windows XP is a special case. If the
AdminPassword entry of the GuiUnattended section is missing, then the
installation is not unattended.
parent d0cfa909
......@@ -24,7 +24,7 @@ for more information.
Copyright and license
=====================
Copyright (C) 2011-2015 GRNET S.A. and individual contributors.
Copyright (C) 2011-2016 GRNET S.A. and individual contributors.
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
......
#! /bin/bash
# Copyright (C) 2011, 2015 GRNET S.A. and individual contributors
# Copyright (C) 2011-2016 GRNET S.A. and individual contributors
#
# 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
......@@ -75,7 +75,7 @@ netbsd_change_shadow_entry() {
}
windows_password() {
local target password sam names wcm xpath unattend arch
local target password sam names wcm xpath unattend arch sysprepinf infedit
target="$1"
password="$2"
sam="$target/windows/system32/config/sam"
......@@ -94,6 +94,24 @@ windows_password() {
SNF_IMAGE_PROPERTY_USERS="Administrator"
fi
if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = 'windows-legacy' ]; then
infedit=@scriptsdir@/handle-ini-file.py
sysprepinf="$(get_sysprepinf "$target")"
if [ -z "$sysprepinf" ]; then
log_error "SYSPREP.INF answer file not found."
fi
# Change the Administrator password if not set. This needs to be done
# in order to have an unattended installation. If the AdminPassword
# entry is present, then maybe the user wants to leave it as is. If
# not, he should have added "Administrator" to the USERS image
# property.
if [ -z "$($infedit "$sysprepinf" get GuiUnattended AdminPassword)" ]; then
$infedit "$sysprepinf" set GuiUnattended AdminPassword "$password"
$infedit "$sysprepinf" set GuiUnattended EncryptedAdminPassword No
fi
fi
names="$($HIVEXREGEDIT --export "$sam" '\SAM\Domains\Account\Users\Names' \
| gawk 'match($0, /Names\\([^\\]+)\]/, n) { print n[1]; }')"
......
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