From nobody Sun Dec 24 01:08:07 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SyNFM3zZ1z55GFt; Sun, 24 Dec 2023 01:08:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SyNFM32WMz3Qmw; Sun, 24 Dec 2023 01:08:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703380087; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=39HIJBWszaYEfd0xYvwVTSQHiXSgHmM2xYA/apTPi14=; b=hLoNjWR58aaItomRbk7UYxdjp8hgVPCODYhBG/oT8YF+XPhgTWkxktNjB22mQR2gEdGJQJ 7vLMggKEV/hK7cCRKFn9Jr6y2v6NiEqpRqG/QcJa/mWL22C40s8LzFFnNyd7CEY0fezbrb XodsfaNlZKEf3Pgn5gQgcyVW4DhEpJsG2eBvZ05g8YYoq0acrlccXnQ5kIstKv19C4rzqh YCcQCFC6aqbx768KRGAlpU7gq8UtWH/VZLNMWUgIP0U+yVjgQsr5VsGz1GKwXHJC3etSpt 1cGfMtCrBNP/b1iP5wLgRGCyP97jTEKkYKuPzPMTLcvO5p9Znlww6K41PGQC5Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703380087; a=rsa-sha256; cv=none; b=Jhgsfuz8EH1lWMhPupSn3aV9z+6ruip2QoIPMDpAPhR7IpHnb08Z+MzeYAnbJJPPYBEaaP n/8lwqCFl42W1P8QGCuymvUx9CYKPSGF2LcZAjBV3snl5idzavooegu1GRkH4DaSggnS3Y aryRUQnTR7VViviBuwLNe81egoxhuTFYHI9PEMHraB7p8heYkW5nlb5G4pMLO5HGHXa9Rf IBuESdrjy3gEeAXoJ9bi6hV84c/ROHfclUDVR3wWZDsHSu8TGMRRFwDVQwnbue/hHBGgg/ Zi6Zz9TAX3D/Rpyv/XgBW0FFUDwJgbByJioNy2+pQS6QB2usLlomfoVDP2WOIw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703380087; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=39HIJBWszaYEfd0xYvwVTSQHiXSgHmM2xYA/apTPi14=; b=CLZZnhMjC4iMFkRpAp0e+3eCPkrBQZS1kwnLVrKBoBQgNWi2S89B7PaeMb0ifYMjqWTnmM ThDEhGw1ahnaIGTOHQ4vIjnLCv2pNF88zAltA7/wln+dyiHdAHO/TXq0ay3xJ9PfXJBo+T /lTEe7NK2HVt8Hy2jBCXic+kX/i/h7cYwqzYXT/tJ8YsNi6zb47mOWyOCQ/ax1VcPZYQri Jt1rgHoEc2s+XdK/pgaGXqoElrTYG05g6rQTvsLZ0wI1O1ABaOsGklgQirtblLJI5Q1nIX AVmuQvA/qL7s5wuN6MCPOXLQJKxmm2fnc7viv2jwIfKD3Uielw/Fj/vRgfWp+w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SyNFM254fz1LSS; Sun, 24 Dec 2023 01:08:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3BO187MH050670; Sun, 24 Dec 2023 01:08:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BO187jw050667; Sun, 24 Dec 2023 01:08:07 GMT (envelope-from git) Date: Sun, 24 Dec 2023 01:08:07 GMT Message-Id: <202312240108.3BO187jw050667@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: acc704b36192 - stable/14 - gssd: Add support for the new upcall required by commit 428879dc9110 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: acc704b36192dce117ef0d748be1d057e3fac9d0 Auto-Submitted: auto-generated The branch stable/14 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=acc704b36192dce117ef0d748be1d057e3fac9d0 commit acc704b36192dce117ef0d748be1d057e3fac9d0 Author: Rick Macklem AuthorDate: 2023-10-23 21:41:26 +0000 Commit: Rick Macklem CommitDate: 2023-12-24 01:06:54 +0000 gssd: Add support for the new upcall required by commit 428879dc9110 Commit 428879dc9110 adds a requirement for a new upcall for the gssd(8). This patch adds that upcall. Unfortunately, the old gssd.c would not build against the new patched gssd.x. This patch will fix the build. (cherry picked from commit 82ea0132c8b17a7a6067c8a36c6434e587ede6de) --- usr.sbin/gssd/gssd.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/usr.sbin/gssd/gssd.c b/usr.sbin/gssd/gssd.c index 59e0fc057f84..a22891f3bebf 100644 --- a/usr.sbin/gssd/gssd.c +++ b/usr.sbin/gssd/gssd.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,7 @@ #ifndef WITHOUT_KERBEROS #include #endif +#include #include #include #include @@ -49,6 +51,8 @@ #include #include #include +#include +#include #include #include #include @@ -624,6 +628,51 @@ gssd_import_name_1_svc(import_name_args *argp, import_name_res *result, struct s return (TRUE); } +/* + * If the name is a numeric IP host address, do a DNS lookup on it and + * return the DNS name in a malloc'd string. + */ +static char * +gssd_conv_ip_to_dns(int len, char *name) +{ + struct sockaddr_in sin; + struct sockaddr_in6 sin6; + char *retcp; + + retcp = NULL; + if (len > 0) { + retcp = mem_alloc(NI_MAXHOST); + memcpy(retcp, name, len); + retcp[len] = '\0'; + if (inet_pton(AF_INET, retcp, &sin.sin_addr) != 0) { + sin.sin_family = AF_INET; + sin.sin_len = sizeof(sin); + sin.sin_port = 0; + if (getnameinfo((struct sockaddr *)&sin, + sizeof(sin), retcp, NI_MAXHOST, + NULL, 0, NI_NAMEREQD) != 0) { + mem_free(retcp, NI_MAXHOST); + return (NULL); + } + } else if (inet_pton(AF_INET6, retcp, &sin6.sin6_addr) != 0) { + sin6.sin6_family = AF_INET6; + sin6.sin6_len = sizeof(sin6); + sin6.sin6_port = 0; + if (getnameinfo((struct sockaddr *)&sin6, + sizeof(sin6), retcp, NI_MAXHOST, + NULL, 0, NI_NAMEREQD) != 0) { + mem_free(retcp, NI_MAXHOST); + return (NULL); + } + } else { + mem_free(retcp, NI_MAXHOST); + return (NULL); + } + gssd_verbose_out("gssd_conv_ip_to_dns: %s\n", retcp); + } + return (retcp); +} + bool_t gssd_canonicalize_name_1_svc(canonicalize_name_args *argp, canonicalize_name_res *result, struct svc_req *rqstp) { @@ -933,6 +982,25 @@ gssd_display_status_1_svc(display_status_args *argp, display_status_res *result, return (TRUE); } +bool_t +gssd_ip_to_dns_1_svc(ip_to_dns_args *argp, ip_to_dns_res *result, struct svc_req *rqstp) +{ + char *host; + + memset(result, 0, sizeof(*result)); + /* Check to see if the name is actually an IP address. */ + host = gssd_conv_ip_to_dns(argp->ip_addr.ip_addr_len, + argp->ip_addr.ip_addr_val); + if (host != NULL) { + result->major_status = GSS_S_COMPLETE; + result->dns_name.dns_name_len = strlen(host); + result->dns_name.dns_name_val = host; + return (TRUE); + } + result->major_status = GSS_S_FAILURE; + return (TRUE); +} + int gssd_1_freeresult(SVCXPRT *transp, xdrproc_t xdr_result, caddr_t result) {