logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: fa612dee642cdeebfb9f6892257c62bbdfdf676f
parent 15907c2898039d17ce812a712fccabfb8403a5e4
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon, 14 Mar 2022 21:36:19 +0100

bin/id.c: FreeBSD fix for getgrouplist return code

Diffstat:

Mbin/id.c8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/bin/id.c b/bin/id.c @@ -28,6 +28,7 @@ simple_list_groups(struct passwd *pw) // getgrouplist(3) BSD extension might not be in all Unixes int grls = getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups); + // note: FreeBSD returns 0 on success if(grls < 0) { goto failure; @@ -92,7 +93,8 @@ list_groups(struct passwd *pw) // getgrouplist(3) BSD extension might not be in all Unixes int grls = getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups); - if(grls > 0) + // note: FreeBSD returns 0 on success + if(grls >= 0) { printf(" groups="); @@ -357,7 +359,9 @@ main(int argc, char *argv[]) if(real_flag) { ret = simple_list_groups(&pw); - } else { + } + else + { ret = simple_list_groups(&epw); }