m_cap Add Capability::OnList() hook

This commit is contained in:
Attila Molnar 2015-12-05 15:42:04 +01:00
parent 53b9f55c18
commit 3e08629e83
2 changed files with 13 additions and 0 deletions

View File

@ -199,5 +199,15 @@ namespace Cap
{
return true;
}
/** Called when a user requests a list of all capabilities and this capability is about to be included in the list.
* The default behavior always includes the cap in the list.
* @param user User querying a list capabilities
* @return True to add this cap to the list sent to the user, false to not list it
*/
virtual bool OnList(LocalUser* user)
{
return true;
}
};
}

View File

@ -149,6 +149,9 @@ class Cap::ManagerImpl : public Cap::Manager
if (!(show_caps & cap->GetMask()))
continue;
if ((show_all) && (!cap->OnList(user)))
continue;
if (minus_prefix)
out.push_back('-');
out.append(cap->GetName()).push_back(' ');