[PATCH] conf: Don't generate machine names with a dot

Michal Privoznik posted 1 patch 4 years, 1 month ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/c99a26104d84bdbbbfc264e7ec0084692cb2802c.1582906969.git.mprivozn@redhat.com
There is a newer version of this series
src/conf/domain_conf.c | 4 ++--
tests/virsystemdtest.c | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
[PATCH] conf: Don't generate machine names with a dot
Posted by Michal Privoznik 4 years, 1 month ago
According to the linked BZ, machined expects either valid
hostname or valid FQDN. While in case of multiple dots, a
trailing one doesn't violate FQDN, it does violate the rule in
case of something simple, like "domain.". But it's safe to remove
it in both cases.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1721804

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/conf/domain_conf.c | 4 ++--
 tests/virsystemdtest.c | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 17867eeece..9371153618 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -30838,8 +30838,8 @@ virDomainMachineNameAppendValid(virBufferPtr buf,
         virBufferAddChar(buf, *name);
     }
 
-    /* trailing dashes are not allowed */
-    virBufferTrimChars(buf, "-");
+    /* trailing dashes or dots are not allowed */
+    virBufferTrimChars(buf, "-.");
 }
 
 #undef HOSTNAME_CHARS
diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c
index b7dfd64d06..9847f255ac 100644
--- a/tests/virsystemdtest.c
+++ b/tests/virsystemdtest.c
@@ -744,6 +744,7 @@ mymain(void)
                  "qemu-100-kstest-network-device-default-httpksc9eed63e-981e-48ec");
     TEST_MACHINE("kstest-network-device-default-httpks_(c9eed63e-981e-48ec--cdc-56b3f8c5f678)", 10,
                  "qemu-10-kstest-network-device-default-httpksc9eed63e-981e-48ec");
+    TEST_MACHINE("demo.test.", 11, "qemu-11-demo.test");
 
 # define TESTS_PM_SUPPORT_HELPER(name, function) \
     do { \
-- 
2.24.1

Re: [PATCH] conf: Don't generate machine names with a dot
Posted by Michal Privoznik 4 years, 1 month ago
On 2/28/20 5:22 PM, Michal Privoznik wrote:
> According to the linked BZ, machined expects either valid
> hostname or valid FQDN. While in case of multiple dots, a
> trailing one doesn't violate FQDN, it does violate the rule in
> case of something simple, like "domain.". But it's safe to remove
> it in both cases.
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1721804

In the end, I've cloned the bug. The new URL is:

https://bugzilla.redhat.com/show_bug.cgi?id=1808499

Fixed locally.

Michal

Re: [PATCH] conf: Don't generate machine names with a dot
Posted by Ján Tomko 4 years, 1 month ago
s/with a dot/ending with a dot/ in the summary?

On a Friday in 2020, Michal Privoznik wrote:
>According to the linked BZ, machined expects either valid
>hostname or valid FQDN. While in case of multiple dots, a
>trailing one doesn't violate FQDN, it does violate the rule in
>case of something simple, like "domain.". But it's safe to remove
>it in both cases.
>

Please mention my libvirt commit 45464db8ba502764cf37ec9335770248bdb3d9a8
and systemd commit d65652f1f21a4b0c59711320f34266c635393c89 here.

>Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1721804
>
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>---
> src/conf/domain_conf.c | 4 ++--
> tests/virsystemdtest.c | 1 +
> 2 files changed, 3 insertions(+), 2 deletions(-)

If you care about all the possible use cases:
* the above-mentioned systemd commit also forbids hyphens on either side
   of a dot
* even before that commit, leading dots were not allowed

Using any of the above (including the trailing dot which this commit fixes)
is equally odd to me. (unlike the quick fix I did for the dashes, which were
a result of libvirt cutting of sensible UUIDs in half)

So even after this patch libvirt is able to generate invalid machines.
names. I simply do not care.

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano