Mercurial > trustbridge
comparison 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 |
comparison
equal
deleted
inserted
replaced
977:9ad1f18799fb | 978:d92b1594e974 |
---|---|
91 | 91 |
92 exe_path_len = strlen(inst_dir) + strlen(NSS_PROCESS_NAME); | 92 exe_path_len = strlen(inst_dir) + strlen(NSS_PROCESS_NAME); |
93 argv[0] = xmalloc (exe_path_len + 1); | 93 argv[0] = xmalloc (exe_path_len + 1); |
94 | 94 |
95 ret = snprintf(argv[0], exe_path_len + 1, "%s%s", inst_dir, NSS_PROCESS_NAME); | 95 ret = snprintf(argv[0], exe_path_len + 1, "%s%s", inst_dir, NSS_PROCESS_NAME); |
96 xfree (inst_dir); | |
96 if (ret < 0 || (size_t) ret != exe_path_len) | 97 if (ret < 0 || (size_t) ret != exe_path_len) |
97 { | 98 { |
98 ERRORPRINTF ("Error setting executable variable.\n"); | 99 ERRORPRINTF ("Error setting executable variable.\n"); |
99 xfree (argv[0]); | 100 xfree (argv[0]); |
100 return -1; | 101 return -1; |
198 int | 199 int |
199 write_stores_nss (char **to_install, char **to_remove) | 200 write_stores_nss (char **to_install, char **to_remove) |
200 { | 201 { |
201 struct passwd *usr_it = NULL; | 202 struct passwd *usr_it = NULL; |
202 uid_t my_uid = geteuid(); | 203 uid_t my_uid = geteuid(); |
204 pid_t childprocess = -1; | |
205 int status = -1; | |
203 | 206 |
204 if (my_uid != 0) | 207 if (my_uid != 0) |
205 { | 208 { |
206 /* Running as a user */ | 209 /* Running as a user */ |
207 char *homedir = getenv ("HOME"); | 210 char *homedir = getenv ("HOME"); |
208 pid_t childprocess = -1; /* Only one child for single user installation */ | |
209 int status = -1; | |
210 if (!homedir) | 211 if (!homedir) |
211 { | 212 { |
212 ERRORPRINTF ("Failed to find home directory\n"); | 213 ERRORPRINTF ("Failed to find home directory\n"); |
213 } | 214 } |
214 | 215 |
216 /* Only one child for single user installation */ | |
215 childprocess = start_procces_for_user (to_install, to_remove, | 217 childprocess = start_procces_for_user (to_install, to_remove, |
216 my_uid, getgid(), homedir); | 218 my_uid, getgid(), homedir); |
217 | 219 |
218 if (childprocess == -1) | 220 if (childprocess == -1) |
219 { | 221 { |
227 ERRORPRINTF ("Waitpid failed.\n"); | 229 ERRORPRINTF ("Waitpid failed.\n"); |
228 return -1; | 230 return -1; |
229 } | 231 } |
230 | 232 |
231 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; | |
232 } | 251 } |
233 | 252 |
234 setpwent(); | 253 setpwent(); |
235 | 254 |
236 while ((usr_it = getpwent ()) != NULL) | 255 while ((usr_it = getpwent ()) != NULL) |