summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Kletzander <mkletzan@redhat.com>2015-11-24 15:56:12 +0100
committerCole Robinson <crobinso@redhat.com>2015-12-23 17:54:46 -0500
commitc0fa258b3df906bffd00e8b1ea825cb21eaa2579 (patch)
tree432df58540a82ee924c90a48f41ee9164ceaeb0f /src
parentd035796675ca42795953828d11f902f691fa6b29 (diff)
downloadlibvirt-c0fa258b3df906bffd00e8b1ea825cb21eaa2579.tar.gz
systemd: Escape machine name for machined
According to the documentation, CreateMachine accepts only 7bit ASCII characters in the machinename parameter, so let's make sure we can start machines with unicode names with systemd. We already have a function for that, we just forgot to use it. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1062943 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1282846 Signed-off-by: Martin Kletzander <mkletzan@redhat.com> (cherry picked from commit e24eda48cfae84a9003456b68eaf753a26123639)
Diffstat (limited to 'src')
-rw-r--r--src/util/virsystemd.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index 54c409d7f6..0c8f026437 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -119,16 +119,20 @@ char *virSystemdMakeMachineName(const char *name,
{
char *machinename = NULL;
char *username = NULL;
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+
if (privileged) {
- if (virAsprintf(&machinename, "%s-%s", drivername, name) < 0)
- goto cleanup;
+ virBufferAsprintf(&buf, "%s-", drivername);
} else {
if (!(username = virGetUserName(geteuid())))
goto cleanup;
- if (virAsprintf(&machinename, "%s-%s-%s", username, drivername, name) < 0)
- goto cleanup;
+
+ virBufferAsprintf(&buf, "%s-%s-", username, drivername);
}
+ virSystemdEscapeName(&buf, name);
+
+ machinename = virBufferContentAndReset(&buf);
cleanup:
VIR_FREE(username);