comparison cinst/nssstore_linux.c @ 975:b3695a3399de

(issue86) Install into default directories on Linux If the mozilla process is now started as root it will try to write into the default directories for NSS Shared and mozilla / thunderbird profiles. Cinst will now start the mozilla process once as root.
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 29 Aug 2014 12:59:44 +0200
parents dbf5ea18cb20
children 78798d3af8f0
comparison
equal deleted inserted replaced
974:cbd32175c56c 975:b3695a3399de
199 int 199 int
200 write_stores_nss (char **to_install, char **to_remove) 200 write_stores_nss (char **to_install, char **to_remove)
201 { 201 {
202 struct passwd *usr_it = NULL; 202 struct passwd *usr_it = NULL;
203 uid_t my_uid = geteuid(); 203 uid_t my_uid = geteuid();
204 pid_t childprocess = -1;
205 int status = -1;
204 206
205 if (my_uid != 0) 207 if (my_uid != 0)
206 { 208 {
207 /* Running as a user */ 209 /* Running as a user */
208 char *homedir = getenv ("HOME"); 210 char *homedir = getenv ("HOME");
209 pid_t childprocess = -1; /* Only one child for single user installation */
210 int status = -1;
211 if (!homedir) 211 if (!homedir)
212 { 212 {
213 ERRORPRINTF ("Failed to find home directory\n"); 213 ERRORPRINTF ("Failed to find home directory\n");
214 } 214 }
215 215
216 /* Only one child for single user installation */
216 childprocess = start_procces_for_user (to_install, to_remove, 217 childprocess = start_procces_for_user (to_install, to_remove,
217 my_uid, getgid(), homedir); 218 my_uid, getgid(), homedir);
218 219
219 if (childprocess == -1) 220 if (childprocess == -1)
220 { 221 {
228 ERRORPRINTF ("Waitpid failed.\n"); 229 ERRORPRINTF ("Waitpid failed.\n");
229 return -1; 230 return -1;
230 } 231 }
231 232
232 return 0; 233 return 0;
234 }
235
236 /* Start once as root to install in the system default directories. */
237 childprocess = start_procces_for_user (to_install, to_remove,
238 my_uid, getgid(), getenv ("HOME"));
239 if (childprocess == -1)
240 {
241 ERRORPRINTF ("Failed to start default profile installation!\n");
242 return -1;
243 }
244
245 /* Wait until the default profile directories are done. */
246 childprocess = waitpid (childprocess, &status, 0);
247 if (childprocess == -1 || !WIFEXITED(status))
248 {
249 ERRORPRINTF ("Child process did not finish.\n");
250 return -1;
233 } 251 }
234 252
235 setpwent(); 253 setpwent();
236 254
237 while ((usr_it = getpwent ()) != NULL) 255 while ((usr_it = getpwent ()) != NULL)

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