mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-26 00:05:34 -04:00
Refactor Tools::disableCoreDumps().
- Use all available methods. - Don't print a warning when no method is implmeneted on the platform.
This commit is contained in:
parent
68373730bf
commit
a8bf6a9782
1 changed files with 13 additions and 9 deletions
|
@ -39,10 +39,12 @@
|
||||||
|
|
||||||
#include "config-keepassx.h"
|
#include "config-keepassx.h"
|
||||||
|
|
||||||
|
#if defined(HAVE_RLIMIT_CORE)
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_PR_SET_DUMPABLE)
|
#if defined(HAVE_PR_SET_DUMPABLE)
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
#elif defined(HAVE_RLIMIT_CORE)
|
|
||||||
#include <sys/resource.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_PT_DENY_ATTACH
|
#ifdef HAVE_PT_DENY_ATTACH
|
||||||
|
@ -222,21 +224,23 @@ QString platform()
|
||||||
|
|
||||||
void disableCoreDumps()
|
void disableCoreDumps()
|
||||||
{
|
{
|
||||||
bool success = false;
|
// default to true
|
||||||
|
// there is no point in printing a warning if this is not implemented on the platform
|
||||||
|
bool success = true;
|
||||||
|
|
||||||
// prefer PR_SET_DUMPABLE since that also prevents ptrace
|
#if defined(HAVE_RLIMIT_CORE)
|
||||||
#if defined(HAVE_PR_SET_DUMPABLE)
|
|
||||||
success = (prctl(PR_SET_DUMPABLE, 0) == 0);
|
|
||||||
#elif defined(HAVE_RLIMIT_CORE)
|
|
||||||
struct rlimit limit;
|
struct rlimit limit;
|
||||||
limit.rlim_cur = 0;
|
limit.rlim_cur = 0;
|
||||||
limit.rlim_max = 0;
|
limit.rlim_max = 0;
|
||||||
success = (setrlimit(RLIMIT_CORE, &limit) == 0);
|
success = success && (setrlimit(RLIMIT_CORE, &limit) == 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_PR_SET_DUMPABLE)
|
||||||
|
success = success && (prctl(PR_SET_DUMPABLE, 0) == 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Mac OS X
|
// Mac OS X
|
||||||
#ifdef HAVE_PT_DENY_ATTACH
|
#ifdef HAVE_PT_DENY_ATTACH
|
||||||
// make sure setrlimit() and ptrace() succeeded
|
|
||||||
success = success && (ptrace(PT_DENY_ATTACH, 0, 0, 0) == 0);
|
success = success && (ptrace(PT_DENY_ATTACH, 0, 0, 0) == 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue