aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/zenserver.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-05-08 18:40:53 +0200
committerGitHub <[email protected]>2023-05-08 18:40:53 +0200
commita2e393d27f9b8245b39ad2e38c82986b05cebf6a (patch)
tree6c100f553ba3f11509dc72fce660cb73f6caa243 /src/zenserver/zenserver.cpp
parentproject store gc lifetime (#257) (diff)
downloadzen-a2e393d27f9b8245b39ad2e38c82986b05cebf6a.tar.xz
zen-a2e393d27f9b8245b39ad2e38c82986b05cebf6a.zip
add ip and username to sentry reports if allowed in settings (#276)
* add ip and username to sentry reports if allowed in settings * add --sentry-allow-personal-info command line options to zenserver
Diffstat (limited to 'src/zenserver/zenserver.cpp')
-rw-r--r--src/zenserver/zenserver.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp
index 03c44c0ca..75a49367c 100644
--- a/src/zenserver/zenserver.cpp
+++ b/src/zenserver/zenserver.cpp
@@ -25,6 +25,14 @@
# include <zencore/windows.h>
#endif
+#if ZEN_PLATFORM_LINUX
+# include <pwd.h>
+#endif
+
+#if ZEN_PLATFORM_MAC
+# include <pwd.h>
+#endif
+
#if ZEN_USE_MIMALLOC
ZEN_THIRD_PARTY_INCLUDES_START
# include <mimalloc-new-delete.h>
@@ -986,6 +994,31 @@ ZenEntryPoint::Run()
}
sentry_options_add_attachment(SentryOptions, SentryAttachmentPath.c_str());
sentry_options_set_release(SentryOptions, ZEN_CFG_VERSION);
+
+ if (m_ServerOptions.SentryAllowPII)
+ {
+ sentry_value_t user = sentry_value_new_object();
+
+# if ZEN_PLATFORM_WINDOWS
+ CHAR UserNameBuffer[511 + 1];
+ DWORD UserNameLength = sizeof(UserNameBuffer) / sizeof(CHAR);
+ BOOL OK = GetUserNameA(UserNameBuffer, &UserNameLength);
+ if (OK)
+ {
+ sentry_value_set_by_key(user, "username", sentry_value_new_string(UserNameBuffer));
+ }
+# endif // ZEN_PLATFORM_WINDOWS
+# if (ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC)
+ uid_t uid = geteuid();
+ struct passwd* pw = getpwuid(uid);
+ if (pw)
+ {
+ sentry_value_set_by_key(user, "username", sentry_value_new_string(pw->pw_name));
+ }
+# endif
+ sentry_value_set_by_key(user, "ip_address", sentry_value_new_string("{{auto}}"));
+ sentry_set_user(user);
+ }
// sentry_options_set_debug(SentryOptions, 1);
SentryErrorCode = sentry_init(SentryOptions);