diff cinst/nssstore_linux.c @ 978:d92b1594e974

Merged.
author Emanuel Schuetze <emanuel@intevation.de>
date Fri, 29 Aug 2014 13:10:11 +0200
parents b3695a3399de
children 78798d3af8f0
line wrap: on
line diff
--- a/cinst/nssstore_linux.c	Fri Aug 29 13:09:40 2014 +0200
+++ b/cinst/nssstore_linux.c	Fri Aug 29 13:10:11 2014 +0200
@@ -93,6 +93,7 @@
   argv[0] = xmalloc (exe_path_len + 1);
 
   ret = snprintf(argv[0], exe_path_len + 1, "%s%s", inst_dir, NSS_PROCESS_NAME);
+  xfree (inst_dir);
   if (ret < 0 || (size_t) ret != exe_path_len)
     {
       ERRORPRINTF ("Error setting executable variable.\n");
@@ -200,18 +201,19 @@
 {
   struct passwd *usr_it = NULL;
   uid_t my_uid = geteuid();
+  pid_t childprocess = -1;
+  int status = -1;
 
   if (my_uid != 0)
     {
       /* Running as a user */
       char *homedir = getenv ("HOME");
-      pid_t childprocess = -1; /* Only one child for single user installation */
-      int status = -1;
       if (!homedir)
         {
           ERRORPRINTF ("Failed to find home directory\n");
         }
 
+      /* Only one child for single user installation */
       childprocess = start_procces_for_user (to_install, to_remove,
                                              my_uid, getgid(), homedir);
 
@@ -231,6 +233,23 @@
       return 0;
     }
 
+  /* Start once as root to install in the system default directories. */
+  childprocess = start_procces_for_user (to_install, to_remove,
+                                         my_uid, getgid(), getenv ("HOME"));
+  if (childprocess == -1)
+    {
+      ERRORPRINTF ("Failed to start default profile installation!\n");
+      return -1;
+    }
+
+  /* Wait until the default profile directories are done. */
+  childprocess = waitpid (childprocess, &status, 0);
+  if (childprocess == -1 || !WIFEXITED(status))
+    {
+      ERRORPRINTF ("Child process did not finish.\n");
+      return -1;
+    }
+
   setpwent();
 
   while ((usr_it = getpwent ()) != NULL)

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