diff cinst/nssstore_win.c @ 985:1743895b39b8

(issue86) Install into default profile folders on windows.
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 29 Aug 2014 17:13:30 +0200
parents 427e2e18b8c8
children 1c1964c27b39 6684e5012b7a
line wrap: on
line diff
--- a/cinst/nssstore_win.c	Fri Aug 29 17:12:35 2014 +0200
+++ b/cinst/nssstore_win.c	Fri Aug 29 17:13:30 2014 +0200
@@ -628,10 +628,13 @@
 * @param [in] selection_file filename of the file containing
 *             the users install / remove selection.
 *
+* @param [in] drop_privileges weather or not elevated privileges
+*             should be dropped before starting the process.
+*
 * @returns true on success, false on error.
 */
 static bool
-start_procces_for_user (wchar_t *selection_file)
+start_procces_for_user (wchar_t *selection_file, bool drop_privileges)
 {
   HANDLE hToken = NULL;
   LPWSTR lpApplicationPath = NULL,
@@ -670,7 +673,7 @@
   /* set up handles. stdin and stdout go to the same stdout*/
   siStartInfo.cb = sizeof (STARTUPINFO);
 
-  if (is_elevated())
+  if (is_elevated() && drop_privileges)
     {
       /* Start the child process as normal user */
       hToken = get_restricted_token ();
@@ -884,9 +887,17 @@
   if (is_elevated())
     {
       register_proccesses_for_others (selection_file_name);
+      /* Start the NSS process once with elevated rights to
+         install into the default profile directories. */
+      if (!start_procces_for_user (selection_file_name, false))
+        {
+          ERRORPRINTF ("Failed to run NSS installation process for default folders.\n");
+          xfree(selection_file_name);
+          return -1;
+        }
     }
 
-  if (!start_procces_for_user (selection_file_name))
+  if (!start_procces_for_user (selection_file_name, true))
     {
       ERRORPRINTF ("Failed to run NSS installation process.\n");
       xfree(selection_file_name);

http://wald.intevation.org/projects/trustbridge/