aboutsummaryrefslogtreecommitdiff
path: root/www/chromium/files/patch-base_base__paths__posix.cc
diff options
context:
space:
mode:
Diffstat (limited to 'www/chromium/files/patch-base_base__paths__posix.cc')
-rw-r--r--www/chromium/files/patch-base_base__paths__posix.cc98
1 files changed, 98 insertions, 0 deletions
diff --git a/www/chromium/files/patch-base_base__paths__posix.cc b/www/chromium/files/patch-base_base__paths__posix.cc
new file mode 100644
index 000000000000..e4e467db6322
--- /dev/null
+++ b/www/chromium/files/patch-base_base__paths__posix.cc
@@ -0,0 +1,98 @@
+--- base/base_paths_posix.cc.orig 2022-02-07 13:39:41 UTC
++++ base/base_paths_posix.cc
+@@ -15,6 +15,7 @@
+ #include <ostream>
+ #include <string>
+
++#include "base/command_line.h"
+ #include "base/environment.h"
+ #include "base/files/file_path.h"
+ #include "base/files/file_util.h"
+@@ -25,9 +26,13 @@
+ #include "base/process/process_metrics.h"
+ #include "build/build_config.h"
+
+-#if defined(OS_FREEBSD)
++#if defined(OS_BSD)
+ #include <sys/param.h>
+ #include <sys/sysctl.h>
++#if defined(OS_OPENBSD)
++#include <kvm.h>
++#define MAXTOKENS 2
++#endif
+ #elif defined(OS_SOLARIS) || defined(OS_AIX)
+ #include <stdlib.h>
+ #endif
+@@ -68,13 +73,65 @@ bool PathProviderPosix(int key, FilePath* result) {
+ *result = FilePath(bin_dir);
+ return true;
+ #elif defined(OS_OPENBSD) || defined(OS_AIX)
+- // There is currently no way to get the executable path on OpenBSD
+- char* cpath;
+- if ((cpath = getenv("CHROME_EXE_PATH")) != NULL)
+- *result = FilePath(cpath);
+- else
+- *result = FilePath("/usr/local/chrome/chrome");
+- return true;
++ char *cpath;
++#if !defined(OS_AIX)
++ struct kinfo_file *files;
++ kvm_t *kd = NULL;
++ char errbuf[_POSIX2_LINE_MAX];
++ static char retval[PATH_MAX];
++ int cnt;
++ struct stat sb;
++ pid_t cpid = getpid();
++ bool ret = false;
++
++ const base::CommandLine* command_line =
++ base::CommandLine::ForCurrentProcess();
++
++ VLOG(1) << "PathProviderPosix argv: " << command_line->argv()[0];
++
++ if (realpath(command_line->argv()[0].c_str(), retval) == NULL)
++ goto out;
++
++ if (stat(command_line->argv()[0].c_str(), &sb) < 0)
++ goto out;
++
++ if (!command_line->HasSwitch("no-sandbox")) {
++ ret = true;
++ *result = FilePath(retval);
++ VLOG(1) << "PathProviderPosix (sandbox) result: " << retval;
++ goto out;
++ }
++
++ if ((kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf)) == NULL)
++ goto out;
++
++ if ((files = kvm_getfiles(kd, KERN_FILE_BYPID, cpid,
++ sizeof(struct kinfo_file), &cnt)) == NULL)
++ goto out;
++
++ for (int i = 0; i < cnt; i++) {
++ if (files[i].fd_fd == KERN_FILE_TEXT &&
++ files[i].va_fsid == static_cast<uint32_t>(sb.st_dev) &&
++ files[i].va_fileid == sb.st_ino) {
++ ret = true;
++ *result = FilePath(retval);
++ VLOG(1) << "PathProviderPosix result: " << retval;
++ }
++ }
++out:
++ if (kd)
++ kvm_close(kd);
++ if (!ret) {
++#endif
++ if ((cpath = getenv("CHROME_EXE_PATH")) != NULL)
++ *result = FilePath(cpath);
++ else
++ *result = FilePath("/usr/local/chrome/chrome");
++ return true;
++#if !defined(OS_AIX)
++ }
++ return ret;
++#endif
+ #endif
+ }
+ case DIR_SRC_TEST_DATA_ROOT: {