From nobody Sun Dec 24 01:03:20 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 4SyN7r2Lgfz55GDy; Sun, 24 Dec 2023 01:03:20 +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 4SyN7r1rN0z3PhP; Sun, 24 Dec 2023 01:03:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703379800; 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=+DvgX7zsCoLbmIyCLTaBK6sqAppWrGj50kKyKrdgOAU=; b=qdYY3gwclA9CqDLqClX1MYEYWlWHQIXGvYZ2UCjScrhtMwZovKw2ljBBZq4f0HeEmfdn+X GMGEaghM5ABVaTwd77KXrpHFL37T7u7lXT13kAjU+rvlZmkPRcEEBJrAModYdsnb9FLMsJ 5ZAizlhhT/MUGVtAaotJ03FlaCVoXls4c5xFXx88dI2xpbnZtby9NhqLdtEASOkDefGwqt OPnmd1rzIkcHKjOag411xx0BIufC42Jh4dyhHhI+0hbEwKaqa2H0v26G3Q3oGmF52+omVm C9qJ3Uj7nWM3aUP6MrwtYRWy3k0RzjXiAOZqxRrNZiin9qXql5shNsxTbrTAEw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703379800; a=rsa-sha256; cv=none; b=SVZM9+XBzwNDm2pUxPXUt6G6Q+RvH+U4ht/55sNeQJXzOTUkPbtl98psqFBgZ9z7bUlthB to758ib7PWeT8aFgLvt1kdGLF4yOXGKGik5NhC6vCiy2tzjyqRtS8IBV4tpWzDf4qS7TCQ uuFctKgxtNkYlRpN2x4IQt6xd7mugQpVh04aJM/9M5oo5E6oU+mifFj3/9eN3/M3526mYZ 5Z3R1whC4Y1W94bTOJUXintGTXZ1R5dGOPCH5NntH2HxIpW5HadTV020syznEbKQZgD6Nj 6z88VZVXYW0Aaejo+Dz4Ev70efpbEWoea9iXuwipMMaveHBIapIT0WsDD4Rd1A== 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=1703379800; 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=+DvgX7zsCoLbmIyCLTaBK6sqAppWrGj50kKyKrdgOAU=; b=xRcUfBOnkDsMpRLnF2B+tOqTB4bdyDcOpQnswQDvLsa3sph/lSadvxbFD4nZAoFo2rX9Ts 6fsL1kcnJH3oU1Vqj3bPQgvUTLmmCB02V960P7AeVLQKYfaY3YcQzCDUeJrkjgIWkDiZTq CcTjGSs0uVLNIXlCYOAjgiyT/CaK/JLA6DMCXBwzWxhDhXmxaeUeZvuTN25AN62eP+pv/x /L0LWVsPLyusHiqpXhjfnJXHfrcEmBp3YZyYhAW00SanhlK36kecQ9alsCoAbWwfvUUzuM nbUuhvUwP3iQscrbAUgAIKy2bKg4fxNj5m2mkNF93NHuRiZ5TubB+6Rn7luiVg== 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 4SyN7r0ttGz1LYb; Sun, 24 Dec 2023 01:03:20 +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 3BO13KhC049814; Sun, 24 Dec 2023 01:03:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BO13K74049811; Sun, 24 Dec 2023 01:03:20 GMT (envelope-from git) Date: Sun, 24 Dec 2023 01:03:20 GMT Message-Id: <202312240103.3BO13K74049811@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: 1ae724792ced - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 1ae724792ced8ea56ecc6a9c19b67741be9859cc Auto-Submitted: auto-generated The branch stable/14 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=1ae724792ced8ea56ecc6a9c19b67741be9859cc commit 1ae724792ced8ea56ecc6a9c19b67741be9859cc Author: Rick Macklem AuthorDate: 2023-10-23 20:17:16 +0000 Commit: Rick Macklem CommitDate: 2023-12-24 01:01:11 +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. (cherry picked from commit 428879dc9110240ad0940c7ac8cd69bcaf6e686e) --- 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); +}