Revert "systemd: Escape only needed characters for machined"

This reverts commit 0e0149ce91.

That commit was added to comply with systemd rules that were changed in
the meantime, so this patch is pointless.
This commit is contained in:
Martin Kletzander 2016-02-01 16:28:29 +01:00
parent e1d7273f24
commit 9ba2646291
2 changed files with 9 additions and 18 deletions

View File

@ -38,17 +38,8 @@
VIR_LOG_INIT("util.systemd");
/**
* virSystemdEscapeName:
*
* This function escapes various characters in @name and appends that
* escaped string to @buf, in order to comply with the requirements
* from systemd/machined. Parameter @full_escape decides whether to
* also escape dot as a first character and '-'.
*/
static void virSystemdEscapeName(virBufferPtr buf,
const char *name,
bool full_escape)
const char *name)
{
static const char hextable[16] = "0123456789abcdef";
@ -66,7 +57,7 @@ static void virSystemdEscapeName(virBufferPtr buf,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
":-_.\\"
if (full_escape && *name == '.') {
if (*name == '.') {
ESCAPE(*name);
name++;
}
@ -74,7 +65,7 @@ static void virSystemdEscapeName(virBufferPtr buf,
while (*name) {
if (*name == '/')
virBufferAddChar(buf, '-');
else if ((full_escape && *name == '-') ||
else if (*name == '-' ||
*name == '\\' ||
!strchr(VALID_CHARS, *name))
ESCAPE(*name);
@ -94,9 +85,9 @@ char *virSystemdMakeScopeName(const char *name,
virBuffer buf = VIR_BUFFER_INITIALIZER;
virBufferAddLit(&buf, "machine-");
virSystemdEscapeName(&buf, drivername, true);
virSystemdEscapeName(&buf, drivername);
virBufferAddLit(&buf, "\\x2d");
virSystemdEscapeName(&buf, name, true);
virSystemdEscapeName(&buf, name);
virBufferAddLit(&buf, ".scope");
if (virBufferCheckError(&buf) < 0)
@ -113,7 +104,7 @@ char *virSystemdMakeSliceName(const char *partition)
if (*partition == '/')
partition++;
virSystemdEscapeName(&buf, partition, true);
virSystemdEscapeName(&buf, partition);
virBufferAddLit(&buf, ".slice");
if (virBufferCheckError(&buf) < 0)
@ -139,7 +130,7 @@ char *virSystemdMakeMachineName(const char *name,
virBufferAsprintf(&buf, "%s-%s-", username, drivername);
}
virSystemdEscapeName(&buf, name, false);
virSystemdEscapeName(&buf, name);
machinename = virBufferContentAndReset(&buf);
cleanup:

View File

@ -517,9 +517,9 @@ mymain(void)
} while (0)
TEST_MACHINE("demo", "qemu-demo");
TEST_MACHINE("demo-name", "qemu-demo-name");
TEST_MACHINE("demo-name", "qemu-demo\\x2dname");
TEST_MACHINE("demo!name", "qemu-demo\\x21name");
TEST_MACHINE(".demo", "qemu-.demo");
TEST_MACHINE(".demo", "qemu-\\x2edemo");
TEST_MACHINE("bull\U0001f4a9", "qemu-bull\\xf0\\x9f\\x92\\xa9");
# define TESTS_PM_SUPPORT_HELPER(name, function) \