mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
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:
parent
e1d7273f24
commit
9ba2646291
@ -38,17 +38,8 @@
|
|||||||
|
|
||||||
VIR_LOG_INIT("util.systemd");
|
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,
|
static void virSystemdEscapeName(virBufferPtr buf,
|
||||||
const char *name,
|
const char *name)
|
||||||
bool full_escape)
|
|
||||||
{
|
{
|
||||||
static const char hextable[16] = "0123456789abcdef";
|
static const char hextable[16] = "0123456789abcdef";
|
||||||
|
|
||||||
@ -66,7 +57,7 @@ static void virSystemdEscapeName(virBufferPtr buf,
|
|||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
|
||||||
":-_.\\"
|
":-_.\\"
|
||||||
|
|
||||||
if (full_escape && *name == '.') {
|
if (*name == '.') {
|
||||||
ESCAPE(*name);
|
ESCAPE(*name);
|
||||||
name++;
|
name++;
|
||||||
}
|
}
|
||||||
@ -74,7 +65,7 @@ static void virSystemdEscapeName(virBufferPtr buf,
|
|||||||
while (*name) {
|
while (*name) {
|
||||||
if (*name == '/')
|
if (*name == '/')
|
||||||
virBufferAddChar(buf, '-');
|
virBufferAddChar(buf, '-');
|
||||||
else if ((full_escape && *name == '-') ||
|
else if (*name == '-' ||
|
||||||
*name == '\\' ||
|
*name == '\\' ||
|
||||||
!strchr(VALID_CHARS, *name))
|
!strchr(VALID_CHARS, *name))
|
||||||
ESCAPE(*name);
|
ESCAPE(*name);
|
||||||
@ -94,9 +85,9 @@ char *virSystemdMakeScopeName(const char *name,
|
|||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
virBufferAddLit(&buf, "machine-");
|
virBufferAddLit(&buf, "machine-");
|
||||||
virSystemdEscapeName(&buf, drivername, true);
|
virSystemdEscapeName(&buf, drivername);
|
||||||
virBufferAddLit(&buf, "\\x2d");
|
virBufferAddLit(&buf, "\\x2d");
|
||||||
virSystemdEscapeName(&buf, name, true);
|
virSystemdEscapeName(&buf, name);
|
||||||
virBufferAddLit(&buf, ".scope");
|
virBufferAddLit(&buf, ".scope");
|
||||||
|
|
||||||
if (virBufferCheckError(&buf) < 0)
|
if (virBufferCheckError(&buf) < 0)
|
||||||
@ -113,7 +104,7 @@ char *virSystemdMakeSliceName(const char *partition)
|
|||||||
if (*partition == '/')
|
if (*partition == '/')
|
||||||
partition++;
|
partition++;
|
||||||
|
|
||||||
virSystemdEscapeName(&buf, partition, true);
|
virSystemdEscapeName(&buf, partition);
|
||||||
virBufferAddLit(&buf, ".slice");
|
virBufferAddLit(&buf, ".slice");
|
||||||
|
|
||||||
if (virBufferCheckError(&buf) < 0)
|
if (virBufferCheckError(&buf) < 0)
|
||||||
@ -139,7 +130,7 @@ char *virSystemdMakeMachineName(const char *name,
|
|||||||
virBufferAsprintf(&buf, "%s-%s-", username, drivername);
|
virBufferAsprintf(&buf, "%s-%s-", username, drivername);
|
||||||
}
|
}
|
||||||
|
|
||||||
virSystemdEscapeName(&buf, name, false);
|
virSystemdEscapeName(&buf, name);
|
||||||
|
|
||||||
machinename = virBufferContentAndReset(&buf);
|
machinename = virBufferContentAndReset(&buf);
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -517,9 +517,9 @@ mymain(void)
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
TEST_MACHINE("demo", "qemu-demo");
|
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!name", "qemu-demo\\x21name");
|
||||||
TEST_MACHINE(".demo", "qemu-.demo");
|
TEST_MACHINE(".demo", "qemu-\\x2edemo");
|
||||||
TEST_MACHINE("bull\U0001f4a9", "qemu-bull\\xf0\\x9f\\x92\\xa9");
|
TEST_MACHINE("bull\U0001f4a9", "qemu-bull\\xf0\\x9f\\x92\\xa9");
|
||||||
|
|
||||||
# define TESTS_PM_SUPPORT_HELPER(name, function) \
|
# define TESTS_PM_SUPPORT_HELPER(name, function) \
|
||||||
|
Loading…
Reference in New Issue
Block a user