summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Tancsa <mike@sentex.net>2017-03-31 17:50:35 -0300
committerQuentin Young <qlyoung@users.noreply.github.com>2017-04-01 00:50:40 -0400
commit7e5b53972233b6aea593397ed8fb8f55068eadaf (patch)
treea7caf57de08ad3f3dc0735c423905b0ae134112e
parent98b506c210fc9b8a1336ab36359ca79826a3f785 (diff)
lib: fix usage of getgrouplist() in *BSD
On BSD systems, the getgrouplist() function returns 0 if successful and -1 on error. Linux in the other hand returns *ngroups (the number of groups of which user is a member) on success and -1 on error. Given this difference, the most portable way to use getgrouplist() is use its return value only for checking if it succeeded or not. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
-rw-r--r--lib/privs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/privs.c b/lib/privs.c
index 376d6f3365..decd4bb7db 100644
--- a/lib/privs.c
+++ b/lib/privs.c
@@ -731,7 +731,7 @@ zprivs_init(struct zebra_privs_t *zprivs)
if (zprivs->user)
{
ngroups = sizeof(groups);
- if ( (ngroups = getgrouplist (zprivs->user, zprivs_state.zgid, groups, &ngroups )) < 0 )
+ if (getgrouplist (zprivs->user, zprivs_state.zgid, groups, &ngroups) < 0)
{
/* cant use log.h here as it depends on vty */
fprintf (stderr, "privs_init: could not getgrouplist for user %s\n",