fix: use shorter paths for creating singleton sockets (#31608)
This commit is contained in:
parent
e88a2955da
commit
3bf42593ba
2 changed files with 18 additions and 13 deletions
|
@ -61,7 +61,7 @@ index eec994c4252f17d9c9c41e66d5dae6509ed98a18..e538c9b76da4d4435e10cd3848438446
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
bool EscapeVirtualization(const base::FilePath& user_data_dir);
|
bool EscapeVirtualization(const base::FilePath& user_data_dir);
|
||||||
diff --git a/chrome/browser/process_singleton_posix.cc b/chrome/browser/process_singleton_posix.cc
|
diff --git a/chrome/browser/process_singleton_posix.cc b/chrome/browser/process_singleton_posix.cc
|
||||||
index 727333dd6abec99643e31bc77ed2cc8f3d5a0a0b..e5361397f78636816507355e7db6a9e55e6ed234 100644
|
index a04d139f958a7aaef9b96e8c29317ccf7c97f009..29188668a69047b3ad3bebd1f0057565a330b509 100644
|
||||||
--- a/chrome/browser/process_singleton_posix.cc
|
--- a/chrome/browser/process_singleton_posix.cc
|
||||||
+++ b/chrome/browser/process_singleton_posix.cc
|
+++ b/chrome/browser/process_singleton_posix.cc
|
||||||
@@ -567,6 +567,7 @@ class ProcessSingleton::LinuxWatcher
|
@@ -567,6 +567,7 @@ class ProcessSingleton::LinuxWatcher
|
||||||
|
|
|
@ -76,7 +76,7 @@ index 0d7c1db6489d95a40c66808c3f838b0740e46ff6..eec994c4252f17d9c9c41e66d5dae650
|
||||||
|
|
||||||
#if defined(OS_MAC)
|
#if defined(OS_MAC)
|
||||||
diff --git a/chrome/browser/process_singleton_posix.cc b/chrome/browser/process_singleton_posix.cc
|
diff --git a/chrome/browser/process_singleton_posix.cc b/chrome/browser/process_singleton_posix.cc
|
||||||
index 4547eb8563e1af57aad991d9d1e2cf02c778380a..727333dd6abec99643e31bc77ed2cc8f3d5a0a0b 100644
|
index 4547eb8563e1af57aad991d9d1e2cf02c778380a..a04d139f958a7aaef9b96e8c29317ccf7c97f009 100644
|
||||||
--- a/chrome/browser/process_singleton_posix.cc
|
--- a/chrome/browser/process_singleton_posix.cc
|
||||||
+++ b/chrome/browser/process_singleton_posix.cc
|
+++ b/chrome/browser/process_singleton_posix.cc
|
||||||
@@ -80,6 +80,7 @@
|
@@ -80,6 +80,7 @@
|
||||||
|
@ -171,7 +171,7 @@ index 4547eb8563e1af57aad991d9d1e2cf02c778380a..727333dd6abec99643e31bc77ed2cc8f
|
||||||
ProcessSingleton::NotifyResult
|
ProcessSingleton::NotifyResult
|
||||||
ProcessSingleton::NotifyOtherProcessWithTimeoutOrCreate(
|
ProcessSingleton::NotifyOtherProcessWithTimeoutOrCreate(
|
||||||
const base::CommandLine& command_line,
|
const base::CommandLine& command_line,
|
||||||
@@ -999,12 +1039,26 @@ bool ProcessSingleton::Create() {
|
@@ -999,14 +1039,32 @@ bool ProcessSingleton::Create() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,15 +180,15 @@ index 4547eb8563e1af57aad991d9d1e2cf02c778380a..727333dd6abec99643e31bc77ed2cc8f
|
||||||
- // do not support Unix domain sockets.
|
- // do not support Unix domain sockets.
|
||||||
- if (!socket_dir_.CreateUniqueTempDir()) {
|
- if (!socket_dir_.CreateUniqueTempDir()) {
|
||||||
- LOG(ERROR) << "Failed to create socket directory.";
|
- LOG(ERROR) << "Failed to create socket directory.";
|
||||||
- return false;
|
+ base::FilePath tmp_dir;
|
||||||
|
+ if (!base::GetTempDir(&tmp_dir)) {
|
||||||
|
+ LOG(ERROR) << "Failed to get temporary directory.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
+ if (IsAppSandboxed()) {
|
+ if (IsAppSandboxed()) {
|
||||||
+ // For sandboxed applications, the tmp dir could be too long to fit
|
+ // For sandboxed applications, the tmp dir could be too long to fit
|
||||||
+ // addr->sun_path, so we need to make it as short as possible.
|
+ // addr->sun_path, so we need to make it as short as possible.
|
||||||
+ base::FilePath tmp_dir;
|
|
||||||
+ if (!base::GetTempDir(&tmp_dir)) {
|
|
||||||
+ LOG(ERROR) << "Failed to get temporary directory.";
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ if (!socket_dir_.Set(tmp_dir.Append("S"))) {
|
+ if (!socket_dir_.Set(tmp_dir.Append("S"))) {
|
||||||
+ LOG(ERROR) << "Failed to set socket directory.";
|
+ LOG(ERROR) << "Failed to set socket directory.";
|
||||||
+ return false;
|
+ return false;
|
||||||
|
@ -197,14 +197,19 @@ index 4547eb8563e1af57aad991d9d1e2cf02c778380a..727333dd6abec99643e31bc77ed2cc8f
|
||||||
+ // Create the socket file somewhere in /tmp which is usually mounted as a
|
+ // Create the socket file somewhere in /tmp which is usually mounted as a
|
||||||
+ // normal filesystem. Some network filesystems (notably AFS) are screwy and
|
+ // normal filesystem. Some network filesystems (notably AFS) are screwy and
|
||||||
+ // do not support Unix domain sockets.
|
+ // do not support Unix domain sockets.
|
||||||
+ if (!socket_dir_.CreateUniqueTempDir()) {
|
+ // Prefer CreateUniqueTempDirUnderPath rather than CreateUniqueTempDir as
|
||||||
|
+ // the latter will calculate unique paths based on bundle ids which can
|
||||||
|
+ // increase the socket path length than what is allowed.
|
||||||
|
+ if (!socket_dir_.CreateUniqueTempDirUnderPath(tmp_dir)) {
|
||||||
+ LOG(ERROR) << "Failed to create socket directory.";
|
+ LOG(ERROR) << "Failed to create socket directory.";
|
||||||
+ return false;
|
+ return false;
|
||||||
+ }
|
+ }
|
||||||
}
|
+ }
|
||||||
|
+
|
||||||
// Check that the directory was created with the correct permissions.
|
// Check that the directory was created with the correct permissions.
|
||||||
@@ -1046,10 +1100,13 @@ bool ProcessSingleton::Create() {
|
int dir_mode = 0;
|
||||||
|
CHECK(base::GetPosixFilePermissions(socket_dir_.GetPath(), &dir_mode) &&
|
||||||
|
@@ -1046,10 +1104,13 @@ bool ProcessSingleton::Create() {
|
||||||
if (listen(sock, 5) < 0)
|
if (listen(sock, 5) < 0)
|
||||||
NOTREACHED() << "listen failed: " << base::safe_strerror(errno);
|
NOTREACHED() << "listen failed: " << base::safe_strerror(errno);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue