Monday, May 28, 2018

Add @newuser/@newgroup checks to portcheck

This adds @newuser/@newgroup validation to portcheck, based on user.list.

While the first check (about user/group being registered) should be okay,
the second one probably needs some bikeshedding: now complex ports like
net/icinga will start spewing warnings because, in case of icinga, both
net/icinga/core and net/icinga/core2 install same user/group.

So what way do you want this: with or without pkgpath checking?

--
WBR,
Vadim Zhukov


Index: portcheck
===================================================================
RCS file: /cvs/ports/infrastructure/bin/portcheck,v
retrieving revision 1.117
diff -u -p -r1.117 portcheck
--- portcheck 22 Dec 2017 22:59:53 -0000 1.117
+++ portcheck 28 May 2018 17:25:08 -0000
@@ -733,11 +733,12 @@ check_port_dir() {
fi
fi

+ pkgpath=${pkgpath:-"$pkgpath_this"}
+
for _s in $multi_packages; do
sub_checks "$dir" "$_s" "${check_flavors[@]}"
done

- pkgpath=${pkgpath:-"$pkgpath_this"}
last_subst_cmd="$subst_cmd"
}

@@ -1014,7 +1015,7 @@ check_plist() {
local readme_seen=false

# Temporary ones
- local app l theme varname py
+ local app l theme varname py id who userline

while read -pr l; do
case "$l" in
@@ -1216,6 +1217,21 @@ check_plist() {
;;
"@man "*.gz)
err "${portref}compressed $l"
+ ;;
+
+ # N.B.: The user.list could miss either user or group part
+ "@newuser "*|"@newgroup "*)
+ who=$l
+ who=${l#*[[:space:]]}
+ id=${who#*:}
+ id=${id%%:*}
+ who=${who%%:*}
+ userline="$(awk "/^$id[[:space:]]/ && \$2 == \"$who\"" $portsdir/infrastructure/db/user.list)"
+ if [ -z "$userline" ]; then
+ err "${portref}$l is not registered in db/user.list"
+ elif [ "${pkgpath%%,*}" != "${userline##*[[:space:]]}" ]; then
+ err "${portref}$l pkgpath mismatch in db/user.list"
+ fi
;;

@owner)

No comments:

Post a Comment