From: Ken Milmore <ken.milmore@gmail.com>
To: kernel-tls-handshake@lists.linux.dev
Subject: [PATCH 3/7] tlshd_handshake_parms: Use an empty string, instead of "unknown", for the default value of peername.
Date: Sun, 8 Jun 2025 18:43:22 +0100 [thread overview]
Message-ID: <1f1e31ce-84fd-4db8-8873-68ba69019f67@gmail.com> (raw)
"unknown" could conceivably be a valid hostname.
Signed-off-by: Ken Milmore <ken.milmore@gmail.com>
---
src/tlshd/log.c | 6 +++++-
src/tlshd/netlink.c | 3 ++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/tlshd/log.c b/src/tlshd/log.c
index 3594d52..77e2d29 100644
--- a/src/tlshd/log.c
+++ b/src/tlshd/log.c
@@ -57,7 +57,9 @@ void tlshd_log_success(const char *hostname, const struct sockaddr *sap,
char buf[NI_MAXHOST];
getnameinfo(sap, salen, buf, sizeof(buf), NULL, 0, NI_NUMERICHOST);
- syslog(LOG_INFO, "Handshake with %s (%s) was successful\n",
+ if (hostname[0] == '\0')
+ hostname = "<unknown>";
+ syslog(LOG_INFO, "Handshake with '%s' (%s) was successful\n",
hostname, buf);
}
@@ -75,6 +77,8 @@ void tlshd_log_failure(const char *hostname, const struct sockaddr *sap,
char buf[NI_MAXHOST];
getnameinfo(sap, salen, buf, sizeof(buf), NULL, 0, NI_NUMERICHOST);
+ if (hostname[0] == '\0')
+ hostname = "<unknown>";
syslog(LOG_ERR, "Handshake with '%s' (%s) failed\n",
hostname, buf);
} else
diff --git a/src/tlshd/netlink.c b/src/tlshd/netlink.c
index ce8e981..0f4a797 100644
--- a/src/tlshd/netlink.c
+++ b/src/tlshd/netlink.c
@@ -223,7 +223,7 @@ static void tlshd_parse_certificate(struct tlshd_handshake_parms *parms,
parms->x509_privkey = nla_get_s32(tb[HANDSHAKE_A_X509_PRIVKEY]);
}
-static char tlshd_peername[NI_MAXHOST] = "unknown";
+static char tlshd_peername[NI_MAXHOST] = "";
static struct sockaddr_storage tlshd_peeraddr = { 0 };
static int tlshd_genl_valid_handler(struct nl_msg *msg, void *arg)
@@ -289,6 +289,7 @@ static int tlshd_genl_valid_handler(struct nl_msg *msg, void *arg)
NULL, 0, NI_NAMEREQD);
if (err) {
tlshd_log_gai_error(err);
+ tlshd_peername[0] = '\0';
return NL_STOP;
}
}
--
2.47.2
next reply other threads:[~2025-06-08 17:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-08 17:43 Ken Milmore [this message]
2025-06-08 18:14 ` [PATCH 3/7] tlshd_handshake_parms: Use an empty string, instead of "unknown", for the default value of peername Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1f1e31ce-84fd-4db8-8873-68ba69019f67@gmail.com \
--to=ken.milmore@gmail.com \
--cc=kernel-tls-handshake@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox