Bug 290078 - Build of security/ca_root_nss results in leftover of cert files on 16-CURRENT
Summary: Build of security/ca_root_nss results in leftover of cert files on 16-CURRENT
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 16.0-CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Dag-Erling Smørgrav
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2025-10-07 19:45 UTC by Yasuhiro Kimura
Modified: 2026-06-12 05:37 UTC (History)
3 users (show)

See Also:
des: mfc-stable14-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yasuhiro Kimura freebsd_committer freebsd_triage 2025-10-07 19:45:25 UTC
Host: 16.0-CURRENT main-n280862-f19aea89abd8 amd64
Poudriere: 3.4.3
Jaile: Same as host
Ports tree: ports 9ab81a2c7468

On above conditions build of security/ca_root_nss results in leftover of cert files as below

----------------------------------------------------------------------
=>> Checking for extra files and directories
=>> Error: Files or directories left over:
/etc/ssl/certs/2ccbdda3.0
/etc/ssl/certs/9e654b62.0
/etc/ssl/certs/b0d5255e.0
=>> Error: Files or directories modified:
/etc/ssl/cert.pem size (224449, 229231)
build of security/ca_root_nss | ca_root_nss-3.115_3 ended at Wed Oct  8 04:34:45 JST 2025
build time: 00:00:07
!!! build failure encountered !!!
[00:00:10] Error: Build failed in phase: leftovers
[00:00:10] Logs: /usr/local/poudriere/data/logs/bulk/curamd64-default/2025-10-08_04h34m35s
[00:00:10] Cleaning up
[00:00:10] Unmounting file systems
----------------------------------------------------------------------

On 13.5-RELEASE amd64 and 14.3-RELEASE amd64 leftover doesn't happen.

According to result of bisect, leftover starts with following commit.

----------------------------------------------------------------------
commit c340ef28fd38
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: Mon Aug 18 23:26:29 2025
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: Mon Aug 18 23:28:29 2025

    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.
      This allows e.g. Unbound to preload the bundle before chrooting.
    
    * 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.
    
    * We now also have tests.
    
    Reviewed by:    kevans, markj
    Differential Revision:  https://reviews.freebsd.org/D42320
    Differential Revision:  https://reviews.freebsd.org/D51896
----------------------------------------------------------------------

So it seems something is wrong with C version of certctl.

Cc-ing committer of base c340ef28fd38.
Comment 1 commit-hook freebsd_committer freebsd_triage 2026-05-05 22:31:42 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=2fef18ff594328a771b6aa659e8ffa5a7e076540

commit 2fef18ff594328a771b6aa659e8ffa5a7e076540
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-05-05 22:30:52 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-05-05 22:30:52 +0000

    certctl: Unstickify (un)trusted certificates

    Ever since certctl was rewritten in C, the rehash command has reingested
    TRUSTDESTDIR / UNTRUSTDESTDIR in addition to TRUSTPATH / UNTRUSTPATH.
    This seemed like a good idea at the time but was, in retrospect, a
    mistake, as it means a (un)trusted certificate remains (un)trusted
    forever (or at least until it expires) even if it is removed from
    (UN)TRUSTPATH.  Among other issues, it causes ports QA to fail for any
    port that either installs certificates or depends on a port that does.

    Although this behavior was undocumented, the change may surprise users
    who have added certificates manually, so update the manual page to point
    it out and add prominent warnings to the trust and untrust commands.

    PR:             290078
    MFC after:      1 week
    Reviewed by:    kevans, bcr
    Differential Revision:  https://reviews.freebsd.org/D56617

 usr.sbin/certctl/certctl.8             | 15 ++++++-
 usr.sbin/certctl/certctl.c             | 81 ++++++++++++++++++++++------------
 usr.sbin/certctl/tests/certctl_test.sh |  3 +-
 3 files changed, 67 insertions(+), 32 deletions(-)
Comment 2 commit-hook freebsd_committer freebsd_triage 2026-05-07 18:59:58 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=c65e233a52c61bf24fb935d1971e38fbde10791d

commit c65e233a52c61bf24fb935d1971e38fbde10791d
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-05-05 22:30:52 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-05-07 18:48:10 +0000

    certctl: Unstickify (un)trusted certificates

    Ever since certctl was rewritten in C, the rehash command has reingested
    TRUSTDESTDIR / UNTRUSTDESTDIR in addition to TRUSTPATH / UNTRUSTPATH.
    This seemed like a good idea at the time but was, in retrospect, a
    mistake, as it means a (un)trusted certificate remains (un)trusted
    forever (or at least until it expires) even if it is removed from
    (UN)TRUSTPATH.  Among other issues, it causes ports QA to fail for any
    port that either installs certificates or depends on a port that does.

    Although this behavior was undocumented, the change may surprise users
    who have added certificates manually, so update the manual page to point
    it out and add prominent warnings to the trust and untrust commands.

    PR:             290078
    MFC after:      1 week
    Reviewed by:    kevans, bcr
    Differential Revision:  https://reviews.freebsd.org/D56617

    (cherry picked from commit 2fef18ff594328a771b6aa659e8ffa5a7e076540)

 usr.sbin/certctl/certctl.8             | 15 ++++++-
 usr.sbin/certctl/certctl.c             | 81 ++++++++++++++++++++++------------
 usr.sbin/certctl/tests/certctl_test.sh |  3 +-
 3 files changed, 67 insertions(+), 32 deletions(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2026-05-07 20:20:08 UTC
A commit in branch releng/15.1 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=cef90b4386354618126925716cbadff6b1961a2e

commit cef90b4386354618126925716cbadff6b1961a2e
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-05-05 22:30:52 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2026-05-07 20:18:58 +0000

    certctl: Unstickify (un)trusted certificates

    Ever since certctl was rewritten in C, the rehash command has reingested
    TRUSTDESTDIR / UNTRUSTDESTDIR in addition to TRUSTPATH / UNTRUSTPATH.
    This seemed like a good idea at the time but was, in retrospect, a
    mistake, as it means a (un)trusted certificate remains (un)trusted
    forever (or at least until it expires) even if it is removed from
    (UN)TRUSTPATH.  Among other issues, it causes ports QA to fail for any
    port that either installs certificates or depends on a port that does.

    Although this behavior was undocumented, the change may surprise users
    who have added certificates manually, so update the manual page to point
    it out and add prominent warnings to the trust and untrust commands.

    Approved by:    re (cperciva)
    PR:             290078
    MFC after:      1 week
    Reviewed by:    kevans, bcr
    Differential Revision:  https://reviews.freebsd.org/D56617

    (cherry picked from commit 2fef18ff594328a771b6aa659e8ffa5a7e076540)
    (cherry picked from commit c65e233a52c61bf24fb935d1971e38fbde10791d)

 usr.sbin/certctl/certctl.8             | 15 ++++++-
 usr.sbin/certctl/certctl.c             | 81 ++++++++++++++++++++++------------
 usr.sbin/certctl/tests/certctl_test.sh |  3 +-
 3 files changed, 67 insertions(+), 32 deletions(-)