Skip to content

Commit

Permalink
[Profiler] Log information about secure-execution mode (#4196)
Browse files Browse the repository at this point in the history
* Log information about secure-execution mode
* Do not log user/group id
  • Loading branch information
gleocadie authored May 30, 2023
1 parent d789ad5 commit 5a0f7f5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions profiler/src/ProfilerEngine/Datadog.Profiler.Native/OpSysTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#define _GNU_SOURCE
#include <errno.h>
#include "cgroup.h"
#include <sys/auxv.h>
#endif

#include <chrono>
Expand Down Expand Up @@ -386,6 +387,17 @@ bool OpSysTools::IsSafeToStartProfiler(double coresThreshold)
}
}

// Check if process is running is a secure-execution mode
auto at_secure = getauxval(AT_SECURE);
Log::Info("Is process running in a secure execution mode ? ", std::boolalpha, at_secure);
// Reasons for which AT_SECURE is true:
// User ID != Effective User ID
Log::Info("Process User ID differs from Effective User ID ? ", std::boolalpha, getuid() != geteuid());
// Group ID != Effective Group ID
Log::Info("Process Group ID differs from Effective Group ID ? ", std::boolalpha, getgid() != getegid());
// TODO check capabilities (for now checking capabilities requires additional packages/libraries)
// if at_secure is true, we know that it due to the capabilities

return false;
}

Expand Down

0 comments on commit 5a0f7f5

Please sign in to comment.