[gnome-boxes] express,winxp,win2k3: Setup user account & autologon
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] express,winxp,win2k3: Setup user account & autologon
- Date: Wed, 23 May 2012 18:38:50 +0000 (UTC)
commit 2098e7175843d4a2e055abe8950a2963d79a8c1c
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue May 22 05:45:59 2012 +0300
express,winxp,win2k3: Setup user account & autologon
We weren't really creating a user account based on the information
provided. This patch fixes it. I tried very hard to find a less
intrusive way to accomplish this but I failed.
https://bugzilla.gnome.org/show_bug.cgi?id=676320
data/Makefile.am | 2 +
data/win2k3.sif | 4 +-
data/winxp.cmd | 6 ++
data/winxp.reg | 6 ++
data/winxp.sif | 4 +-
src/unattended-installer.vala | 139 +++++++++++++++++++++++------------------
src/winxp-installer.vala | 8 +++
7 files changed, 102 insertions(+), 67 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 03e1447..8f09cab 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -23,6 +23,8 @@ unattended_DATA = fedora.ks \
win7.xml \
win2k8.xml \
winxp.sif \
+ winxp.cmd \
+ winxp.reg \
win2k.sif \
win2k3.sif \
disk.img \
diff --git a/data/win2k3.sif b/data/win2k3.sif
index ff50a69..25888e4 100644
--- a/data/win2k3.sif
+++ b/data/win2k3.sif
@@ -16,8 +16,6 @@
[GuiUnattended]
AdminPassword="BOXES_PASSWORD"
EncryptedAdminPassword=NO
- AutoLogon=Yes
- AutoLogonCount=1
OEMSkipRegional=1
TimeZone=35
OemSkipWelcome=1
@@ -39,7 +37,7 @@
InstallDefaultComponents=Yes
[SetupParams]
- UserExecute = "sc config TlntSvr start= auto"
+ UserExecute = "a:\winxp.cmd"
[WindowsFirewall]
Profiles = WindowsFirewall.TurnOffFirewall
diff --git a/data/winxp.cmd b/data/winxp.cmd
new file mode 100644
index 0000000..004de19
--- /dev/null
+++ b/data/winxp.cmd
@@ -0,0 +1,6 @@
+sc config TlntSvr start= auto
+net user BOXES_USERNAME BOXES_PASSWORD /add /passwordreq:no
+net localgroup administrators BOXES_USERNAME /add
+net accounts /maxpwage:unlimited
+REGEDIT /S a:\winxp.reg
+EXIT
diff --git a/data/winxp.reg b/data/winxp.reg
new file mode 100644
index 0000000..4473091
--- /dev/null
+++ b/data/winxp.reg
@@ -0,0 +1,6 @@
+Windows Registry Editor Version 5.00
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
+"DefaultUserName"="BOXES_USERNAME"
+"DefaultPassword"="BOXES_PASSWORD"
+"AutoAdminLogon"="1"
diff --git a/data/winxp.sif b/data/winxp.sif
index ff50a69..25888e4 100644
--- a/data/winxp.sif
+++ b/data/winxp.sif
@@ -16,8 +16,6 @@
[GuiUnattended]
AdminPassword="BOXES_PASSWORD"
EncryptedAdminPassword=NO
- AutoLogon=Yes
- AutoLogonCount=1
OEMSkipRegional=1
TimeZone=35
OemSkipWelcome=1
@@ -39,7 +37,7 @@
InstallDefaultComponents=Yes
[SetupParams]
- UserExecute = "sc config TlntSvr start= auto"
+ UserExecute = "a:\winxp.cmd"
[WindowsFirewall]
Profiles = WindowsFirewall.TurnOffFirewall
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index 73dde76..8637ef1 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -27,12 +27,12 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
}
public bool password_mandatory { get; protected set; }
+ public DataStreamNewlineType newline_type;
+ public string disk_path;
- protected string unattended_src_path;
- protected string unattended_dest_name;
- protected DataStreamNewlineType newline_type;
-
- protected string disk_path;
+ protected GLib.List<UnattendedFile> unattended_files;
+ protected string unattended_src_path { get { return unattended_files.data.src_path; } }
+ protected string unattended_dest_name { get { return unattended_files.data.dest_name; } }
private bool created_disk;
@@ -81,10 +81,11 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
resources = media.resources;
disk_path = get_pkgcache (os.short_id + "-unattended.img");
- this.unattended_src_path = unattended_src_path;
- this.unattended_dest_name = unattended_dest_name;
newline_type = DataStreamNewlineType.LF;
+ unattended_files = new GLib.List<UnattendedFile> ();
+ unattended_files.append (new UnattendedFile (this, unattended_src_path, unattended_dest_name));
+
var time = TimeVal ();
var date = new DateTime.from_timeval_local (time);
timezone = date.get_timezone_abbreviation ();
@@ -108,7 +109,8 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
else
yield create_disk_image (cancellable);
- yield copy_unattended_file (cancellable);
+ foreach (var unattended_file in unattended_files)
+ yield unattended_file.copy (cancellable);
yield prepare_direct_boot (cancellable);
} catch (GLib.Error error) {
clean_up ();
@@ -152,6 +154,15 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
(_("Password required for express installation of %s"), label);
}
+ public virtual string fill_unattended_data (string data) throws RegexError {
+ var str = username_regex.replace (data, data.length, 0, username_entry.text);
+ str = password_regex.replace (str, str.length, 0, password);
+ str = timezone_regex.replace (str, str.length, 0, timezone);
+ str = lang_regex.replace (str, str.length, 0, lang);
+
+ return str;
+ }
+
protected virtual void setup_ui () {
setup_label = new Gtk.Label (_("Choose express install to automatically preconfigure the box with optimal settings."));
setup_label.halign = Gtk.Align.START;
@@ -234,17 +245,10 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
debug ("Removed '%s'.", disk_path);
}
- protected virtual string fill_unattended_data (string data) throws RegexError {
- var str = username_regex.replace (data, data.length, 0, username_entry.text);
- str = password_regex.replace (str, str.length, 0, password);
- str = timezone_regex.replace (str, str.length, 0, timezone);
- str = lang_regex.replace (str, str.length, 0, lang);
-
- return str;
- }
-
protected virtual async void prepare_direct_boot (Cancellable? cancellable) throws GLib.Error {}
+ protected void add_unattended_file (string unattended_src_path, string unattended_dest_name) {
+ unattended_files.append (new UnattendedFile (this, unattended_src_path, unattended_dest_name));
}
private async void create_disk_image (Cancellable? cancellable) throws GLib.Error {
@@ -259,50 +263,6 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
created_disk = true;
}
- private async void copy_unattended_file (Cancellable? cancellable) throws GLib.Error {
- var unattended_src = File.new_for_path (unattended_src_path);
- var unattended_tmp_path = get_user_unattended_dir (unattended_dest_name);
- var unattended_tmp = File.new_for_path (unattended_tmp_path);
-
- yield create_unattended_file (unattended_src, unattended_tmp, cancellable);
-
- debug ("Copying unattended file '%s' into disk drive/image '%s'", unattended_dest_name, disk_path);
- // FIXME: Perhaps we should use libarchive for this?
- string[] argv = { "mcopy", "-n", "-o", "-i", disk_path,
- unattended_tmp_path,
- "::" + unattended_dest_name };
- yield exec (argv, cancellable);
- debug ("Copied unattended file '%s' into disk drive/image '%s'", unattended_dest_name, disk_path);
-
- debug ("Deleting temporary file '%s'", unattended_tmp_path);
- unattended_tmp.delete (cancellable);
- debug ("Deleted temporary file '%s'", unattended_tmp_path);
- }
-
- private async void create_unattended_file (File source,
- File destination,
- Cancellable? cancellable) throws GLib.Error {
- debug ("Creating unattended file at '%s'..", destination.get_path ());
- var input_stream = yield source.read_async (Priority.DEFAULT, cancellable);
- var output_stream = yield destination.replace_async (null,
- false,
- FileCreateFlags.REPLACE_DESTINATION,
- Priority.DEFAULT,
- cancellable);
- var data_stream = new DataInputStream (input_stream);
- data_stream.newline_type = DataStreamNewlineType.ANY;
- string? str;
- while ((str = yield data_stream.read_line_async (Priority.DEFAULT, cancellable)) != null) {
- str = fill_unattended_data (str);
-
- str += (newline_type == DataStreamNewlineType.LF) ? "\n" : "\r\n";
-
- yield output_stream.write_async (str.data, Priority.DEFAULT, cancellable);
- }
- yield output_stream.close_async (Priority.DEFAULT, cancellable);
- debug ("Created unattended file at '%s'..", destination.get_path ());
- }
-
private async bool unattended_disk_exists (Cancellable? cancellable) {
var file = File.new_for_path (disk_path);
@@ -335,3 +295,60 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
avatar.file = avatar_file;
}
}
+
+private class Boxes.UnattendedFile {
+ public string src_path;
+ public string dest_name;
+
+ private UnattendedInstaller installer;
+
+ public UnattendedFile (UnattendedInstaller installer, string src_path, string dest_name) {
+ this.installer = installer;
+ this.src_path = src_path;
+ this.dest_name = dest_name;
+ }
+
+ public async void copy (Cancellable? cancellable) throws GLib.Error {
+ var unattended_tmp = yield create (cancellable);
+
+ debug ("Copying unattended file '%s' into disk drive/image '%s'", dest_name, installer.disk_path);
+ // FIXME: Perhaps we should use libarchive for this?
+ string[] argv = { "mcopy", "-n", "-o", "-i", installer.disk_path,
+ unattended_tmp.get_path (),
+ "::" + dest_name };
+ yield exec (argv, cancellable);
+ debug ("Copied unattended file '%s' into disk drive/image '%s'", dest_name, installer.disk_path);
+
+ debug ("Deleting temporary file '%s'", unattended_tmp.get_path ());
+ unattended_tmp.delete (cancellable);
+ debug ("Deleted temporary file '%s'", unattended_tmp.get_path ());
+ }
+
+ private async File create (Cancellable? cancellable) throws GLib.Error {
+ var source = File.new_for_path (src_path);
+ var destination_path = get_user_unattended_dir (dest_name);
+ var destination = File.new_for_path (destination_path);
+
+ debug ("Creating unattended file at '%s'..", destination.get_path ());
+ var input_stream = yield source.read_async (Priority.DEFAULT, cancellable);
+ var output_stream = yield destination.replace_async (null,
+ false,
+ FileCreateFlags.REPLACE_DESTINATION,
+ Priority.DEFAULT,
+ cancellable);
+ var data_stream = new DataInputStream (input_stream);
+ data_stream.newline_type = DataStreamNewlineType.ANY;
+ string? str;
+ while ((str = yield data_stream.read_line_async (Priority.DEFAULT, cancellable)) != null) {
+ str = installer.fill_unattended_data (str);
+
+ str += (installer.newline_type == DataStreamNewlineType.LF) ? "\n" : "\r\n";
+
+ yield output_stream.write_async (str.data, Priority.DEFAULT, cancellable);
+ }
+ yield output_stream.close_async (Priority.DEFAULT, cancellable);
+ debug ("Created unattended file at '%s'..", destination.get_path ());
+
+ return destination;
+ }
+}
diff --git a/src/winxp-installer.vala b/src/winxp-installer.vala
index 0b08133..554b2d3 100644
--- a/src/winxp-installer.vala
+++ b/src/winxp-installer.vala
@@ -23,6 +23,14 @@ private class Boxes.WinXPInstaller: WindowsInstaller {
var unattended_source = get_unattended_dir (media.os.short_id + ".sif");
base.copy (media, unattended_source, "Winnt.sif");
+ var name = media.os.short_id + ".cmd";
+ unattended_source = get_unattended_dir (name);
+ add_unattended_file (unattended_source, name);
+
+ name = media.os.short_id + ".reg";
+ unattended_source = get_unattended_dir (name);
+ add_unattended_file (unattended_source, name);
+
newline_type = DataStreamNewlineType.CR_LF;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]