comparison cinst/nssstore_win.c @ 1084:b8fb6bf7f980

(issue118) Add signature check for cinst.exe and mozilla.exe
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 11 Sep 2014 15:17:39 +0200
parents f110a3f6e387
children fd85a02d771d
comparison
equal deleted inserted replaced
1083:d6dc1144895b 1084:b8fb6bf7f980
49 #include <aclapi.h> 49 #include <aclapi.h>
50 50
51 #include "logging.h" 51 #include "logging.h"
52 #include "util.h" 52 #include "util.h"
53 #include "strhelp.h" 53 #include "strhelp.h"
54 #include "binverify.h"
54 55
55 #ifndef APPNAME 56 #ifndef APPNAME
56 #define APPNAME L"cinst" 57 #define APPNAME L"cinst"
57 #endif 58 #endif
58 59
691 STARTUPINFOW siStartInfo = {0}; 692 STARTUPINFOW siStartInfo = {0};
692 BOOL success = FALSE; 693 BOOL success = FALSE;
693 char *install_dir = get_install_dir(); 694 char *install_dir = get_install_dir();
694 wchar_t *w_inst_dir; 695 wchar_t *w_inst_dir;
695 size_t w_path_len = 0; 696 size_t w_path_len = 0;
697 bin_verify_result v_res;
696 698
697 if (!selection_file) 699 if (!selection_file)
698 { 700 {
699 ERRORPRINTF ("Invalid call\n"); 701 ERRORPRINTF ("Invalid call\n");
700 return false; 702 return false;
742 744
743 if (lpCommandLine == NULL) 745 if (lpCommandLine == NULL)
744 { 746 {
745 ERRORPRINTF ("Failed to build command line."); 747 ERRORPRINTF ("Failed to build command line.");
746 xfree (lpApplicationPath); 748 xfree (lpApplicationPath);
749 return false;
750 }
751
752 /* Verify the binary */
753 {
754 char *utf8_name = wchar_to_utf8 (lpApplicationPath, wcslen(lpApplicationPath));
755 v_res = verify_binary (utf8_name, strlen(utf8_name));
756 xfree(utf8_name);
757 }
758
759 if (v_res.result != VerifyValid)
760 {
761 ERRORPRINTF ("Failed to verify the NSS installer.\n");
762 syslog_error_printf ("Integrity check of the certificate installation subprocess for NSS failed.\n");
763 xfree (lpApplicationPath);
764 xfree (lpCommandLine);
747 return false; 765 return false;
748 } 766 }
749 767
750 DEBUGPRINTF ("Starting %S with command line %S\n", lpApplicationPath, lpCommandLine); 768 DEBUGPRINTF ("Starting %S with command line %S\n", lpApplicationPath, lpCommandLine);
751 769
758 0, /* Creation flags. */ 776 0, /* Creation flags. */
759 NULL, /* Inherit environment */ 777 NULL, /* Inherit environment */
760 NULL, /* Current working directory */ 778 NULL, /* Current working directory */
761 &siStartInfo, 779 &siStartInfo,
762 &piProcInfo); 780 &piProcInfo);
781 fclose (v_res.fptr);
763 xfree (lpApplicationPath); 782 xfree (lpApplicationPath);
764 xfree (lpCommandLine); 783 xfree (lpCommandLine);
765 if (!success) 784 if (!success)
766 { 785 {
767 PRINTLASTERROR ("Failed to create process.\n"); 786 PRINTLASTERROR ("Failed to create process.\n");

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