[ros-dev] [ros-diffs] [ekohl] 73433: [SERVICES] Create a new environment block when a service process is started. Patch by Hermès BÉLUSCA - MAÏTO. CORE-12414

Ged Murphy gedmurphy.maillists at gmail.com
Tue Dec 6 20:28:35 UTC 2016


This leaks if ImpersonateLoggedOnUser fails and the environment block is non-null

-----Original Message-----
From: Ros-diffs [mailto:ros-diffs-bounces at reactos.org] On Behalf Of ekohl at svn.reactos.org
Sent: 06 December 2016 17:30
To: ros-diffs at reactos.org
Subject: [ros-diffs] [ekohl] 73433: [SERVICES] Create a new environment block when a service process is started. Patch by Hermès BÉLUSCA - MAÏTO. CORE-12414


+    if (Service->lpImage->hToken)
+    {
+        /* User token: Run the service under the user account */
+
+        if (!CreateEnvironmentBlock(&lpEnvironment, Service->lpImage->hToken, FALSE))
+        {
+            /* We failed, run the service with the current environment */
+            DPRINT1("CreateEnvironmentBlock() failed with error %d, service '%S' will run with the current environment.\n",
+                    Service->lpServiceName, GetLastError());
+            lpEnvironment = NULL;
+        }
+
+        /* Impersonate the new user */
+        if (!ImpersonateLoggedOnUser(Service->lpImage->hToken))
+        {
+            dwError = GetLastError();
+            DPRINT1("ImpersonateLoggedOnUser() failed with error %d\n", GetLastError());
+            return dwError;
+        }





More information about the Ros-dev mailing list