From nobody Mon Oct 23 20:19:39 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 4SDmkg3zFcz4yS1Y; Mon, 23 Oct 2023 20:19:39 +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 4SDmkg3JP3z3PHh; Mon, 23 Oct 2023 20:19:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698092379; 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=zQFde6L3/FsIo4Tlef4WLg1jFj1wuXl4m8Ut2It3320=; b=bhWTAVVgLa6vStFD7w31PPi9wk+nPnYnNbMluBdSmZ79axNipmy+DRw14EXyLNuOP8TjCa iVkC87SXI00/l86s6SG6VwRGrNgEHv7HK879ksmHi/Kwctj/y2nsZfABT1plDTGYLVtfC3 0HSvV3MUDSSvdu5WDRWCKAMA73nGT0cgRvI189KNMKEAQCgCaVBglYM2pGTi5zSTrcWTqY jqjGKoI7Sis5dIPWsVEDc8EFwrS4/+1H6EC/vdcP1tFuVNrK9x3iKsiUjF7p9KMtWosesZ 2LbmiTr4gyoj0hgzpla7+0oKtbQfvR08MKXDxHvh2p1gOF/9mUb9aHudhX6tdg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698092379; a=rsa-sha256; cv=none; b=vNFSPhVUKbzEb+KpbZyAEACwKPl9DrSohczfbNH4A90HlkBSDX7dZDcOSEze/ShMTf/1EE AW/HMq2BFZ7nIc2N4vL1wJ5HaGl56Rm4KD3Ah+rPqj0dTJSdj9SLxSfMZXGd3oY1pnBz0s EEncTDa+MUPlaj1Aivw1rRC4TydCUVr9UtWvNY05sS85WxLQ9B4wgr7sfjUxXqtD3zwWt1 hAwXeFIYFIpjGtMM64h1PlDGP/feYYeiYmEkQlxL+fSmtqJnghWNqDsdY+J3AbCcfjsTEt tYZLXEiYPY+fwb5t/gdLsYphMbhwPq97n9xqQCvcrzRszLXXz7qGsZCiowNSHg== 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=1698092379; 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=zQFde6L3/FsIo4Tlef4WLg1jFj1wuXl4m8Ut2It3320=; b=O+LOXidvOIowkW2emeYNaMzAcICAYQYZiPZJNW2+4D0OJRFavW2jUGiKMlNCJV2CIr1Grc fFso66TOl8LobczKaVDfL/15nRvNv0JTwkav5uCd1vyRndh0i6IHqUl96+g6MiCrTlS4b6 GvPMmqL3EMWpsPXd998SpnCP8KmkIknoXDUSuN+Qi2abtE3WrE8m4hi76Lfd/d60cz2vnO yzomxt8QvYy3VvbeWKmgQ1QqonjMhEu7pWk7OlVEsMMYmgvrjSDyfiIIsZkp9kLN2JuaeD 0jSRCl9lrs8IBxwr/GkHHMuBRtI0odfif52ZOW4W0Vjub8s5vLGA6S8S1FMTZA== 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 4SDmkg2LyBzst9; Mon, 23 Oct 2023 20:19:39 +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 39NKJd18051082; Mon, 23 Oct 2023 20:19:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39NKJdtb051079; Mon, 23 Oct 2023 20:19:39 GMT (envelope-from git) Date: Mon, 23 Oct 2023 20:19:39 GMT Message-Id: <202310232019.39NKJdtb051079@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 428879dc9110 - main - kgssapi: Add a new file with a function for a future commit 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/main X-Git-Reftype: branch X-Git-Commit: 428879dc9110240ad0940c7ac8cd69bcaf6e686e Auto-Submitted: auto-generated The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=428879dc9110240ad0940c7ac8cd69bcaf6e686e commit 428879dc9110240ad0940c7ac8cd69bcaf6e686e Author: Rick Macklem AuthorDate: 2023-10-23 20:17:16 +0000 Commit: Rick Macklem CommitDate: 2023-10-23 20:17:16 +0000 kgssapi: Add a new file with a function for a future commit A future commit needs a new upcall function that can do reverse DNS in order to generate a "service principal". This patch adds the file. MFC after: 1 month --- sys/kgssapi/gss_ip_to_dns.c | 85 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/sys/kgssapi/gss_ip_to_dns.c b/sys/kgssapi/gss_ip_to_dns.c new file mode 100644 index 000000000000..d2be006d5b3e --- /dev/null +++ b/sys/kgssapi/gss_ip_to_dns.c @@ -0,0 +1,85 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2008 Isilon Inc http://www.isilon.com/ + * Authors: Doug Rabson + * Developed with Red Inc: Alfred Perlstein + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "gssd.h" + +OM_uint32 +gss_ip_to_dns(OM_uint32 *minor_status, + char *ip_addr, + char *dns_name) +{ + struct ip_to_dns_res res; + struct ip_to_dns_args args; + enum clnt_stat stat; + CLIENT *cl; + + *minor_status = 0; + cl = kgss_gssd_client(); + if (cl == NULL) + return (GSS_S_FAILURE); + + args.ip_addr.ip_addr_len = strlen(ip_addr); + args.ip_addr.ip_addr_val = mem_alloc(args.ip_addr.ip_addr_len); + memcpy(args.ip_addr.ip_addr_val, ip_addr, args.ip_addr.ip_addr_len); + + bzero(&res, sizeof(res)); + stat = gssd_ip_to_dns_1(&args, &res, cl); + CLNT_RELEASE(cl); + if (stat != RPC_SUCCESS) { + *minor_status = stat; + return (GSS_S_FAILURE); + } + + if (res.major_status != GSS_S_COMPLETE) { + *minor_status = res.minor_status; + return (res.major_status); + } + + if (res.dns_name.dns_name_len == 0 || + res.dns_name.dns_name_len >= NI_MAXHOST) { + *minor_status = 0; + return (GSS_S_FAILURE); + } + + memcpy(dns_name, res.dns_name.dns_name_val, res.dns_name.dns_name_len); + dns_name[res.dns_name.dns_name_len] = '\0'; + + return (GSS_S_COMPLETE); +}