Skip to content

Commit 5a0f7f5

Browse files
authored
[Profiler] Log information about secure-execution mode (#4196)
* Log information about secure-execution mode * Do not log user/group id
1 parent d789ad5 commit 5a0f7f5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

profiler/src/ProfilerEngine/Datadog.Profiler.Native/OpSysTools.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#define _GNU_SOURCE
2323
#include <errno.h>
2424
#include "cgroup.h"
25+
#include <sys/auxv.h>
2526
#endif
2627

2728
#include <chrono>
@@ -386,6 +387,17 @@ bool OpSysTools::IsSafeToStartProfiler(double coresThreshold)
386387
}
387388
}
388389

390+
// Check if process is running is a secure-execution mode
391+
auto at_secure = getauxval(AT_SECURE);
392+
Log::Info("Is process running in a secure execution mode ? ", std::boolalpha, at_secure);
393+
// Reasons for which AT_SECURE is true:
394+
// User ID != Effective User ID
395+
Log::Info("Process User ID differs from Effective User ID ? ", std::boolalpha, getuid() != geteuid());
396+
// Group ID != Effective Group ID
397+
Log::Info("Process Group ID differs from Effective Group ID ? ", std::boolalpha, getgid() != getegid());
398+
// TODO check capabilities (for now checking capabilities requires additional packages/libraries)
399+
// if at_secure is true, we know that it due to the capabilities
400+
389401
return false;
390402
}
391403

0 commit comments

Comments
 (0)