Skip to content

Commit

Permalink
libs: return from change_caps if no caps
Browse files Browse the repository at this point in the history
When called without caps/privs, just return from "change_caps"
instead of exiting - it's possible that a process may not need
privs, but a lib (for example) may use the api.

Signed-off-by: Mark Stapp <mjs@cisco.com>
  • Loading branch information
Mark Stapp committed Jan 31, 2025
1 parent de8f52b commit e13a448
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/privs.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,11 @@ int zprivs_change_caps(zebra_privs_ops_t op)
{
cap_flag_value_t cflag;

/* should be no possibility of being called without valid caps */
assert(zprivs_state.syscaps_p && zprivs_state.caps);
if (!(zprivs_state.syscaps_p && zprivs_state.caps))
exit(1);
/* Called without valid caps - just return. Not every daemon needs
* privs.
*/
if (zprivs_state.syscaps_p == NULL || zprivs_state.caps == NULL)
return 0;

if (op == ZPRIVS_RAISE)
cflag = CAP_SET;
Expand Down

0 comments on commit e13a448

Please sign in to comment.