Skip to content

Commit

Permalink
fix: Check the NNS user/group earlier
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Aponte <[email protected]>
  • Loading branch information
federico-sysdig committed Jun 13, 2024
1 parent 9c622d3 commit f587800
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions userspace/libsinsp/user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,6 @@ scap_userinfo *sinsp_usergroup_manager::userinfo_map_insert(
std::string_view home,
std::string_view shell)
{
if(!name.empty() && (name[0] == '+' || name[0] == '-'))
{
// ignore NSS entries
return nullptr;
}

auto &usr = map[uid];
usr.uid = uid;
usr.gid = gid;
Expand All @@ -263,12 +257,6 @@ scap_groupinfo *sinsp_usergroup_manager::groupinfo_map_insert(
uint32_t gid,
std::string_view name)
{
if(!name.empty() && (name[0] == '+' || name[0] == '-'))
{
// ignore NSS entries
return nullptr;
}

auto &grp = map[gid];
grp.gid = gid;
strlcpy(grp.name, (name.data() != nullptr) ? std::string(name).c_str() : "<NA>", MAX_CREDENTIALS_STR_LEN);
Expand All @@ -278,6 +266,14 @@ scap_groupinfo *sinsp_usergroup_manager::groupinfo_map_insert(

scap_userinfo *sinsp_usergroup_manager::add_user(const std::string &container_id, int64_t pid, uint32_t uid, uint32_t gid, std::string_view name, std::string_view home, std::string_view shell, bool notify)
{
// ignore NSS entries
if(!name.empty() && (name[0] == '+' || name[0] == '-'))
{
libsinsp_logger()->format(sinsp_logger::SEV_DEBUG,
"NSS user ignored: %.*s", static_cast<int>(name.length()), name.data());
return nullptr;
}

if (!m_import_users)
{
m_fallback_user.uid = uid;
Expand Down Expand Up @@ -413,6 +409,14 @@ bool sinsp_usergroup_manager::rm_user(const string &container_id, uint32_t uid,

scap_groupinfo *sinsp_usergroup_manager::add_group(const string &container_id, int64_t pid, uint32_t gid, std::string_view name, bool notify)
{
// ignore NSS entries
if(!name.empty() && (name[0] == '+' || name[0] == '-'))
{
libsinsp_logger()->format(sinsp_logger::SEV_DEBUG,
"NSS group ignored: %.*s", static_cast<int>(name.length()), name.data());
return nullptr;
}

if (!m_import_users)
{
m_fallback_grp.gid = gid;
Expand Down

0 comments on commit f587800

Please sign in to comment.