mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
parent
b586913598
commit
2531de02eb
85 changed files with 68 additions and 1357 deletions
|
|
@ -48,11 +48,7 @@ PlatformThreadId PlatformThread::CurrentId() {
|
|||
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(__GLIBC__)
|
||||
return (intptr_t) (pthread_self());
|
||||
#elif defined(OS_NETBSD)
|
||||
|
|
|
|||
|
|
@ -24,24 +24,13 @@
|
|||
#include "prenv.h"
|
||||
#include "prmem.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
|
||||
* On our platforms we use 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 {
|
||||
|
||||
|
|
@ -229,36 +218,6 @@ void SetCurrentProcessPrivileges(ChildPrivileges privs) {
|
|||
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -22,41 +22,6 @@
|
|||
|
||||
#include "GMPLoader.h"
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
# include <sys/time.h>
|
||||
# include <sys/resource.h>
|
||||
|
||||
# include <binder/ProcessState.h>
|
||||
|
||||
# ifdef LOGE_IF
|
||||
# undef LOGE_IF
|
||||
# endif
|
||||
|
||||
# include <android/log.h>
|
||||
# define LOGE_IF(cond, ...) \
|
||||
( (CONDITION(cond)) \
|
||||
? ((void)__android_log_print(ANDROID_LOG_ERROR, \
|
||||
"Gecko:MozillaRntimeMain", __VA_ARGS__)) \
|
||||
: (void)0 )
|
||||
|
||||
#endif // MOZ_WIDGET_GONK
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
static void
|
||||
InitializeBinder(void *aDummy) {
|
||||
// Change thread priority to 0 only during calling ProcessState::self().
|
||||
// The priority is registered to binder driver and used for default Binder
|
||||
// Thread's priority.
|
||||
// To change the process's priority to small value need's root permission.
|
||||
int curPrio = getpriority(PRIO_PROCESS, 0);
|
||||
int err = setpriority(PRIO_PROCESS, 0, 0);
|
||||
MOZ_ASSERT(!err);
|
||||
LOGE_IF(err, "setpriority failed. Current process needs root permission.");
|
||||
android::ProcessState::self()->startThreadPool();
|
||||
setpriority(PRIO_PROCESS, 0, curPrio);
|
||||
}
|
||||
#endif
|
||||
|
||||
mozilla::gmp::SandboxStarter*
|
||||
MakeSandboxStarter()
|
||||
{
|
||||
|
|
@ -76,15 +41,6 @@ content_process_main(int argc, char* argv[])
|
|||
|
||||
XRE_SetProcessType(argv[--argc]);
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
// This creates a ThreadPool for binder ipc. A ThreadPool is necessary to
|
||||
// receive binder calls, though not necessary to send binder calls.
|
||||
// ProcessState::Self() also needs to be called once on the main thread to
|
||||
// register the main thread with the binder driver.
|
||||
|
||||
InitializeBinder(nullptr);
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
// For plugins, this is done in PluginProcessChild::Init, as we need to
|
||||
// avoid it for unsupported plugins. See PluginProcessChild::Init for
|
||||
|
|
@ -94,7 +50,7 @@ content_process_main(int argc, char* argv[])
|
|||
SetDllDirectoryW(L"");
|
||||
}
|
||||
#endif
|
||||
#if !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_GONK) && defined(MOZ_PLUGIN_CONTAINER)
|
||||
#if !defined(MOZ_WIDGET_ANDROID) && defined(MOZ_PLUGIN_CONTAINER)
|
||||
// On desktop, the GMPLoader lives in plugin-container, so that its
|
||||
// code can be covered by an EME/GMP vendor's voucher.
|
||||
nsAutoPtr<mozilla::gmp::SandboxStarter> starter(MakeSandboxStarter());
|
||||
|
|
|
|||
|
|
@ -14,12 +14,7 @@
|
|||
#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 {
|
||||
|
|
|
|||
|
|
@ -20,12 +20,7 @@
|
|||
#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 {
|
||||
|
|
|
|||
|
|
@ -62,13 +62,9 @@ static const int kMagicAndroidSystemPropFd = 5;
|
|||
#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
|
||||
// We only attempted to drop privileges on gonk, because it
|
||||
// had no plugins or extensions to worry about breaking.
|
||||
false
|
||||
#endif
|
||||
;
|
||||
|
||||
static bool
|
||||
|
|
@ -699,12 +695,6 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExt
|
|||
}
|
||||
#endif // ANDROID
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
if (const char *ldPreloadPath = getenv("LD_PRELOAD")) {
|
||||
newEnvVars["LD_PRELOAD"] = ldPreloadPath;
|
||||
}
|
||||
#endif // MOZ_WIDGET_GONK
|
||||
|
||||
// remap the IPC socket fd to a well-known int, as the OS does for
|
||||
// STDOUT_FILENO, for example
|
||||
int srcChannelFd, dstChannelFd;
|
||||
|
|
|
|||
|
|
@ -14,14 +14,9 @@
|
|||
#undef CHROMIUM_LOG
|
||||
#endif
|
||||
|
||||
#if defined(MOZ_WIDGET_GONK)
|
||||
#include <android/log.h>
|
||||
#define CHROMIUM_LOG(args...) __android_log_print(ANDROID_LOG_INFO, "I/O", args);
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define IODEBUG true
|
||||
#define CHROMIUM_LOG(args...) if (IODEBUG) printf(args);
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
|
|
|||
|
|
@ -18,14 +18,9 @@
|
|||
#undef CHROMIUM_LOG
|
||||
#endif
|
||||
|
||||
#if defined(MOZ_WIDGET_GONK)
|
||||
#include <android/log.h>
|
||||
#define CHROMIUM_LOG(args...) __android_log_print(ANDROID_LOG_INFO, "I/O", args);
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define IODEBUG true
|
||||
#define CHROMIUM_LOG(args...) if (IODEBUG) printf(args);
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
|
|
|||
|
|
@ -12,14 +12,9 @@
|
|||
#undef CHROMIUM_LOG
|
||||
#endif
|
||||
|
||||
#if defined(MOZ_WIDGET_GONK)
|
||||
#include <android/log.h>
|
||||
#define CHROMIUM_LOG(args...) __android_log_print(ANDROID_LOG_INFO, "I/O", args);
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define IODEBUG true
|
||||
#define CHROMIUM_LOG(args...) if (IODEBUG) printf(args);
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
|
|
|||
|
|
@ -15,26 +15,12 @@
|
|||
#undef CHROMIUM_LOG
|
||||
#endif
|
||||
|
||||
#if defined(MOZ_WIDGET_GONK)
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
#define CHROMIUM_LOG(args...) \
|
||||
__android_log_print(ANDROID_LOG_INFO, "HAL-IPC", args);
|
||||
|
||||
#define CHROMIUM_LOG_VA(fmt, ap) \
|
||||
__android_log_vprint(ANDROID_LOG_INFO, "HAL-IPC", fmt, ap);
|
||||
|
||||
#else
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define IODEBUG true
|
||||
#define CHROMIUM_LOG(args...) if (IODEBUG) { printf(args); }
|
||||
#define CHROMIUM_LOG_VA(fmt, ap) if (IODEBUG) { vprintf(fmt, ap); }
|
||||
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
namespace DaemonSocketPDUHelpers {
|
||||
|
|
|
|||
|
|
@ -10,12 +10,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined(MOZ_WIDGET_GONK)
|
||||
#include <android/log.h>
|
||||
#define KEYSTORE_LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk", args)
|
||||
#else
|
||||
#define KEYSTORE_LOG(args...) printf(args);
|
||||
#endif
|
||||
|
||||
#include "KeyStore.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
|
|
|||
|
|
@ -13,12 +13,7 @@
|
|||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
|
||||
#include "nsThreadUtils.h" // For NS_IsMainThread.
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
#include <android/log.h>
|
||||
#define KEYSTORE_LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk", args)
|
||||
#else
|
||||
#define KEYSTORE_LOG(args...) printf(args);
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
|
|
|||
|
|
@ -21,12 +21,7 @@
|
|||
#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 {
|
||||
|
|
|
|||
|
|
@ -181,11 +181,7 @@ 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;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,14 +11,9 @@
|
|||
#undef CHROMIUM_LOG
|
||||
#endif
|
||||
|
||||
#if defined(MOZ_WIDGET_GONK)
|
||||
#include <android/log.h>
|
||||
#define CHROMIUM_LOG(args...) __android_log_print(ANDROID_LOG_INFO, "I/O", args);
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define IODEBUG true
|
||||
#define CHROMIUM_LOG(args...) if (IODEBUG) printf(args);
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue