diff options
-rw-r--r-- | base/base.gypi | 1 | ||||
-rw-r--r-- | base/rand_util.h | 6 | ||||
-rw-r--r-- | base/rand_util_c.h | 26 | ||||
-rw-r--r-- | base/rand_util_nacl.cc | 1 | ||||
-rw-r--r-- | base/rand_util_posix.cc | 7 | ||||
-rw-r--r-- | chrome/nacl/nacl_listener.cc | 4 | ||||
-rw-r--r-- | chrome/renderer/pepper/ppb_nacl_private_impl.cc | 6 | ||||
-rw-r--r-- | content/common/sandbox_mac.mm | 4 | ||||
-rw-r--r-- | content/zygote/zygote_main_linux.cc | 9 |
9 files changed, 19 insertions, 45 deletions
diff --git a/base/base.gypi b/base/base.gypi index b072a3e..b17f391 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -274,7 +274,6 @@ 'property_bag.h', 'rand_util.cc', 'rand_util.h', - 'rand_util_c.h', 'rand_util_posix.cc', 'rand_util_win.cc', 'safe_strerror_posix.cc', diff --git a/base/rand_util.h b/base/rand_util.h index 8d795a3..82e548b 100644 --- a/base/rand_util.h +++ b/base/rand_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -43,6 +43,10 @@ BASE_EXPORT void RandBytes(void* output, size_t output_length); // Note that this is a variation of |RandBytes| with a different return type. BASE_EXPORT std::string RandBytesAsString(size_t length); +#ifdef OS_POSIX +BASE_EXPORT int GetUrandomFD(); +#endif + } // namespace base #endif // BASE_RAND_UTIL_H_ diff --git a/base/rand_util_c.h b/base/rand_util_c.h deleted file mode 100644 index f16d264..0000000 --- a/base/rand_util_c.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BASE_RAND_UTIL_C_H_ -#define BASE_RAND_UTIL_C_H_ -#pragma once - -#include "base/base_export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// Note this *should* be in "namespace base" but the function is needed -// from C so namespaces cannot be used. - -// Returns an FD for /dev/urandom, possibly pre-opened before sandboxing -// was switched on. This is a C function so that Native Client can use it. -BASE_EXPORT int GetUrandomFD(void); - -#ifdef __cplusplus -} -#endif - -#endif /* BASE_RAND_UTIL_C_H_ */ diff --git a/base/rand_util_nacl.cc b/base/rand_util_nacl.cc index e885465..718da05 100644 --- a/base/rand_util_nacl.cc +++ b/base/rand_util_nacl.cc @@ -3,7 +3,6 @@ // found in the LICENSE file. #include "base/rand_util.h" -#include "base/rand_util_c.h" #include "base/lazy_instance.h" #include "base/logging.h" diff --git a/base/rand_util_posix.cc b/base/rand_util_posix.cc index 6abf5f8..abb404a 100644 --- a/base/rand_util_posix.cc +++ b/base/rand_util_posix.cc @@ -1,9 +1,8 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/rand_util.h" -#include "base/rand_util_c.h" #include <errno.h> #include <fcntl.h> @@ -54,8 +53,8 @@ uint64 RandUint64() { return number; } -} // namespace base - int GetUrandomFD(void) { return g_urandom_fd.Pointer()->fd(); } + +} // namespace base diff --git a/chrome/nacl/nacl_listener.cc b/chrome/nacl/nacl_listener.cc index 1f48ef5..01a3305 100644 --- a/chrome/nacl/nacl_listener.cc +++ b/chrome/nacl/nacl_listener.cc @@ -11,7 +11,7 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" -#include "base/rand_util_c.h" +#include "base/rand_util.h" #include "chrome/common/nacl_messages.h" #include "chrome/nacl/nacl_validation_db.h" #include "chrome/nacl/nacl_validation_query.h" @@ -192,7 +192,7 @@ void NaClListener::OnMsgStart(const nacl::NaClStartParams& params) { std::vector<nacl::FileDescriptor> handles = params.handles; #if defined(OS_LINUX) || defined(OS_MACOSX) - args->urandom_fd = dup(GetUrandomFD()); + args->urandom_fd = dup(base::GetUrandomFD()); if (args->urandom_fd < 0) { LOG(ERROR) << "Failed to dup() the urandom FD"; return; diff --git a/chrome/renderer/pepper/ppb_nacl_private_impl.cc b/chrome/renderer/pepper/ppb_nacl_private_impl.cc index b9e9075..61fa839 100644 --- a/chrome/renderer/pepper/ppb_nacl_private_impl.cc +++ b/chrome/renderer/pepper/ppb_nacl_private_impl.cc @@ -9,7 +9,7 @@ #include "base/command_line.h" #include "base/lazy_instance.h" #include "base/logging.h" -#include "base/rand_util_c.h" +#include "base/rand_util.h" #include "chrome/common/render_messages.h" #include "content/public/common/content_switches.h" #include "content/public/renderer/render_thread.h" @@ -54,9 +54,9 @@ PP_Bool StartPpapiProxy(PP_Instance instance) { int UrandomFD(void) { #if defined(OS_POSIX) - return GetUrandomFD(); + return base::GetUrandomFD(); #else - return 0; + return -1; #endif } diff --git a/content/common/sandbox_mac.mm b/content/common/sandbox_mac.mm index 90b7fe9..1eb3e5f 100644 --- a/content/common/sandbox_mac.mm +++ b/content/common/sandbox_mac.mm @@ -20,7 +20,7 @@ extern "C" { #include "base/mac/scoped_cftyperef.h" #include "base/mac/scoped_nsautorelease_pool.h" #include "base/memory/scoped_nsobject.h" -#include "base/rand_util_c.h" +#include "base/rand_util.h" #include "base/string16.h" #include "base/string_piece.h" #include "base/string_util.h" @@ -266,7 +266,7 @@ void Sandbox::SandboxWarmup(int sandbox_type) { { // Allow access to /dev/urandom. - GetUrandomFD(); + base::GetUrandomFD(); } // Process-type dependent warm-up. diff --git a/content/zygote/zygote_main_linux.cc b/content/zygote/zygote_main_linux.cc index 37b3d25..bbc0a0f 100644 --- a/content/zygote/zygote_main_linux.cc +++ b/content/zygote/zygote_main_linux.cc @@ -22,7 +22,6 @@ #include "base/pickle.h" #include "base/process_util.h" #include "base/rand_util.h" -#include "base/rand_util_c.h" #include "base/sys_info.h" #include "build/build_config.h" #include "crypto/nss_util.h" @@ -340,7 +339,7 @@ FILE* fopen_override(const char* path, const char* mode) __asm__ ("fopen"); __attribute__ ((__visibility__("default"))) FILE* fopen_override(const char* path, const char* mode) { if (g_am_zygote_or_renderer && strcmp(path, kUrandomDevPath) == 0) { - int fd = HANDLE_EINTR(dup(GetUrandomFD())); + int fd = HANDLE_EINTR(dup(base::GetUrandomFD())); if (fd < 0) { PLOG(ERROR) << "dup() failed."; return NULL; @@ -356,7 +355,7 @@ FILE* fopen_override(const char* path, const char* mode) { __attribute__ ((__visibility__("default"))) FILE* fopen64(const char* path, const char* mode) { if (g_am_zygote_or_renderer && strcmp(path, kUrandomDevPath) == 0) { - int fd = HANDLE_EINTR(dup(GetUrandomFD())); + int fd = HANDLE_EINTR(dup(base::GetUrandomFD())); if (fd < 0) { PLOG(ERROR) << "dup() failed."; return NULL; @@ -379,7 +378,7 @@ int xstat_override(int version, __attribute__ ((__visibility__("default"))) int xstat_override(int version, const char *path, struct stat *buf) { if (g_am_zygote_or_renderer && strcmp(path, kUrandomDevPath) == 0) { - int result = __fxstat(version, GetUrandomFD(), buf); + int result = __fxstat(version, base::GetUrandomFD(), buf); return result; } else { CHECK_EQ(0, pthread_once(&g_libc_file_io_funcs_guard, @@ -396,7 +395,7 @@ int xstat64_override(int version, __attribute__ ((__visibility__("default"))) int xstat64_override(int version, const char *path, struct stat64 *buf) { if (g_am_zygote_or_renderer && strcmp(path, kUrandomDevPath) == 0) { - int result = __fxstat64(version, GetUrandomFD(), buf); + int result = __fxstat64(version, base::GetUrandomFD(), buf); return result; } else { CHECK_EQ(0, pthread_once(&g_libc_file_io_funcs_guard, |