From nobody Fri Aug 29 14:43:22 2025 X-Original-To: freebsd-current@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 4cD1H23TlWz65dhK for ; Fri, 29 Aug 2025 14:43:42 +0000 (UTC) (envelope-from rick.macklem@gmail.com) Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cD1H151JBz3r1r; Fri, 29 Aug 2025 14:43:41 +0000 (UTC) (envelope-from rick.macklem@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20230601 header.b=aiq2KAeL; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of rick.macklem@gmail.com designates 2a00:1450:4864:20::52d as permitted sender) smtp.mailfrom=rick.macklem@gmail.com Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-61caa266828so4543673a12.1; Fri, 29 Aug 2025 07:43:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756478615; x=1757083415; darn=freebsd.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=TOIUkzcZz0nDljeoS5LnR2oWkp8f7AXPNcTiPqp15dA=; b=aiq2KAeLvwBBRiirBoGVbzaVmmQkJN/shB4gQFg2WpXYyYkqFzfgHKHcGZ7ovgdyeV FJz4CotrMycFlG7eVw4MVF3hQY50QDUpGyw6b7cSWlw0vjZ8vHx1F2UZfvpQUW62lzgL 8mLaEG3xA5B25OEMWXS51VIsQzaS/LxqJGYVdedQppCzth0hxur2IF2IDIs4pFQ/+du/ ju94F0u/8LQYvnut9UEZVTuspzM9ZzkGEyIxnITK+Ep142nsbz7DTgcKx4FGUU5phhdD v8zQs9m4zAHjvVH3K5bsRs7+rD/4vxjrTeNuYOWJeYKZ112tpzbyjytSAZEqMbuKOjjP M1YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756478615; x=1757083415; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TOIUkzcZz0nDljeoS5LnR2oWkp8f7AXPNcTiPqp15dA=; b=Wz2nQY9UmxyAwloLlfQ6QATHHQiUR3oiVipOZIt5wAxXzXXsI4PcZGMDkTr24Dj6F7 r4UIWG0kxCXzulxSV4qb3ramOTPkW9oE5obyH494BlEa0MybkiGLqNUfLmiOzc2LAzBH n1dKQOzV0upPXCz7GBSKy9fYYx2KDVXAfd/JhhD9JZXesbn7/ARc7reKYLpDBYEPMcrv PsSigudQr9HpmCqeccKNNwmvZmYfyXH58D8tVryGVx6v+blUdHr9cKKk8WMmfa1dEi9A sctpg9G8CB4/Oowb3rOWhPcEUY9RPKOEsPVxAnLAqxH1qAzraVDNv/byF0UiLc72iUAy 4AgA== X-Forwarded-Encrypted: i=1; AJvYcCW+Nsrg8MyCwxM5N7C5Ya+OXFYMAIMDDsnDEG2rt/jtaGXOlOzCbu1EARn43xE/8sXIv0ZWH7Af1+vkqKDIA7I=@freebsd.org X-Gm-Message-State: AOJu0Yy7XyQRzchd2GYtoqjDh6br0qZPZ3Hj5RiW6BqigJZkOy5n9WKq li57vqdDUjcP+H4tBWTy8Nh1mMjt3Z2p5nN3bHqHcYF4H0I7ozjaOUoXYrz/l48yYr/xR6J4dY9 r0vM3OjJUEO3WWjkdCV8g8pvDj64o+GNQ X-Gm-Gg: ASbGncvaxrEmE3/O29mwfbdmVrUQRv9dt4EcJZNTosIien5rG2y1T9TiebUDsAsNHZc HDLTXU996DeYVqwUFqU+Ybawa260/DK7/RdQiCZvgw81gQRYCYsJdj8HgMjN0gNzHuVhidX7lyW 90lwHr7+Cg+tPt4jT29T0kTjbQtMjqfRZb2UAivR7CDQVXhOSNJZOYlWucz5nEKyI9sV8tcUTv6 1+JyIk75/8aXpKUM/5cULGM40SA/9nfFOf1p2rUsvS0FiF/ X-Google-Smtp-Source: AGHT+IEW9ILhujwGHC15vwALw3OB6FyFNVayB2qwAHYz5DHLHvXxrmvkgXlk0bI+DUWihWzCMf8ZiibgK8il2UQ/MHw= X-Received: by 2002:a05:6402:274f:b0:61c:d740:2471 with SMTP id 4fb4d7f45d1cf-61cd740275cmr6324934a12.3.1756478614645; Fri, 29 Aug 2025 07:43:34 -0700 (PDT) List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@FreeBSD.org MIME-Version: 1.0 References: <56dd78c6-a53a-4c4c-989a-335cc5fed405@FreeBSD.org> <1578a4eac5402d0496d8989e5258bc78@Leidinger.net> In-Reply-To: From: Rick Macklem Date: Fri, 29 Aug 2025 07:43:22 -0700 X-Gm-Features: Ac12FXwU5rSKU7pJBEy82uBf-iyJPrMmYowpWj3WZjmKJwmYex5fosej_7u2HrY Message-ID: Subject: Re: heimdal -> MIT kdc migration To: Gleb Smirnoff Cc: Cy Schubert , freebsd-current@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: --- X-Spamd-Result: default: False [-3.99 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.99)[-0.993]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20230601]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36:c]; MIME_GOOD(-0.10)[text/plain]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; RCVD_TLS_LAST(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TAGGED_FROM(0.00)[]; TO_DN_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; MISSING_XM_UA(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; MID_RHS_MATCH_FROMTLD(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; MLMMJ_DEST(0.00)[freebsd-current@freebsd.org]; RCVD_COUNT_ONE(0.00)[1]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::52d:from]; FREEMAIL_ENVFROM(0.00)[gmail.com] X-Rspamd-Queue-Id: 4cD1H151JBz3r1r On Wed, Aug 27, 2025 at 8:39=E2=80=AFPM Rick Macklem wrote: > > On Wed, Aug 27, 2025 at 7:43=E2=80=AFPM Rick Macklem wrote: > > > > On Tue, Aug 26, 2025 at 9:35=E2=80=AFAM Gleb Smirnoff wrote: > > > > > > On Tue, Aug 26, 2025 at 08:31:13AM -0700, Gleb Smirnoff wrote: > > > T> On Tue, Aug 26, 2025 at 08:13:26AM -0700, Rick Macklem wrote: > > > T> R> Ok. If you install FreeBSD-13.5 and then "pkg install heimdal",= you get a > > > T> R> working Heimdal-7.8 in ports. > > > T> R> > > > T> R> Now, I have another challenge. Fixing the master passwords. > > > T> R> I'll work on it later to-day. > > > T> > > > T> I have applied two commits from Heimdal from 2012 that add 'kadmin= dump -f MIT' > > > T> feature to our base heimdal and polished them to compile. So far = it doesn't > > > T> work yet, either create an empty dump or create a core dump, inste= ad of > > > T> database dump :) I'll see how difficult it is going to further res= olve that to > > > T> a working condition. If I succeed, then having 'dump -f MIT' in ba= se without > > > T> any ports would be the best solution. Can also be merged to FreeB= SD 14.4. > > > > > > Good news. In the above paragraph I was testing my change incorrectl= y - threw > > > the new binary on a system running unpatched libraries. When run cor= rectly, > > > it successfully produced something that looks like a correct dump in = MIT format. > > > I haven't yet tried to load it into MIT kdc yet, though. > Oh, and one more thing... > - If there are keys for old encryption types like des.. or arcfour.. > in the MIT dump, > those will screw up the load. (You can check and delete them in the > Heimdal-1.5.2 > kdc system via.. > # kadmin -l > get > - if old keys are listed in Keytypes: > del_enctype > exit > > Ideally the conversion code would skip over these and not put them in th= e dump. > > rick > ps: If you don't do this, when you "get_principal" in kadmin.local on > the MIT KDC > system, it will give you a "Database record is incomplete or corrup= ted..". > > > > > > > I will finalize the branch promptly and share it. The above experien= ce also > > > indicated that I need to do a library version bump. > > I don't know if you are enthusiastic about pursuing this, but hopefully= this > > works and gets the principals in (although I doubt the passwords will > > work without changing them). > > > > To get the passwords to work, I think the following *might* do it: > > - If you look in the Heimdal sources, when "--decrypt" is specified, > > I think it finds its way down into a function called hdb_unseal_key_m= key() > > which decrypts the key using the master key by calling _hdb_mkey_decr= ypt(). > > To get the passwords to work, I think the call to _hdb_mkey_decrypt()= would > > need to be followed by a call to _hdb_mkey_encrypt() with the "key" > > argument being the master key for the MIT database. (It it a keytab > > entry called /var/db/krb5kdc/.k5.YOUR.REALM created when you do a > > "kdb5_util create -s" on the system that will be the MIT KDC.) > > - Just to make it even more fun, there is a flag called HDB_KU_MKEY > > which is set to the Heimdal way and not for the MIT way (whatever > > that really means?). > > - There is also some stuff about padding in hdb_unseal_key_mkey(), > > but hopefully that won't be a problem? > > > > I think hdb_read_master_key() can be used to read in the MIT master > > key from the file you provide as an argument to it. > > > > This all is just a hunch, based on what I've seen so far. > > > > I'll admit since the hardware I have takes forever to "make buildworld" > > and I don't know a quick way to build/test these changes, I'm not > > inspired to try it. Although not inspired, I have taken a stab at it. I am still trying to figure out how to build/test it, but I have forked glebius@'s github and added some code to... - Not dump the weak encryption keys (they just cause MIT's kadmin.local to complain that the principal's database entry is corrupted. - If the argument to "kadmin -l dump" is "-f " instead of "-f MIT" it re-encrypts the keys in MIT's master key. (I hope that wil= l make the passwords work. (Basically, someone will "kdb5_util create -s" on the MIT KDC system and then copy the /var/db/krbkdc/.k5.YOUR.REALM file over to the Heimdal KDC system and do "kadmin -l dump -f <.k5-filename> mit.dump" then copy "mit.dump" over to the MIT KDC system and "kdb5_util load -update mit.dump". Then, hopefully, the principals will work??) Anyhow, it is currently sitting here: github.com/rmacklem/FreeBSD in the kadmin-dump-MIT branch. (I'm as unconversant with git and github as anyone, so if you have trouble finding it, just let me know.) I'll keep updating this github fork as I get to test it, but if others know how to build it, feel free to test, rick > > > > rick > > > > > > > > -- > > > Gleb Smirnoff