mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Add support to get process name on FreeBSD
This commit is contained in:
parent
c0b71126bd
commit
af4bc3e194
@ -26,6 +26,11 @@
|
|||||||
#include "core/Entry.h"
|
#include "core/Entry.h"
|
||||||
#include "core/Tools.h"
|
#include "core/Tools.h"
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace FdoSecrets
|
namespace FdoSecrets
|
||||||
{
|
{
|
||||||
static const auto IntrospectionService = R"xml(
|
static const auto IntrospectionService = R"xml(
|
||||||
@ -175,7 +180,18 @@ namespace FdoSecrets
|
|||||||
|
|
||||||
// The /proc/pid/exe link is more reliable than /proc/pid/cmdline
|
// The /proc/pid/exe link is more reliable than /proc/pid/cmdline
|
||||||
// It's still weak and if the application does a prctl(PR_SET_DUMPABLE, 0) this link cannot be accessed.
|
// It's still weak and if the application does a prctl(PR_SET_DUMPABLE, 0) this link cannot be accessed.
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
const int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, static_cast<int>(info.pid)};
|
||||||
|
char buffer[2048];
|
||||||
|
size_t size = sizeof(buffer);
|
||||||
|
if (sysctl(mib, 4, buffer, &size, NULL, 0) != 0) {
|
||||||
|
strlcpy(buffer, "Invalid path", sizeof(buffer));
|
||||||
|
}
|
||||||
|
QFileInfo exe(buffer);
|
||||||
|
#else
|
||||||
QFileInfo exe(QStringLiteral("/proc/%1/exe").arg(pid));
|
QFileInfo exe(QStringLiteral("/proc/%1/exe").arg(pid));
|
||||||
|
#endif
|
||||||
info.exePath = exe.canonicalFilePath();
|
info.exePath = exe.canonicalFilePath();
|
||||||
|
|
||||||
// /proc/pid/cmdline gives full command line
|
// /proc/pid/cmdline gives full command line
|
||||||
|
Loading…
Reference in New Issue
Block a user