summaryrefslogtreecommitdiffstats
path: root/rlz
diff options
context:
space:
mode:
authorcpu <cpu@chromium.org>2014-10-28 17:37:00 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-29 00:37:16 +0000
commit7cfb043eb32cdee60d4a233c350281a1f3624412 (patch)
treea5a0fdfcf2da87954c38b4443bdb721d57d229e8 /rlz
parent06e714227cf7acfa719d3e468602542c077646dd (diff)
downloadchromium_src-7cfb043eb32cdee60d4a233c350281a1f3624412.zip
chromium_src-7cfb043eb32cdee60d4a233c350281a1f3624412.tar.gz
chromium_src-7cfb043eb32cdee60d4a233c350281a1f3624412.tar.bz2
Fixing rlz mutex
0 - Remove special case for Vista. 1- Remove the low integrity logic, broken, wether or not to wait has nothing to do with setting the low integrity label, which was racy and (sometimes) broken. 2- Cleanup of style. BUG=426573 Review URL: https://codereview.chromium.org/686733003 Cr-Commit-Position: refs/heads/master@{#301748}
Diffstat (limited to 'rlz')
-rw-r--r--rlz/win/lib/lib_mutex.cc53
-rw-r--r--rlz/win/lib/lib_mutex.h6
2 files changed, 11 insertions, 48 deletions
diff --git a/rlz/win/lib/lib_mutex.cc b/rlz/win/lib/lib_mutex.cc
index 73dfade..d20fe21 100644
--- a/rlz/win/lib/lib_mutex.cc
+++ b/rlz/win/lib/lib_mutex.cc
@@ -1,67 +1,32 @@
// 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.
-//
-// Mutex to guarantee serialization of RLZ key accesses.
#include "rlz/win/lib/lib_mutex.h"
#include <windows.h>
-#include <Sddl.h> // For SDDL_REVISION_1, ConvertStringSecurityDescript..
-#include <Aclapi.h> // For SetSecurityInfo
-
-#include "base/logging.h"
#include "base/win/windows_version.h"
namespace {
+const long kTimeoutMs = 5000L;
const wchar_t kMutexName[] = L"{A946A6A9-917E-4949-B9BC-6BADA8C7FD63}";
-} // namespace anonymous
+} // namespace
namespace rlz_lib {
-// Needed to allow synchronization across integrity levels.
-static bool SetObjectToLowIntegrity(HANDLE object,
- SE_OBJECT_TYPE type = SE_KERNEL_OBJECT) {
- if (base::win::GetVersion() < base::win::VERSION_VISTA)
- return true; // Not needed on XP.
-
- // The LABEL_SECURITY_INFORMATION SDDL SACL to be set for low integrity.
- static const wchar_t kLowIntegritySddlSacl[] = L"S:(ML;;NW;;;LW)";
-
- bool result = false;
- DWORD error = ERROR_SUCCESS;
- PSECURITY_DESCRIPTOR security_descriptor = NULL;
- PACL sacl = NULL;
- BOOL sacl_present = FALSE;
- BOOL sacl_defaulted = FALSE;
-
- if (ConvertStringSecurityDescriptorToSecurityDescriptorW(
- kLowIntegritySddlSacl, SDDL_REVISION_1, &security_descriptor, NULL)) {
- if (GetSecurityDescriptorSacl(security_descriptor, &sacl_present,
- &sacl, &sacl_defaulted)) {
- error = SetSecurityInfo(object, type, LABEL_SECURITY_INFORMATION,
- NULL, NULL, NULL, sacl);
- result = (ERROR_SUCCESS == error);
- }
- LocalFree(security_descriptor);
- }
-
- return result;
-}
-
LibMutex::LibMutex() : acquired_(false), mutex_(NULL) {
- mutex_ = CreateMutex(NULL, false, kMutexName);
- bool result = SetObjectToLowIntegrity(mutex_);
- if (result) {
- acquired_ = (WAIT_OBJECT_0 == WaitForSingleObject(mutex_, 5000L));
- }
+ mutex_ = CreateMutex(NULL, FALSE, kMutexName);
+ if (mutex_)
+ acquired_ = (WAIT_OBJECT_0 == WaitForSingleObject(mutex_, kTimeoutMs));
}
LibMutex::~LibMutex() {
- if (acquired_) ReleaseMutex(mutex_);
- CloseHandle(mutex_);
+ if (acquired_)
+ ReleaseMutex(mutex_);
+ if (mutex_)
+ CloseHandle(mutex_);
}
} // namespace rlz_lib
diff --git a/rlz/win/lib/lib_mutex.h b/rlz/win/lib/lib_mutex.h
index 6992bea..d0f0eba 100644
--- a/rlz/win/lib/lib_mutex.h
+++ b/rlz/win/lib/lib_mutex.h
@@ -1,8 +1,6 @@
// 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.
-//
-// Mutex to guarantee serialization of RLZ key accesses.
#ifndef RLZ_WIN_LIB_LIB_MUTEX_H_
#define RLZ_WIN_LIB_LIB_MUTEX_H_
@@ -10,13 +8,13 @@
#include <windows.h>
namespace rlz_lib {
-
+// Cross-process mutex to guarantee serialization of RLZ key accesses.
class LibMutex {
public:
LibMutex();
~LibMutex();
- bool failed(void) { return !acquired_; }
+ bool failed() const { return !acquired_; }
private:
bool acquired_;