Mercurial > trustbridge
comparison cinst/mozilla.c @ 989:1cd1bfe82fc2
(issue86) Fix Firefox / Thunderbird default profile path and make created files readable.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Fri, 29 Aug 2014 19:18:31 +0200 |
parents | ca89cf228a5b |
children | a80abef948fa |
comparison
equal
deleted
inserted
replaced
988:ca89cf228a5b | 989:1cd1bfe82fc2 |
---|---|
64 #include <stdbool.h> | 64 #include <stdbool.h> |
65 #include <stdio.h> | 65 #include <stdio.h> |
66 #include <stdlib.h> | 66 #include <stdlib.h> |
67 #include <string.h> | 67 #include <string.h> |
68 #include <sys/types.h> | 68 #include <sys/types.h> |
69 #include <sys/stat.h> | |
69 | 70 |
70 #define DEBUGPREFIX "MOZ-" | 71 #define DEBUGPREFIX "MOZ-" |
71 #include "logging.h" | 72 #include "logging.h" |
72 | 73 |
73 #include "certhelp.h" | 74 #include "certhelp.h" |
78 #include "util.h" | 79 #include "util.h" |
79 | 80 |
80 #ifndef _WIN32 | 81 #ifndef _WIN32 |
81 #define CONFDIRS ".mozilla", ".thunderbird" | 82 #define CONFDIRS ".mozilla", ".thunderbird" |
82 /* Default installation directory of ubuntu 14.4 is respected */ | 83 /* Default installation directory of ubuntu 14.4 is respected */ |
83 #define MOZILLA_DEFAULTS "/etc/thunderbird", "/etc/firefox" | 84 #define MOZILLA_DEFAULTS "/usr/lib/thunderbird/defaults", "/usr/lib/firefox/browser/defaults" |
85 #define MOZILLA_DBNAMES "cert8.db", "key3.db", "secmod.db" | |
84 #define NSSSHARED ".pki/nssdb" | 86 #define NSSSHARED ".pki/nssdb" |
85 #define NSSSHARED_GLOBAL "/etc/skel/.pki/nssdb" | 87 #define NSSSHARED_GLOBAL "/etc/skel/.pki/nssdb" |
86 #define TARGET_LINUX 1 | 88 #define TARGET_LINUX 1 |
87 #define DIRSEP "/" | 89 #define DIRSEP "/" |
88 #else | 90 #else |
89 #define MOZILLA_DEFAULTS "Mozilla Firefox\\browser\\defaults", "Mozilla Thunderbird\\defaults" | 91 #define MOZILLA_DEFAULTS "Mozilla Firefox\\browser\\defaults", "Mozilla Thunderbird\\defaults" |
92 #define MOZILLA_DBNAMES NULL | |
90 #define CONFDIRS "Mozilla", "Thunderbird" | 93 #define CONFDIRS "Mozilla", "Thunderbird" |
91 #define NSSSHARED "" | 94 #define NSSSHARED "" |
92 #define TARGET_LINUX 0 | 95 #define TARGET_LINUX NULL |
93 #define DIRSEP "\\" | 96 #define DIRSEP "\\" |
94 #endif | 97 #endif |
95 | 98 |
96 /** | 99 /** |
97 * @brief Length of string buffers used | 100 * @brief Length of string buffers used |
301 { | 304 { |
302 DEBUGPRINTF("No ini files found - will do nothing!\n"); | 305 DEBUGPRINTF("No ini files found - will do nothing!\n"); |
303 } | 306 } |
304 return inis; | 307 return inis; |
305 } | 308 } |
309 | |
310 | |
311 /** @brief make the default nss databases readable. | |
312 * | |
313 * This uses the static paths definied in this code to ensure | |
314 * that only the defaults are touched. | |
315 * | |
316 */ | |
317 #ifndef WIN32 | |
318 static void | |
319 make_defaults_readable() | |
320 { | |
321 const char *confdirs[] = { MOZILLA_DEFAULTS, NULL }; | |
322 const char *filenames[] = { MOZILLA_DBNAMES, NULL }; | |
323 | |
324 mode_t access_mask = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; | |
325 | |
326 for (int i=0; confdirs[i] != NULL; i++) | |
327 { | |
328 for (int j=0; filenames[j] != NULL; j++) | |
329 { | |
330 char *realpath = NULL, | |
331 *path = NULL; | |
332 xasprintf (&path, "%s/profile/%s", confdirs[i], filenames[j]); | |
333 realpath = port_realpath(path); | |
334 xfree(path); | |
335 if (!realpath) | |
336 { | |
337 syslog_error_printf("Failed to find %s \n", realpath); | |
338 continue; | |
339 } | |
340 if (chmod(realpath, access_mask)) | |
341 { | |
342 syslog_error_printf("Failed to set access_mask on file.\n"); | |
343 } | |
344 xfree (realpath); | |
345 } | |
346 } | |
347 } | |
348 #endif | |
306 | 349 |
307 /** | 350 /** |
308 * @brief Collect the default profile directories for mozilla software | 351 * @brief Collect the default profile directories for mozilla software |
309 * | 352 * |
310 * If the default directory is found but not the profiles subdirectory | 353 * If the default directory is found but not the profiles subdirectory |
762 exit(ERR_MOZ_INVALID_INPUT); | 805 exit(ERR_MOZ_INVALID_INPUT); |
763 } | 806 } |
764 } | 807 } |
765 } | 808 } |
766 | 809 |
767 | |
768 int | 810 int |
769 main (int argc, char **argv) | 811 main (int argc, char **argv) |
770 { | 812 { |
771 char **dbdirs; | 813 char **dbdirs; |
772 seciteml_t *certs_to_remove = NULL; | 814 seciteml_t *certs_to_remove = NULL; |
818 DEBUGPRINTF("NEW List of installed certs:\n"); | 860 DEBUGPRINTF("NEW List of installed certs:\n"); |
819 for (int i=0; dbdirs[i] != NULL; i++) | 861 for (int i=0; dbdirs[i] != NULL; i++) |
820 DEBUG_nss_list_certs(dbdirs[i]); | 862 DEBUG_nss_list_certs(dbdirs[i]); |
821 #endif | 863 #endif |
822 | 864 |
865 #ifndef WIN32 | |
866 if (is_elevated()) | |
867 { | |
868 make_defaults_readable(); | |
869 } | |
870 #endif | |
871 | |
823 strv_free(dbdirs); | 872 strv_free(dbdirs); |
824 } | 873 } |
825 | 874 |
826 fclose(input_stream); | 875 fclose(input_stream); |
827 | 876 |