mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-03 13:47:18 +03:00
unattended: Avoid invalid chars on hostname
Some installations (Microsoft Windows was the problematic one here) will bail if the Computer's name / hostname contains one of the following characterers: "[{|}~[\\]^':; <=>?@!\"#$%`()+/.,*&]". Let's take a safe path and ensure that we never set those, replacing them by "-". Reviewed-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
This commit is contained in:
parent
aadaaf8785
commit
96af1de49f
@ -10,6 +10,7 @@ import getpass
|
||||
import locale
|
||||
import os
|
||||
import pwd
|
||||
import re
|
||||
import tempfile
|
||||
|
||||
from gi.repository import Libosinfo
|
||||
@ -68,6 +69,12 @@ def _make_installconfig(script, osobj, unattended_data, arch, hostname, url):
|
||||
|
||||
# Set hardware architecture and hostname
|
||||
config.set_hardware_arch(arch)
|
||||
|
||||
# Some installations will bail if the Computer's name contains one of the
|
||||
# following characters: "[{|}~[\\]^':; <=>?@!\"#$%`()+/.,*&]".
|
||||
# In order to take a safer path, let's ensure that we never set those,
|
||||
# replacing them by "-".
|
||||
hostname = re.sub("[{|}~[\\]^':; <=>?@!\"#$%`()+/.,*&]", "-", hostname)
|
||||
config.set_hostname(hostname)
|
||||
|
||||
# Try to guess the timezone from '/etc/localtime', in case it's not
|
||||
|
Loading…
x
Reference in New Issue
Block a user