comparison cinst/mozilla.c @ 308:ab69d268b5c8

Add NSS shared DB on Linux to stores operated on.
author Sascha Wilde <wilde@intevation.de>
date Thu, 03 Apr 2014 18:23:09 +0200
parents a0c5eba8eb41
children fa37384b86b6
comparison
equal deleted inserted replaced
284:a0c5eba8eb41 308:ab69d268b5c8
64 #include "strhelp.h" 64 #include "strhelp.h"
65 #include "nss-secitemlist.h" 65 #include "nss-secitemlist.h"
66 66
67 #ifndef _WIN32 67 #ifndef _WIN32
68 #define CONFDIRS ".mozilla", ".thunderbird" 68 #define CONFDIRS ".mozilla", ".thunderbird"
69 #define NSSSHARED ".pki/nssdb"
69 #define TARGET_LINUX 1 70 #define TARGET_LINUX 1
70 #else 71 #else
71 #define CONFDIRS "Mozilla", "Thunderbird" 72 #define CONFDIRS "Mozilla", "Thunderbird"
72 #define TARGET_LINUX 0 73 #define TARGET_LINUX 0
73 #endif 74 #endif
279 * @return NULL terminated array of strings containing the absolute 280 * @return NULL terminated array of strings containing the absolute
280 * path of the profile directories. The array needs to be freed by the 281 * path of the profile directories. The array needs to be freed by the
281 * caller. 282 * caller.
282 */ 283 */
283 static char** 284 static char**
284 get_all_profile_dirs() 285 get_all_nssdb_dirs()
285 { 286 {
286 char **mozinis, **pdirs; 287 char **mozinis, **pdirs;
287 char **alldirs = NULL; 288 char **alldirs = NULL;
289 /* Search Mozilla/Firefox/Thunderbird profiles */
288 if ((mozinis = get_profile_inis()) != NULL) 290 if ((mozinis = get_profile_inis()) != NULL)
289 { 291 {
290 for (int i=0; mozinis[i] != NULL; i++) 292 for (int i=0; mozinis[i] != NULL; i++)
291 { 293 {
292 pdirs = 294 pdirs =
299 } 301 }
300 strv_free(pdirs); 302 strv_free(pdirs);
301 } 303 }
302 } 304 }
303 strv_free(mozinis); 305 strv_free(mozinis);
306 }
307 /* Search for NSS shared DB (used by Chrome/Chromium on GNU/Linux) */
308 if (TARGET_LINUX)
309 {
310 char buf[LINEBUFLEN], *fqpath;
311 snprintf(buf, LINEBUFLEN, "%s/%s",
312 get_conf_basedir(), NSSSHARED);
313 if ((fqpath = port_realpath(buf)) != NULL)
314 {
315 snprintf(buf, LINEBUFLEN, "sql:%s", fqpath);
316 strv_append(&alldirs, buf, strlen(buf));
317 free(fqpath);
318 }
304 } 319 }
305 return alldirs; 320 return alldirs;
306 } 321 }
307 322
308 #ifdef DEBUGOUTPUT 323 #ifdef DEBUGOUTPUT
583 598
584 599
585 int 600 int
586 main () 601 main ()
587 { 602 {
588 char **pdirs; 603 char **dbdirs;
589 seciteml_t *certs_to_remove = NULL; 604 seciteml_t *certs_to_remove = NULL;
590 seciteml_t *certs_to_add = NULL; 605 seciteml_t *certs_to_add = NULL;
591 606
592 pdirs = 607 dbdirs =
593 get_all_profile_dirs(); 608 get_all_nssdb_dirs();
594 609
595 if (pdirs != NULL) 610 if (dbdirs != NULL)
596 { 611 {
597 parse_commands(&certs_to_add, &certs_to_remove); 612 parse_commands(&certs_to_add, &certs_to_remove);
598 613
599 #ifdef DEBUGOUTPUT 614 #ifdef DEBUGOUTPUT
600 DEBUGPRINTF("OLD List of installed certs:\n"); 615 DEBUGPRINTF("OLD List of installed certs:\n");
601 for (int i=0; pdirs[i] != NULL; i++) 616 for (int i=0; dbdirs[i] != NULL; i++)
602 DEBUG_nss_list_certs(pdirs[i]); 617 DEBUG_nss_list_certs(dbdirs[i]);
603 #endif 618 #endif
604 619
605 if (! apply_to_certs_and_profiles(remove_cert, &certs_to_remove, pdirs)) 620 if (! apply_to_certs_and_profiles(remove_cert, &certs_to_remove, dbdirs))
606 return_code |= WARN_MOZ_COULD_NOT_REMOVE_CERT; 621 return_code |= WARN_MOZ_COULD_NOT_REMOVE_CERT;
607 622
608 if (! apply_to_certs_and_profiles(import_cert, &certs_to_add, pdirs)) 623 if (! apply_to_certs_and_profiles(import_cert, &certs_to_add, dbdirs))
609 return_code |= WARN_MOZ_COULD_NOT_ADD_CERT; 624 return_code |= WARN_MOZ_COULD_NOT_ADD_CERT;
610 625
611 #ifdef DEBUGOUTPUT 626 #ifdef DEBUGOUTPUT
612 DEBUGPRINTF("NEW List of installed certs:\n"); 627 DEBUGPRINTF("NEW List of installed certs:\n");
613 for (int i=0; pdirs[i] != NULL; i++) 628 for (int i=0; dbdirs[i] != NULL; i++)
614 DEBUG_nss_list_certs(pdirs[i]); 629 DEBUG_nss_list_certs(dbdirs[i]);
615 #endif 630 #endif
616 631
617 strv_free(pdirs); 632 strv_free(dbdirs);
618 } 633 }
619 exit(return_code); 634 exit(return_code);
620 } 635 }

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