[gnome-boxes/gnome-3-20] unattended: Avoid invalid chars on hostname



commit 812e4fcf3e384b57769c3c3abcca6e076a146b10
Author: Fabiano FidĂȘncio <fidencio redhat com>
Date:   Sun Apr 17 12:58:36 2016 +0200

    unattended: Avoid invalid chars on hostname
    
    Microsoft Windows doesn't allow to set a hostname that contains one of
    these characters: {|}~[\]^':; <=>? !"#$%`()+/.,*&
    
    Signed-off-by: Fabiano FidĂȘncio <fabianoo fidencio org>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=765175

 src/unattended-installer.vala |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index ddf5072..77fbb6b 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -123,7 +123,11 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
     }
 
     public override void prepare_to_continue_installation (string vm_name) {
-        this.hostname = vm_name.replace (" ", "-");
+        /*
+         * A valid hostname format should be provided by libosinfo.
+         * See: https://bugzilla.redhat.com/show_bug.cgi?id=1328236
+         */
+        this.hostname = replace_regex(vm_name, "[{|}~[\\]^':; <=>? !\"#$%`()+/.,*&]", "");
 
         var path = get_user_unattended ("unattended.img");
         disk_file = File.new_for_path (path);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]