git: 60334f077945 - main - sysutils/amazon-ssm-agent: Use pw(8)'s new metalog feature

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Thu, 09 Oct 2025 13:47:51 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/ports/commit/?id=60334f077945aee154a20ac65076f2bfd69dac9e

commit 60334f077945aee154a20ac65076f2bfd69dac9e
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-10-09 13:41:50 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-10-09 13:46:47 +0000

    sysutils/amazon-ssm-agent: Use pw(8)'s new metalog feature
    
    This allows the ssm-agent user to be created when installing as an
    unprivileged user.  That is, if the package is installed with pkg(8)'s
    METALOG option set, the home directory for ssm-agent will be added to
    the metalog.
    
    PR:             290080
    Approved by:    cperciva (maintainer)
    Sponsored by:   The FreeBSD Foundation
    Sponsored by:   Klara, Inc.
---
 sysutils/amazon-ssm-agent/pkg-install | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sysutils/amazon-ssm-agent/pkg-install b/sysutils/amazon-ssm-agent/pkg-install
index f42d5b710f72..743ffdd91a85 100644
--- a/sysutils/amazon-ssm-agent/pkg-install
+++ b/sysutils/amazon-ssm-agent/pkg-install
@@ -2,5 +2,9 @@
 
 if [ "$2" = "POST-INSTALL" ]; then
 	echo "Creating ssm-user for SSM Agent Sessions"
-	pw -R ${PKG_ROOTDIR} useradd ssm-user -G wheel -m
+	if [ -n "${PKG_METALOG}" ] && \
+	    pw useradd --help 2>&1 | grep -q -F -- '-M metalog'; then
+		METALOG="-M ${PKG_METALOG}"
+	fi
+	pw ${METALOG} -R ${PKG_ROOTDIR} useradd ssm-user -G wheel -m
 fi