Bug 1382099 - Remove MOZ_WIDGET_GONK from ipc/. r=jld.
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 21 Jul 2017 10:45:49 +1000
changeset 418726 c6e13d347c58721bdfbcd65a8ae237cf1c6aa43f
parent 418725 5202dd1a9e218f133380a7fd4b1257d8a99f9c55
child 418727 aac6fe2703820a894367433708f7b7418fb7ea59
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjld
bugs1382099
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1382099 - Remove MOZ_WIDGET_GONK from ipc/. r=jld.
ipc/chromium/src/base/platform_thread_posix.cc
ipc/chromium/src/base/process_util_linux.cc
ipc/dbus/DBusHelpers.cpp
ipc/dbus/DBusUtils.cpp
ipc/glue/GeckoChildProcessHost.cpp
ipc/ril/Ril.cpp
ipc/ril/RilConnector.cpp
--- a/ipc/chromium/src/base/platform_thread_posix.cc
+++ b/ipc/chromium/src/base/platform_thread_posix.cc
@@ -43,21 +43,17 @@ static void* ThreadFunc(void* closure) {
 PlatformThreadId PlatformThread::CurrentId() {
   // Pthreads doesn't have the concept of a thread ID, so we have to reach down
   // into the kernel.
 #if defined(OS_MACOSX)
   mach_port_t port = mach_thread_self();
   mach_port_deallocate(mach_task_self(), port);
   return port;
 #elif defined(OS_LINUX)
-#ifdef MOZ_WIDGET_GONK
-  return (intptr_t) (pthread_self());
-#else
   return syscall(__NR_gettid);
-#endif
 #elif defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(__GLIBC__)
   return (intptr_t) (pthread_self());
 #elif defined(OS_NETBSD)
   return _lwp_self();
 #elif defined(OS_DRAGONFLY)
   return lwp_gettid();
 #elif defined(OS_FREEBSD)
   return pthread_getthreadid_np();
--- a/ipc/chromium/src/base/process_util_linux.cc
+++ b/ipc/chromium/src/base/process_util_linux.cc
@@ -18,34 +18,22 @@
 #include "base/file_util.h"
 #include "base/logging.h"
 #include "base/string_util.h"
 #include "nsLiteralString.h"
 #include "mozilla/UniquePtr.h"
 
 #include "prenv.h"
 
-#ifdef MOZ_WIDGET_GONK
 /*
- * AID_APP is the first application UID used by Android. We're using
- * it as our unprivilegied UID.  This ensure the UID used is not
- * shared with any other processes than our own childs.
- */
-# include <private/android_filesystem_config.h>
-# define CHILD_UNPRIVILEGED_UID AID_APP
-# define CHILD_UNPRIVILEGED_GID AID_APP
-#else
-/*
- * On platforms that are not gonk based, we fall back to an arbitrary
- * UID. This is generally the UID for user `nobody', albeit it is not
- * always the case.
+ * We fall back to an arbitrary UID. This is generally the UID for user
+ * `nobody', albeit it is not always the case.
  */
 # define CHILD_UNPRIVILEGED_UID 65534
 # define CHILD_UNPRIVILEGED_GID 65534
-#endif
 
 namespace {
 
 enum ParsingState {
   KEY_NAME,
   KEY_VALUE
 };
 
@@ -223,46 +211,16 @@ bool LaunchApp(const CommandLine& cl,
 
 void SetCurrentProcessPrivileges(ChildPrivileges privs) {
   if (privs == PRIVILEGES_INHERIT) {
     return;
   }
 
   gid_t gid = CHILD_UNPRIVILEGED_GID;
   uid_t uid = CHILD_UNPRIVILEGED_UID;
-#ifdef MOZ_WIDGET_GONK
-  {
-    static bool checked_pix_max, pix_max_ok;
-    if (!checked_pix_max) {
-      checked_pix_max = true;
-      int fd = open("/proc/sys/kernel/pid_max", O_CLOEXEC | O_RDONLY);
-      if (fd < 0) {
-        DLOG(ERROR) << "Failed to open pid_max";
-        _exit(127);
-      }
-      char buf[PATH_MAX];
-      ssize_t len = read(fd, buf, sizeof(buf) - 1);
-      close(fd);
-      if (len < 0) {
-        DLOG(ERROR) << "Failed to read pid_max";
-        _exit(127);
-      }
-      buf[len] = '\0';
-      int pid_max = atoi(buf);
-      pix_max_ok =
-        (pid_max + CHILD_UNPRIVILEGED_UID > CHILD_UNPRIVILEGED_UID);
-    }
-    if (!pix_max_ok) {
-      DLOG(ERROR) << "Can't safely get unique uid/gid";
-      _exit(127);
-    }
-    gid += getpid();
-    uid += getpid();
-  }
-#endif
   if (setgid(gid) != 0) {
     DLOG(ERROR) << "FAILED TO setgid() CHILD PROCESS";
     _exit(127);
   }
   if (setuid(uid) != 0) {
     DLOG(ERROR) << "FAILED TO setuid() CHILD PROCESS";
     _exit(127);
   }
--- a/ipc/dbus/DBusHelpers.cpp
+++ b/ipc/dbus/DBusHelpers.cpp
@@ -9,22 +9,17 @@
 #include "mozilla/ipc/DBusPendingCallRefPtr.h"
 #include "mozilla/ipc/DBusWatcher.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/Unused.h"
 #include "nsThreadUtils.h"
 
 #undef CHROMIUM_LOG
-#if defined(MOZ_WIDGET_GONK)
-#include <android/log.h>
-#define CHROMIUM_LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "Gonk", args);
-#else
 #define CHROMIUM_LOG(args...)  printf(args);
-#endif
 
 namespace mozilla {
 namespace ipc {
 
 //
 // DBus I/O
 //
 
--- a/ipc/dbus/DBusUtils.cpp
+++ b/ipc/dbus/DBusUtils.cpp
@@ -15,22 +15,17 @@
 ** See the License for the specific language governing permissions and
 ** limitations under the License.
 */
 
 #include <dbus/dbus.h>
 #include "DBusUtils.h"
 
 #undef CHROMIUM_LOG
-#if defined(MOZ_WIDGET_GONK)
-#include <android/log.h>
-#define CHROMIUM_LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "Gonk", args);
-#else
 #define CHROMIUM_LOG(args...)  printf(args);
-#endif
 
 namespace mozilla {
 namespace ipc {
 
 //
 // DBusMessageRefPtr
 //
 
--- a/ipc/glue/GeckoChildProcessHost.cpp
+++ b/ipc/glue/GeckoChildProcessHost.cpp
@@ -70,25 +70,19 @@ using mozilla::ipc::GeckoChildProcessHos
 
 #ifdef MOZ_WIDGET_ANDROID
 #include "AndroidBridge.h"
 #include "GeneratedJNIWrappers.h"
 #include "mozilla/jni/Refs.h"
 #include "mozilla/jni/Utils.h"
 #endif
 
-static const bool kLowRightsSubprocesses =
-  // We currently only attempt to drop privileges on gonk, because we
-  // have no plugins or extensions to worry about breaking.
-#ifdef MOZ_WIDGET_GONK
-  true
-#else
-  false
-#endif
-  ;
+// We currently don't drop privileges on any platform, because we have to worry
+// about plugins and extensions breaking.
+static const bool kLowRightsSubprocesses = false;
 
 static bool
 ShouldHaveDirectoryService()
 {
   return GeckoProcessType_Default == XRE_GetProcessType();
 }
 
 /*static*/
@@ -751,22 +745,16 @@ GeckoChildProcessHost::PerformAsyncLaunc
     newEnvVars["DYLD_INSERT_LIBRARIES"] = interpose.get();
 # endif  // OS_LINUX
   }
 #endif  // OS_LINUX || OS_MACOSX
 
   FilePath exePath;
   BinaryPathType pathType = GetPathToBinary(exePath, mProcessType);
 
-#ifdef MOZ_WIDGET_GONK
-  if (const char *ldPreloadPath = getenv("LD_PRELOAD")) {
-    newEnvVars["LD_PRELOAD"] = ldPreloadPath;
-  }
-#endif // MOZ_WIDGET_GONK
-
 #if defined(XP_LINUX) && defined(MOZ_SANDBOX)
   // Preload libmozsandbox.so so that sandbox-related interpositions
   // can be defined there instead of in the executable.
   // (This could be made conditional on intent to use sandboxing, but
   // it's harmless for non-sandboxed processes.)
   {
     nsAutoCString preload;
     // Prepend this, because people can and do preload libpthread.
--- a/ipc/ril/Ril.cpp
+++ b/ipc/ril/Ril.cpp
@@ -16,22 +16,17 @@
 #include "mozilla/ipc/RilSocketConsumer.h"
 #include "nsThreadUtils.h" // For NS_IsMainThread.
 #include "RilConnector.h"
 
 #ifdef CHROMIUM_LOG
 #undef CHROMIUM_LOG
 #endif
 
-#if defined(MOZ_WIDGET_GONK)
-#include <android/log.h>
-#define CHROMIUM_LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "Gonk", args)
-#else
 #define CHROMIUM_LOG(args...)  printf(args);
-#endif
 
 namespace mozilla {
 namespace ipc {
 
 USING_WORKERS_NAMESPACE;
 using namespace JS;
 
 class RilConsumer;
--- a/ipc/ril/RilConnector.cpp
+++ b/ipc/ril/RilConnector.cpp
@@ -176,21 +176,17 @@ RilConnector::AcceptStreamSocket(int aLi
   MOZ_CRASH("|RilConnector| does not support accepting sockets.");
 }
 
 nsresult
 RilConnector::CreateStreamSocket(struct sockaddr* aAddress,
                                  socklen_t* aAddressLength,
                                  int& aStreamFd)
 {
-#ifdef MOZ_WIDGET_GONK
-  static const int sDomain = AF_UNIX;
-#else
   static const int sDomain = AF_INET;
-#endif
 
   ScopedClose fd;
 
   nsresult rv = CreateSocket(sDomain, fd.rwget());
   if (NS_FAILED(rv)) {
     return rv;
   }
   rv = SetSocketFlags(fd);