Skip to content

Commit 27fd16a

Browse files
federico-sysdigpoiana
authored andcommitted
fix: Check the NNS user/group earlier
Signed-off-by: Federico Aponte <[email protected]>
1 parent 6567760 commit 27fd16a

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

userspace/libsinsp/user.cpp

+16-12
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,6 @@ scap_userinfo *sinsp_usergroup_manager::userinfo_map_insert(
240240
std::string_view home,
241241
std::string_view shell)
242242
{
243-
if(!name.empty() && (name[0] == '+' || name[0] == '-'))
244-
{
245-
// ignore NSS entries
246-
return nullptr;
247-
}
248-
249243
auto &usr = map[uid];
250244
usr.uid = uid;
251245
usr.gid = gid;
@@ -263,12 +257,6 @@ scap_groupinfo *sinsp_usergroup_manager::groupinfo_map_insert(
263257
uint32_t gid,
264258
std::string_view name)
265259
{
266-
if(!name.empty() && (name[0] == '+' || name[0] == '-'))
267-
{
268-
// ignore NSS entries
269-
return nullptr;
270-
}
271-
272260
auto &grp = map[gid];
273261
grp.gid = gid;
274262
strlcpy(grp.name, (name.data() != nullptr) ? std::string(name).c_str() : "<NA>", MAX_CREDENTIALS_STR_LEN);
@@ -278,6 +266,14 @@ scap_groupinfo *sinsp_usergroup_manager::groupinfo_map_insert(
278266

279267
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)
280268
{
269+
// ignore NSS entries
270+
if(!name.empty() && (name[0] == '+' || name[0] == '-'))
271+
{
272+
libsinsp_logger()->format(sinsp_logger::SEV_DEBUG,
273+
"NSS user ignored: %.*s", static_cast<int>(name.length()), name.data());
274+
return nullptr;
275+
}
276+
281277
if (!m_import_users)
282278
{
283279
m_fallback_user.uid = uid;
@@ -413,6 +409,14 @@ bool sinsp_usergroup_manager::rm_user(const string &container_id, uint32_t uid,
413409

414410
scap_groupinfo *sinsp_usergroup_manager::add_group(const string &container_id, int64_t pid, uint32_t gid, std::string_view name, bool notify)
415411
{
412+
// ignore NSS entries
413+
if(!name.empty() && (name[0] == '+' || name[0] == '-'))
414+
{
415+
libsinsp_logger()->format(sinsp_logger::SEV_DEBUG,
416+
"NSS group ignored: %.*s", static_cast<int>(name.length()), name.data());
417+
return nullptr;
418+
}
419+
416420
if (!m_import_users)
417421
{
418422
m_fallback_grp.gid = gid;

0 commit comments

Comments
 (0)