comparison cinst/nssstore_win.c @ 985:1743895b39b8

(issue86) Install into default profile folders on windows.
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 29 Aug 2014 17:13:30 +0200
parents 427e2e18b8c8
children 1c1964c27b39 6684e5012b7a
comparison
equal deleted inserted replaced
984:faf58e9f518b 985:1743895b39b8
626 * Starts the NSS installation process for the current user 626 * Starts the NSS installation process for the current user
627 * 627 *
628 * @param [in] selection_file filename of the file containing 628 * @param [in] selection_file filename of the file containing
629 * the users install / remove selection. 629 * the users install / remove selection.
630 * 630 *
631 * @param [in] drop_privileges weather or not elevated privileges
632 * should be dropped before starting the process.
633 *
631 * @returns true on success, false on error. 634 * @returns true on success, false on error.
632 */ 635 */
633 static bool 636 static bool
634 start_procces_for_user (wchar_t *selection_file) 637 start_procces_for_user (wchar_t *selection_file, bool drop_privileges)
635 { 638 {
636 HANDLE hToken = NULL; 639 HANDLE hToken = NULL;
637 LPWSTR lpApplicationPath = NULL, 640 LPWSTR lpApplicationPath = NULL,
638 lpCommandLine = NULL; 641 lpCommandLine = NULL;
639 PROCESS_INFORMATION piProcInfo = {0}; 642 PROCESS_INFORMATION piProcInfo = {0};
668 wcscat_s (lpApplicationPath, w_path_len, L"\\" NSS_APP_NAME); 671 wcscat_s (lpApplicationPath, w_path_len, L"\\" NSS_APP_NAME);
669 672
670 /* set up handles. stdin and stdout go to the same stdout*/ 673 /* set up handles. stdin and stdout go to the same stdout*/
671 siStartInfo.cb = sizeof (STARTUPINFO); 674 siStartInfo.cb = sizeof (STARTUPINFO);
672 675
673 if (is_elevated()) 676 if (is_elevated() && drop_privileges)
674 { 677 {
675 /* Start the child process as normal user */ 678 /* Start the child process as normal user */
676 hToken = get_restricted_token (); 679 hToken = get_restricted_token ();
677 if (hToken == NULL) 680 if (hToken == NULL)
678 { 681 {
882 DEBUGPRINTF ("Wrote selection file. Loc: %S\n", selection_file_name); 885 DEBUGPRINTF ("Wrote selection file. Loc: %S\n", selection_file_name);
883 886
884 if (is_elevated()) 887 if (is_elevated())
885 { 888 {
886 register_proccesses_for_others (selection_file_name); 889 register_proccesses_for_others (selection_file_name);
887 } 890 /* Start the NSS process once with elevated rights to
888 891 install into the default profile directories. */
889 if (!start_procces_for_user (selection_file_name)) 892 if (!start_procces_for_user (selection_file_name, false))
893 {
894 ERRORPRINTF ("Failed to run NSS installation process for default folders.\n");
895 xfree(selection_file_name);
896 return -1;
897 }
898 }
899
900 if (!start_procces_for_user (selection_file_name, true))
890 { 901 {
891 ERRORPRINTF ("Failed to run NSS installation process.\n"); 902 ERRORPRINTF ("Failed to run NSS installation process.\n");
892 xfree(selection_file_name); 903 xfree(selection_file_name);
893 return -1; 904 return -1;
894 } 905 }

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