We recently enabled reading sysctl values from inside the sandbox. This CL removes workarounds needed when sysctl reads where blocked.
Review URL: http://codereview.chromium.org/151202 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19809 0039d316-1c4b-4281-b951-d872f2087c98
Esse commit está contido em:
@@ -14,8 +14,6 @@ namespace base {
|
||||
class SysInfo {
|
||||
public:
|
||||
// Return the number of logical processors/cores on the current machine.
|
||||
// WARNING: On POSIX, this method uses static variables and is not threadsafe
|
||||
// until it's been initialized by being called once without a race.
|
||||
static int NumberOfProcessors();
|
||||
|
||||
// Return the number of bytes of physical memory on the current machine.
|
||||
@@ -46,8 +44,6 @@ class SysInfo {
|
||||
static std::string OperatingSystemVersion();
|
||||
|
||||
// Retrieves detailed numeric values for the OS version.
|
||||
// WARNING: On OS X, this method uses static variables and is not threadsafe
|
||||
// until it's been initialized by being called once without a race.
|
||||
// TODO(port): Implement a Linux version of this method and enable the
|
||||
// corresponding unit test.
|
||||
static void OperatingSystemVersionNumbers(int32 *major_version,
|
||||
@@ -68,14 +64,6 @@ class SysInfo {
|
||||
// Return the smallest amount of memory (in bytes) which the VM system will
|
||||
// allocate.
|
||||
static size_t VMAllocationGranularity();
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
// Under the OS X Sandbox, our access to the system is limited, this call
|
||||
// caches the system info on startup before we turn the Sandbox on.
|
||||
// The above functions are all wired up to return the cached value so the rest
|
||||
// of the code can call them in the Sandbox without worrying.
|
||||
static void CacheSysInfo();
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
||||
+10
-24
@@ -12,35 +12,21 @@ namespace base {
|
||||
void SysInfo::OperatingSystemVersionNumbers(int32 *major_version,
|
||||
int32 *minor_version,
|
||||
int32 *bugfix_version) {
|
||||
static bool is_initialized = false;
|
||||
static int32 major_version_cached = 0;
|
||||
static int32 minor_version_cached = 0;
|
||||
static int32 bugfix_version_cached = 0;
|
||||
int32 major_version_cached = 0;
|
||||
int32 minor_version_cached = 0;
|
||||
int32 bugfix_version_cached = 0;
|
||||
|
||||
if (!is_initialized) {
|
||||
// Gestalt can't be called in the sandbox, so we cache its return value.
|
||||
Gestalt(gestaltSystemVersionMajor,
|
||||
reinterpret_cast<SInt32*>(&major_version_cached));
|
||||
Gestalt(gestaltSystemVersionMinor,
|
||||
reinterpret_cast<SInt32*>(&minor_version_cached));
|
||||
Gestalt(gestaltSystemVersionBugFix,
|
||||
reinterpret_cast<SInt32*>(&bugfix_version_cached));
|
||||
is_initialized = true;
|
||||
}
|
||||
// Gestalt can't be called in the sandbox, so we cache its return value.
|
||||
Gestalt(gestaltSystemVersionMajor,
|
||||
reinterpret_cast<SInt32*>(&major_version_cached));
|
||||
Gestalt(gestaltSystemVersionMinor,
|
||||
reinterpret_cast<SInt32*>(&minor_version_cached));
|
||||
Gestalt(gestaltSystemVersionBugFix,
|
||||
reinterpret_cast<SInt32*>(&bugfix_version_cached));
|
||||
|
||||
*major_version = major_version_cached;
|
||||
*minor_version = minor_version_cached;
|
||||
*bugfix_version = bugfix_version_cached;
|
||||
}
|
||||
|
||||
// static
|
||||
void SysInfo::CacheSysInfo() {
|
||||
// Due to startup time concerns [premature optimization?] we only cache values
|
||||
// from functions we know to be called in the renderer & fail when the sandbox
|
||||
// is enabled.
|
||||
NumberOfProcessors();
|
||||
int32 dummy;
|
||||
OperatingSystemVersionNumbers(&dummy, &dummy, &dummy);
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
||||
@@ -39,7 +39,7 @@ int SysInfo::NumberOfProcessors() {
|
||||
#else
|
||||
// It seems that sysconf returns the number of "logical" processors on both
|
||||
// mac and linux. So we get the number of "online logical" processors.
|
||||
static long res = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
long res = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
if (res == -1) {
|
||||
NOTREACHED();
|
||||
return 1;
|
||||
|
||||
@@ -148,10 +148,6 @@ bool RendererMainPlatformDelegate::EnableSandbox() {
|
||||
// succeed.
|
||||
DebugUtil::BeingDebugged();
|
||||
|
||||
// Cache the System info information, since we can't query certain attributes
|
||||
// with the Sandbox enabled.
|
||||
base::SysInfo::CacheSysInfo();
|
||||
|
||||
// For the renderer, we give it a custom sandbox to lock down as tight as
|
||||
// possible, but still be able to draw.
|
||||
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário