Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Aug 2025 11:59:52 +0200
From:      Kristof Provost <kp@FreeBSD.org>
To:        =?utf-8?q?Dag-Erling_Sm=C3=B8rgrav?= <des@FreeBSD.org>
Cc:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   Re: git: 81d8827ad875 - main - certctl: Reimplement in C
Message-ID:  <5331736E-B67F-4B3C-A04A-54E7A5F88B07@FreeBSD.org>
In-Reply-To: <202508132225.57DMPlLZ083341@gitrepo.freebsd.org>
References:  <202508132225.57DMPlLZ083341@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--=_MailMate_E13A9DC5-543A-4DAC-AEC3-456857F598E0_=
Content-Type: text/plain; charset=UTF-8; format=flowed; markup=markdown
Content-Transfer-Encoding: quoted-printable

On 14 Aug 2025, at 0:25, Dag-Erling Sm=C3=B8rgrav wrote:
> The branch main has been updated by des:
>
> URL: =

> https://cgit.FreeBSD.org/src/commit/?id=3D81d8827ad8752e35411204541f1f0=
9df1481e417
>
> commit 81d8827ad8752e35411204541f1f09df1481e417
> Author:     Dag-Erling Sm=C3=B8rgrav <des@FreeBSD.org>
> AuthorDate: 2025-08-13 22:25:27 +0000
> Commit:     Dag-Erling Sm=C3=B8rgrav <des@FreeBSD.org>
> CommitDate: 2025-08-13 22:25:27 +0000
>
>     certctl: Reimplement in C
>
>     Notable changes include:
>
>     * We no longer forget manually untrusted certificates when =

> rehashing.
>
>     * Rehash will now scan the existing directory and progressively =

> replace
>       its contents with those of the new trust store.  The trust store =

> as a
>       whole is not replaced atomically, but each file within it is.
>
>     * We no longer attempt to link to the original files, but we don't =

> copy
>       them either.  Instead, we write each certificate out in its =

> minimal
>       form.
>
>     * We now generate a trust bundle in addition to the hashed =

> diretory.
>       This also contains only the minimal DER form of each =

> certificate.
>
>     * The C version is approximately two orders of magnitude faster =

> than the
>       sh version, with rehash taking ~100 ms vs ~5-25 s depending on =

> whether
>       ca_root_nss is installed.
>
>     * The DISTBASE concept has been dropped; the same effect can be =

> achieved
>       by adjusting DESTDIR.
>
>     * We now also have rudimentary tests.
>
>     Reviewed by:    kevans
>     Differential Revision:  https://reviews.freebsd.org/D42320

I=E2=80=99m seeing errors like this during bricoler test runs now:

> /usr/home/kp/bricoler/freebsd-src-regression-suite-vm-image/image.amd64=
=2Eamd64-METALOG.mtree:38358: =

> error: word too long to fit buffer (max 10 characters)

Those are all lines with absolute paths (e.g. /etc/ssl/cert.pem rather =

than ./etc/ssl/cert.pem).
This hack seems to fix things for me, but I=E2=80=99m nowhere near famili=
ar =

enough with the relevant build bits to say for sure if that=E2=80=99s rig=
ht or =

