]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Fix priviledge modification for vty group specified
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 8 Apr 2016 23:20:34 +0000 (19:20 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Sat, 9 Apr 2016 00:33:15 +0000 (20:33 -0400)
When attempting to switch runtime permissions over to
the correct group specified for the vty group, if the
user specified to run as does not have that vty group
then do warn about the issue and stop running

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reported-by: Thomas Martin <tmartincpp@gmail.com>
lib/privs.c

index 0ca8783dcc87826719b24201890ff1bea86b3248..e6d76b600b0d4122f223bfb01153500e93f6fff7 100644 (file)
@@ -664,6 +664,7 @@ zprivs_init(struct zebra_privs_t *zprivs)
   struct group *grentry = NULL;
   gid_t groups[NGROUPS_MAX];
   int i, ngroups = 0;
+  int found = 0;
 
   if (!zprivs)
     {
@@ -729,8 +730,17 @@ zprivs_init(struct zebra_privs_t *zprivs)
 
           for ( i = 0; i < ngroups; i++ )
             if ( groups[i] == zprivs_state.vtygrp )
-              break;
+              {
+                found++;
+                break;
+              }
 
+          if (!found)
+            {
+             fprintf (stderr, "privs_init: user(%s) is not part of vty group specified(%s)\n",
+                      zprivs->user, zprivs->vty_group);
+              exit (1);
+            }
           if ( i >= ngroups && ngroups < (int) ZEBRA_NUM_OF(groups) )
             {
               groups[i] = zprivs_state.vtygrp;