Skip to content

Commit

Permalink
fix(userspace/libsinsp): solve user resolution issues with musl
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Dellaluce <[email protected]>
  • Loading branch information
jasondellaluce authored and poiana committed Oct 21, 2023
1 parent 3a41d14 commit faebb36
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions userspace/libsinsp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ if(NOT MSVC)
endif()
add_definitions(-DHAVE_PWD_H)
add_definitions(-DHAVE_GRP_H)
if(MUSL_OPTIMIZED_BUILD)
add_definitions(-DMUSL_OPTIMIZED)
endif()
endif()

if(NOT DEFINED CHISEL_TOOL_LIBRARY_NAME)
Expand Down
4 changes: 2 additions & 2 deletions userspace/libsinsp/test/user.ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ class usergroup_manager_host_root_test : public sinsp_with_test_input

{
std::ofstream ofs(etc + "/passwd");
ofs << "toor:x:0:0:toor:/toor:/bin/ash";
ofs << "toor:x:0:0:toor:/toor:/bin/ash" << std::endl;
ofs.close();
}
{
std::ofstream ofs(etc + "/group");
ofs << "toor:x:0:toor";
ofs << "toor:x:0:toor" << std::endl;
ofs.close();
}
}
Expand Down
2 changes: 1 addition & 1 deletion userspace/libsinsp/user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ limitations under the License.
// See fgetpwent() / fgetgrent() feature test macros:
// https://man7.org/linux/man-pages/man3/fgetpwent.3.html
// https://man7.org/linux/man-pages/man3/fgetgrent.3.html
#if defined _DEFAULT_SOURCE || defined _SVID_SOURCE
#if defined(MUSL_OPTIMIZED) || defined(_DEFAULT_SOURCE) || defined(_SVID_SOURCE)
#define HAVE_FGET__ENT
#endif

Expand Down

0 comments on commit faebb36

Please sign in to comment.