diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/zenserver/config.cpp | 3 | ||||
| -rw-r--r-- | src/zenserver/config.h | 1 | ||||
| -rw-r--r-- | src/zenserver/zenserver.cpp | 33 |
3 files changed, 37 insertions, 0 deletions
diff --git a/src/zenserver/config.cpp b/src/zenserver/config.cpp index 08ef17c12..da0da2593 100644 --- a/src/zenserver/config.cpp +++ b/src/zenserver/config.cpp @@ -170,6 +170,9 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) options.add_options()("no-sentry", "Disable Sentry crash handler", cxxopts::value<bool>(ServerOptions.NoSentry)->default_value("false")); + options.add_options()("sentry-allow-personal-info", + "Allow personally identifiable information in sentry crash reports", + cxxopts::value<bool>(ServerOptions.SentryAllowPII)->default_value("false")); options.add_option("security", "", diff --git a/src/zenserver/config.h b/src/zenserver/config.h index 8a5c6de4e..9559cae33 100644 --- a/src/zenserver/config.h +++ b/src/zenserver/config.h @@ -148,6 +148,7 @@ struct ZenServerOptions bool ShouldCrash = false; // Option for testing crash handling bool IsFirstRun = false; bool NoSentry = false; + bool SentryAllowPII = false; // Allow personally identifiable information in sentry crash reports bool ObjectStoreEnabled = false; #if ZEN_WITH_TRACE std::string TraceHost; // Host name or IP address to send trace data to 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); |