gentoo-overlay/sys-apps/systemd/files/0012-Handle-musl-s-longer-H...

59 lines
2.1 KiB
Diff
Raw Normal View History

From 2704e56cc30d04c56943ba1a3133dfcafa73c4dd Mon Sep 17 00:00:00 2001
From: "A. Wilcox" <AWilcox@Wilcox-Tech.com>
Date: Sun, 18 Aug 2024 02:46:06 -0500
Subject: [PATCH 12/34] Handle musl's longer HOST_NAME_MAX: hardcode 64
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
There are multiple places in systemd, both runtime and test, that assume
that HOST_NAME_MAX is 64. Really, that should be fixed, but to make it
work at all, we start with hardcoding 64.
This cannot be upstreamed, but any work to actually fix the 64
assumption probably could.
Signed-off-by: Alexander Miroshnichenko <alex@millerson.name>
---
src/basic/hostname-util.c | 4 ++--
src/shared/hostname-setup.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/basic/hostname-util.c b/src/basic/hostname-util.c
index e743033b1ea1..0581b1b26a06 100644
--- a/src/basic/hostname-util.c
+++ b/src/basic/hostname-util.c
@@ -128,7 +128,7 @@ bool hostname_is_valid(const char *s, ValidHostnameFlags flags) {
if (hyphen)
return false;
- if (p-s > HOST_NAME_MAX) /* Note that HOST_NAME_MAX is 64 on Linux, but DNS allows domain names up to
+ if (p-s > 64) /* Note that HOST_NAME_MAX is 64 on Linux, but DNS allows domain names up to
* 255 characters */
return false;
@@ -141,7 +141,7 @@ char* hostname_cleanup(char *s) {
assert(s);
- for (p = s, d = s, dot = hyphen = true; *p && d - s < HOST_NAME_MAX; p++)
+ for (p = s, d = s, dot = hyphen = true; *p && d - s < 64; p++)
if (*p == '.') {
if (dot || hyphen)
continue;
diff --git a/src/shared/hostname-setup.c b/src/shared/hostname-setup.c
index 6cfd4b54bf63..4de610fb50f1 100644
--- a/src/shared/hostname-setup.c
+++ b/src/shared/hostname-setup.c
@@ -66,7 +66,7 @@ int shorten_overlong(const char *s, char **ret) {
if (p)
*p = 0;
- strshorten(h, HOST_NAME_MAX);
+ strshorten(h, 64);
if (!hostname_is_valid(h, /* flags= */ 0))
return -EDOM;
--
2.41.0