| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sandbox/src/job.h" | 5 #include "sandbox/src/job.h" |
| 6 |
| 7 #include "base/win/windows_version.h" |
| 6 #include "sandbox/src/restricted_token.h" | 8 #include "sandbox/src/restricted_token.h" |
| 7 | 9 |
| 8 namespace sandbox { | 10 namespace sandbox { |
| 9 | 11 |
| 10 Job::~Job() { | 12 Job::~Job() { |
| 11 if (job_handle_) | 13 if (job_handle_) |
| 12 ::CloseHandle(job_handle_); | 14 ::CloseHandle(job_handle_); |
| 13 }; | 15 }; |
| 14 | 16 |
| 15 DWORD Job::Init(JobLevel security_level, wchar_t *job_name, | 17 DWORD Job::Init(JobLevel security_level, wchar_t *job_name, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 42 jbur.UIRestrictionsClass |= JOB_OBJECT_UILIMIT_DISPLAYSETTINGS; | 44 jbur.UIRestrictionsClass |= JOB_OBJECT_UILIMIT_DISPLAYSETTINGS; |
| 43 jeli.BasicLimitInformation.LimitFlags |= JOB_OBJECT_LIMIT_ACTIVE_PROCESS; | 45 jeli.BasicLimitInformation.LimitFlags |= JOB_OBJECT_LIMIT_ACTIVE_PROCESS; |
| 44 jeli.BasicLimitInformation.ActiveProcessLimit = 1; | 46 jeli.BasicLimitInformation.ActiveProcessLimit = 1; |
| 45 } | 47 } |
| 46 case JOB_INTERACTIVE: { | 48 case JOB_INTERACTIVE: { |
| 47 jbur.UIRestrictionsClass |= JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS; | 49 jbur.UIRestrictionsClass |= JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS; |
| 48 jbur.UIRestrictionsClass |= JOB_OBJECT_UILIMIT_DESKTOP; | 50 jbur.UIRestrictionsClass |= JOB_OBJECT_UILIMIT_DESKTOP; |
| 49 jbur.UIRestrictionsClass |= JOB_OBJECT_UILIMIT_EXITWINDOWS; | 51 jbur.UIRestrictionsClass |= JOB_OBJECT_UILIMIT_EXITWINDOWS; |
| 50 } | 52 } |
| 51 case JOB_UNPROTECTED: { | 53 case JOB_UNPROTECTED: { |
| 52 OSVERSIONINFO version_info = {0}; | |
| 53 version_info.dwOSVersionInfoSize = sizeof(version_info); | |
| 54 GetVersionEx(&version_info); | |
| 55 | |
| 56 // The JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE flag is not supported on | 54 // The JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE flag is not supported on |
| 57 // Windows 2000. We need a mechanism on Windows 2000 to ensure | 55 // Windows 2000. We need a mechanism on Windows 2000 to ensure |
| 58 // that processes in the job are terminated when the job is closed | 56 // that processes in the job are terminated when the job is closed |
| 59 if ((5 == version_info.dwMajorVersion) && | 57 if (base::win::GetVersion() == base::win::VERSION_PRE_XP) |
| 60 (0 == version_info.dwMinorVersion)) { | |
| 61 break; | 58 break; |
| 62 } | |
| 63 | 59 |
| 64 jeli.BasicLimitInformation.LimitFlags |= | 60 jeli.BasicLimitInformation.LimitFlags |= |
| 65 JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; | 61 JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; |
| 66 break; | 62 break; |
| 67 } | 63 } |
| 68 default: { | 64 default: { |
| 69 return ERROR_BAD_ARGUMENTS; | 65 return ERROR_BAD_ARGUMENTS; |
| 70 } | 66 } |
| 71 } | 67 } |
| 72 | 68 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 if (!job_handle_) | 107 if (!job_handle_) |
| 112 return ERROR_NO_DATA; | 108 return ERROR_NO_DATA; |
| 113 | 109 |
| 114 if (FALSE == ::AssignProcessToJobObject(job_handle_, process_handle)) | 110 if (FALSE == ::AssignProcessToJobObject(job_handle_, process_handle)) |
| 115 return ::GetLastError(); | 111 return ::GetLastError(); |
| 116 | 112 |
| 117 return ERROR_SUCCESS; | 113 return ERROR_SUCCESS; |
| 118 } | 114 } |
| 119 | 115 |
| 120 } // namespace sandbox | 116 } // namespace sandbox |
| OLD | NEW |