not:

	diff --git a/usr.sbin/certctl/certctl.c b/usr.sbin/certctl/certctl.c
	index 365870167aeb..336a49830a3d 100644
	--- a/usr.sbin/certctl/certctl.c
	+++ b/usr.sbin/certctl/certctl.c
	@@ -490,7 +490,7 @@ write_certs(const char *dir, struct cert_tree =

*tree)
	                }
	                /* emit metalog */
	                if (mlf !=3D NULL) {
	-                       fprintf(mlf, "%s/%s type=3Dfile "
	+                       fprintf(mlf, "./%s/%s type=3Dfile "
	                            "uname=3D%s gname=3D%s mode=3D%#o size=3D%ld=
\n",
	                            unexpand_path(dir), path,
	                            uname, gname, mode, ftell(f));
	@@ -561,7 +561,7 @@ write_bundle(const char *dir, const char *file, =

struct cert_tree *tree)
	        }
	        if (ret =3D=3D 0 && mlf !=3D NULL) {
	                fprintf(mlf,
	-                   "%s/%s type=3Dfile uname=3D%s gname=3D%s mode=3D%#o =

size=3D%ld\n",
	+                   "./%s/%s type=3Dfile uname=3D%s gname=3D%s mode=3D%#=
o =

size=3D%ld\n",
	                    unexpand_path(dir), file, uname, gname, mode, =

ftell(f));
	        }
	        fclose(f);

=E2=80=94
Kristof
--=_MailMate_E13A9DC5-543A-4DAC-AEC3-456857F598E0_=
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html>
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/xhtml; charset=3Dutf-8"=
>
</head>
<body><div style=3D"font-family: sans-serif;"><div class=3D"markdown" sty=
le=3D"white-space: normal;">
<p dir=3D"auto">On 14 Aug 2025, at 0:25, Dag-Erling Sm=C3=B8rgrav wrote:<=
/p>
<blockquote style=3D"margin: 0 0 5px; padding-left: 5px; border-left: 2px=
 solid #136BCE; color: #136BCE;">
<p dir=3D"auto">The branch main has been updated by des:</p>
<p dir=3D"auto">URL: <a href=3D"https://cgit.FreeBSD.org/src/commit/?id=3D=
81d8827ad8752e35411204541f1f09df1481e417">https://cgit.FreeBSD.org/src/co=
mmit/?id=3D81d8827ad8752e35411204541f1f09df1481e417</a></p>
<p dir=3D"auto">commit 81d8827ad8752e35411204541f1f09df1481e417<br>
Author:     Dag-Erling Sm=C3=B8rgrav <a href=3D"mailto:des@FreeBSD.org">d=
es@FreeBSD.org</a><br>
AuthorDate: 2025-08-13 22:25:27 +0000<br>
Commit:     Dag-Erling Sm=C3=B8rgrav <a href=3D"mailto:des@FreeBSD.org">d=
es@FreeBSD.org</a><br>
CommitDate: 2025-08-13 22:25:27 +0000</p>
<pre style=3D"margin-left: 15px; margin-right: 15px; padding: 5px; border=
: thin solid gray; overflow-x: auto; max-width: 90vw; background-color: #=
E4E4E4;"><code style=3D"padding: 0 0.25em; background-color: #E4E4E4;">ce=
rtctl: Reimplement in C

Notable changes include:

* We no longer forget manually untrusted certificates when rehashing.

* Rehash will now scan the existing directory and progressively replace
  its contents with those of the new trust store.  The trust store as a
  whole is not replaced atomically, but each file within it is.

* We no longer attempt to link to the original files, but we don't copy
  them either.  Instead, we write each certificate out in its minimal
  form.

* We now generate a trust bundle in addition to the hashed diretory.
  This also contains only the minimal DER form of each certificate.

* The C version is approximately two orders of magnitude faster than the
  sh version, with rehash taking ~100 ms vs ~5-25 s depending on whether
  ca_root_nss is installed.

* The DISTBASE concept has been dropped; the same effect can be achieved
  by adjusting DESTDIR.

* We now also have rudimentary tests.

Reviewed by:    kevans
Differential Revision:  https://reviews.freebsd.org/D42320
</code></pre>
</blockquote>
<p dir=3D"auto">I=E2=80=99m seeing errors like this during bricoler test =
runs now:</p>
<blockquote style=3D"margin: 0 0 5px; padding-left: 5px; border-left: 2px=
 solid #136BCE; color: #136BCE;">
<p dir=3D"auto">/usr/home/kp/bricoler/freebsd-src-regression-suite-vm-ima=
ge/image.amd64.amd64-METALOG.mtree:38358: error: word too long to fit buf=
fer (max 10 characters)</p>
</blockquote>
<p dir=3D"auto">Those are all lines with absolute paths (e.g. /etc/ssl/ce=
rt.pem rather than ./etc/ssl/cert.pem).<br>
This hack seems to fix things for me, but I=E2=80=99m nowhere near famili=
ar enough with the relevant build bits to say for sure if that=E2=80=99s =
right or not:</p>
<pre style=3D"margin-left: 15px; margin-right: 15px; padding: 5px; border=
: thin solid gray; overflow-x: auto; max-width: 90vw; background-color: #=
E4E4E4;"><code style=3D"padding: 0 0.25em; background-color: #E4E4E4;">di=
ff --git a/usr.sbin/certctl/certctl.c b/usr.sbin/certctl/certctl.c
index 365870167aeb..336a49830a3d 100644
--- a/usr.sbin/certctl/certctl.c
+++ b/usr.sbin/certctl/certctl.c
@@ -490,7 +490,7 @@ write_certs(const char *dir, struct cert_tree *tree)
                }
                /* emit metalog */
                if (mlf !=3D NULL) {
-                       fprintf(mlf, &quot;%s/%s type=3Dfile &quot;
+                       fprintf(mlf, &quot;./%s/%s type=3Dfile &quot;
                            &quot;uname=3D%s gname=3D%s mode=3D%#o size=3D=
%ld\n&quot;,
                            unexpand_path(dir), path,
                            uname, gname, mode, ftell(f));
@@ -561,7 +561,7 @@ write_bundle(const char *dir, const char *file, struc=
t cert_tree *tree)
        }
        if (ret =3D=3D 0 &amp;&amp; mlf !=3D NULL) {
                fprintf(mlf,
-                   &quot;%s/%s type=3Dfile uname=3D%s gname=3D%s mode=3D=
%#o size=3D%ld\n&quot;,
+                   &quot;./%s/%s type=3Dfile uname=3D%s gname=3D%s mode=3D=
%#o size=3D%ld\n&quot;,
                    unexpand_path(dir), file, uname, gname, mode, ftell(f=
));
        }
        fclose(f);
</code></pre>
<p dir=3D"auto">=E2=80=94<br>
Kristof</p>

</div>
</div>
</body>

</html>

--=_MailMate_E13A9DC5-543A-4DAC-AEC3-456857F598E0_=--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5331736E-B67F-4B3C-A04A-54E7A5F88B07>