Skip to content

Commit 56c71d0

Browse files
markjdbfluffykhv
authored andcommitted
security/ca_root_nss: Make unprivileged installation possible
The post-install and post-deinstall scripts simply invoke "certctl rehash", which of course requires root privileges. Modify them to enable unprivileged installation, useful for building VM images. For instance, FreeBSD's EC2 image builder wants to install amazon-ssm-agent, which depends on ca_root_nss. Modify the scripts to: 1. Use PKG_ROOTDIR as the root instead of assuming the default. 2. When installing, and PKG_METALOG is set, assume we're doing an unprivileged build and tell certctl to write updates to the configured METALOG. Note, the use of PKG_METALOG depends on a new pkg feature: freebsd/pkg#2476 If an updated ca_root_nss is installed using an old pkg(8), then the PKG_METALOG variable will not be set, so there are no compatibility issues. Sponsored by: The FreeBSD Foundation Sponsored by: Klara, Inc. PR: 288243
1 parent 3c49708 commit 56c71d0

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

‎security/ca_root_nss/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PORTNAME= ca_root_nss
22
PORTVERSION= ${VERSION_NSS}
3-
PORTREVISION= 2
3+
PORTREVISION= 3
44
CATEGORIES= security
55
MASTER_SITES= MOZILLA/security/nss/releases/${DISTNAME:tu:C/[-.]/_/g}_RTM/src
66
DISTNAME= nss-${VERSION_NSS}${NSS_SUFFIX}
@@ -34,7 +34,7 @@ VERSION_NSS= 3.115
3434
CERTDATA_TXT_PATH= lib/ckfw/builtins/certdata.txt
3535
BUNDLE_PROCESSOR= MAca-bundle.pl
3636

37-
SUB_FILES= MAca-bundle.pl pkg-message
37+
SUB_FILES= MAca-bundle.pl pkg-deinstall pkg-install pkg-message
3838
SUB_LIST= VERSION_NSS=${VERSION_NSS}
3939

4040
do-build:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
if [ "$2" = POST-DEINSTALL ]; then
4+
CERTCTL_ARGS="-D ${PKG_ROOTDIR}"
5+
certctl ${CERTCTL_ARGS} rehash
6+
fi
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
if [ "$2" = POST-INSTALL ]; then
4+
CERTCTL_ARGS="-D ${PKG_ROOTDIR}"
5+
if [ -n "${PKG_METALOG}" ]; then
6+
CERTCTL_ARGS="${CERTCTL_ARGS} -U -M ${PKG_METALOG}"
7+
fi
8+
certctl ${CERTCTL_ARGS} rehash
9+
10+
[ ! -e %%LOCALBASE%%/bin/cert-sync ] || \
11+
%%LOCALBASE%%/bin/cert-sync --quiet %%PREFIX%%/share/certs/ca-root-nss.crt
12+
fi

‎security/ca_root_nss/pkg-plist‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,3 @@
22
@sample etc/ssl/cert.pem.sample
33
%%ETCSYMLINK%%openssl/cert.pem
44
%%ETCSYMLINK%%/etc/ssl/cert.pem
5-
@postexec certctl rehash
6-
@postunexec certctl rehash
7-
@postexec [ ! -e %%LOCALBASE%%/bin/cert-sync ] || %%LOCALBASE%%/bin/cert-sync --quiet %%PREFIX%%/share/certs/ca-root-nss.crt

0 commit comments

Comments
 (0)