Created attachment 237674 [details] Git-formatted patch This has been found during Bug 267364. If user or group creation fails before the last element this goes unnoticed since the exit code isn't examined. Only the last exit code is taken into account. There is no point in creating a user when the group creation has failed. A Git-formatted patch has been attached. The patch also cleans up a few inconsistencies in the messages.
Over to maintainer
Port manager, can you have a look?
using `|| exit` is probably a bad idea, the script should probably use `set -e` instead.
(In reply to Mathieu Arnold from comment #3) This might be, but the behavior would then be consistent at least and fail fast.
(In reply to Mathieu Arnold from comment #3) The script uses already "set -e", but it does not work: https://github.com/freebsd/freebsd-ports/blob/a535111bd3362c3463253683afbf485ffd8762cc/Mk/Scripts/do-users-groups.sh#L5
Well, it works for the script, but not the generated script, the do-users-groups.sh script generates a script that is run by pkg when the package is installed. `set -e` needs to be added to the generated script.
Created attachment 240499 [details] Git-formatted patch Matthieu, agree with you. Here is an updated patch. Works in a test jail.
Well, as it turned out, the issue has been reported already seven years ago (!): https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=206951
Mathieu Arnold, the patch is, I hope, as you expect. Can you review?
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=4280a82efe69f5dc77a67394f7bd36095c74cd6c commit 4280a82efe69f5dc77a67394f7bd36095c74cd6c Author: Michael Osipov <michaelo@FreeBSD.org> AuthorDate: 2023-11-22 11:30:32 +0000 Commit: Michael Osipov <michaelo@FreeBSD.org> CommitDate: 2024-05-03 07:44:53 +0000 Mk/Scripts/do-users-groups.sh: Make users and groups creation fail-fast Fail fast when pw(8) fails to create a user or a group. Especially when it is not the last command in the pre-install script then the exit code will be 0 and the failure will go unnoticed. PR: 267384 Approved by: jrm (mentor) Differential Revision: https://reviews.freebsd.org/D42719 Mk/Scripts/do-users-groups.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)