代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/systemd 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From c04904a4f54f8949a6a7821a0859e2732366259b Mon Sep 17 00:00:00 2001
From: licunlong <licunlong1@huawei.com>
Date: Tue, 24 Nov 2020 19:57:38 +0800
Subject: [PATCH] treat underscore as valid hostname char
---
src/basic/hostname-util.c | 14 ++++++++++++--
test/test-network-generator-conversion.sh | 2 +-
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/basic/hostname-util.c b/src/basic/hostname-util.c
index e743033..8464164 100644
--- a/src/basic/hostname-util.c
+++ b/src/basic/hostname-util.c
@@ -80,6 +80,16 @@ bool valid_ldh_char(char c) {
c == '-';
}
+static bool hostname_valid_char(char c) {
+ return
+ (c >= 'a' && c <= 'z') ||
+ (c >= 'A' && c <= 'Z') ||
+ (c >= '0' && c <= '9') ||
+ c == '-' ||
+ c == '_' ||
+ c == '.';
+}
+
bool hostname_is_valid(const char *s, ValidHostnameFlags flags) {
unsigned n_dots = 0;
const char *p;
@@ -116,7 +126,7 @@ bool hostname_is_valid(const char *s, ValidHostnameFlags flags) {
hyphen = true;
} else {
- if (!valid_ldh_char(*p))
+ if (!hostname_valid_char(*p))
return false;
dot = false;
@@ -158,7 +168,7 @@ char* hostname_cleanup(char *s) {
dot = false;
hyphen = true;
- } else if (valid_ldh_char(*p)) {
+ } else if (hostname_valid_char(*p)) {
*(d++) = *p;
dot = false;
hyphen = false;
diff --git a/test/test-network-generator-conversion.sh b/test/test-network-generator-conversion.sh
index 6224a4d..05ef833 100755
--- a/test/test-network-generator-conversion.sh
+++ b/test/test-network-generator-conversion.sh
@@ -283,6 +283,7 @@ COMMAND_LINES=(
"ip=:::::dhcp99:dhcp6:10.0.0.128:[fdef:c400:bd01:1096::bbbb]"
"ip=::::::any"
"ip=::::::ibft"
+ "ip=10.0.0.1:::255.255.255.0:valid_hostname:foo99:off"
)
for cmdline in "${COMMAND_LINES[@]}"; do
check_one_long "$cmdline"
@@ -294,7 +295,6 @@ INVALID_COMMAND_LINES=(
"ip=:::::::foo"
"ip=10.0.0:::255.255.255.0::foo99:off"
"ip=10.0.0.1:::255.255.255::foo99:off"
- "ip=10.0.0.1:::255.255.255.0:invalid_hostname:foo99:off"
"ip=10.0.0.1:::255.255.255.0::verylonginterfacename:off"
"ip=:::::dhcp99:dhcp6:0"
"ip=:::::dhcp99:dhcp6:-1"
--
2.39.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。