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