1 Star 0 Fork 25

mszjaas/nfs-utils_1

forked from src-openEuler/nfs-utils 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-libnfsidmap-try-to-get-the-domain-directly-from-host.patch 2.41 KB
一键复制 编辑 原始数据 按行查看 历史
From 90a23f7c6343bcb1b69c93ceccc14cc06e14d958 Mon Sep 17 00:00:00 2001
From: Aram Akhavan <github@aram.nubmail.ca>
Date: Sat, 15 Jul 2023 13:21:04 -0400
Subject: [PATCH] libnfsidmap: try to get the domain directly from hostname if
the DNS lookup fails and always show the log message if the domain can't be
determined
In nfs4_init_name_mapping(), if no domain is specified in the config file, the hostname will be looked up in DNS, and the domain extracted from that.
If DNS resolution isn't up at this time (i.e. on idmapd startup), the hardcoded domain in IDMAPD_DEFAULT_DOMAIN is used. This will break id mapping
for anyone who doesn't happen to use "localdomain". Previously, the log message indicating this has happened requires -v to be passed, so the
"failure" was silent by default.
Conflict:NA
Reference:https://git.linux-nfs.org/?p=steved/nfs-utils.git;a=patch;h=90a23f7c6343bcb1b69c93ceccc14cc06e14d958
Signed-off-by: Aram Akhavan <github@aram.nubmail.ca>
Signed-off-by: Steve Dickson <steved@redhat.com>
---
support/nfsidmap/libnfsidmap.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/support/nfsidmap/libnfsidmap.c b/support/nfsidmap/libnfsidmap.c
index 0a912e52..f8c36480 100644
--- a/support/nfsidmap/libnfsidmap.c
+++ b/support/nfsidmap/libnfsidmap.c
@@ -219,10 +219,15 @@ static int domain_from_dns(char **domain)
if (gethostname(hname, sizeof(hname)) == -1)
return -1;
- if ((he = gethostbyname(hname)) == NULL)
- return -1;
- if ((c = strchr(he->h_name, '.')) == NULL || *++c == '\0')
- return -1;
+ if ((he = gethostbyname(hname)) == NULL) {
+ IDMAP_LOG(1, ("libnfsidmap: DNS lookup of hostname failed. Attempting to use domain from hostname as is."));
+ if ((c = strchr(hname, '.')) == NULL || *++c == '\0')
+ return -1;
+ }
+ else {
+ if ((c = strchr(he->h_name, '.')) == NULL || *++c == '\0')
+ return -1;
+ }
/*
* Query DNS to see if the _nfsv4idmapdomain TXT record exists
* If so use it...
@@ -387,7 +392,7 @@ int nfs4_init_name_mapping(char *conffile)
dflt = 1;
ret = domain_from_dns(&default_domain);
if (ret) {
- IDMAP_LOG(1, ("libnfsidmap: Unable to determine "
+ IDMAP_LOG(0, ("libnfsidmap: Unable to determine "
"the NFSv4 domain; Using '%s' as the NFSv4 domain "
"which means UIDs will be mapped to the 'Nobody-User' "
"user defined in %s",
--
2.39.2 (Apple Git-143)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mszjaas/nfs-utils_1.git
git@gitee.com:mszjaas/nfs-utils_1.git
mszjaas
nfs-utils_1
nfs-utils_1
master

搜索帮助