diff options
Diffstat (limited to 'src/util/os_installation.c')
-rw-r--r-- | src/util/os_installation.c | 78 |
1 files changed, 3 insertions, 75 deletions
diff --git a/src/util/os_installation.c b/src/util/os_installation.c index 104a98da6..c8590c8fb 100644 --- a/src/util/os_installation.c +++ b/src/util/os_installation.c | |||
@@ -764,26 +764,6 @@ GNUNET_OS_check_helper_binary(const char *binary, | |||
764 | char *p; | 764 | char *p; |
765 | char *pf; | 765 | char *pf; |
766 | 766 | ||
767 | #ifdef MINGW | ||
768 | char *binaryexe; | ||
769 | |||
770 | GNUNET_asprintf(&binaryexe, "%s.exe", binary); | ||
771 | if ((GNUNET_YES == | ||
772 | GNUNET_STRINGS_path_is_absolute(binaryexe, GNUNET_NO, NULL, NULL)) || | ||
773 | (0 == strncmp(binary, "./", 2))) | ||
774 | p = GNUNET_strdup(binaryexe); | ||
775 | else | ||
776 | { | ||
777 | p = get_path_from_PATH(binaryexe); | ||
778 | if (NULL != p) | ||
779 | { | ||
780 | GNUNET_asprintf(&pf, "%s/%s", p, binaryexe); | ||
781 | GNUNET_free(p); | ||
782 | p = pf; | ||
783 | } | ||
784 | } | ||
785 | GNUNET_free(binaryexe); | ||
786 | #else | ||
787 | if ((GNUNET_YES == | 767 | if ((GNUNET_YES == |
788 | GNUNET_STRINGS_path_is_absolute(binary, GNUNET_NO, NULL, NULL)) || | 768 | GNUNET_STRINGS_path_is_absolute(binary, GNUNET_NO, NULL, NULL)) || |
789 | (0 == strncmp(binary, "./", 2))) | 769 | (0 == strncmp(binary, "./", 2))) |
@@ -800,7 +780,7 @@ GNUNET_OS_check_helper_binary(const char *binary, | |||
800 | p = pf; | 780 | p = pf; |
801 | } | 781 | } |
802 | } | 782 | } |
803 | #endif | 783 | |
804 | if (NULL == p) | 784 | if (NULL == p) |
805 | { | 785 | { |
806 | LOG(GNUNET_ERROR_TYPE_INFO, | 786 | LOG(GNUNET_ERROR_TYPE_INFO, |
@@ -814,14 +794,14 @@ GNUNET_OS_check_helper_binary(const char *binary, | |||
814 | GNUNET_free(p); | 794 | GNUNET_free(p); |
815 | return GNUNET_SYSERR; | 795 | return GNUNET_SYSERR; |
816 | } | 796 | } |
817 | #ifndef MINGW | 797 | |
818 | if (0 == getuid()) | 798 | if (0 == getuid()) |
819 | { | 799 | { |
820 | /* as we run as root, we don't insist on SUID */ | 800 | /* as we run as root, we don't insist on SUID */ |
821 | GNUNET_free(p); | 801 | GNUNET_free(p); |
822 | return GNUNET_YES; | 802 | return GNUNET_YES; |
823 | } | 803 | } |
824 | #endif | 804 | |
825 | if (0 != stat(p, &statbuf)) | 805 | if (0 != stat(p, &statbuf)) |
826 | { | 806 | { |
827 | LOG_STRERROR_FILE(GNUNET_ERROR_TYPE_WARNING, "stat", p); | 807 | LOG_STRERROR_FILE(GNUNET_ERROR_TYPE_WARNING, "stat", p); |
@@ -830,7 +810,6 @@ GNUNET_OS_check_helper_binary(const char *binary, | |||
830 | } | 810 | } |
831 | if (check_suid) | 811 | if (check_suid) |
832 | { | 812 | { |
833 | #ifndef MINGW | ||
834 | (void)params; | 813 | (void)params; |
835 | if ((0 != (statbuf.st_mode & S_ISUID)) && (0 == statbuf.st_uid)) | 814 | if ((0 != (statbuf.st_mode & S_ISUID)) && (0 == statbuf.st_uid)) |
836 | { | 815 | { |
@@ -841,57 +820,6 @@ GNUNET_OS_check_helper_binary(const char *binary, | |||
841 | _("Binary `%s' exists, but is not SUID\n"), | 820 | _("Binary `%s' exists, but is not SUID\n"), |
842 | p); | 821 | p); |
843 | /* binary exists, but not SUID */ | 822 | /* binary exists, but not SUID */ |
844 | #else | ||
845 | STARTUPINFO start; | ||
846 | char parameters[512]; | ||
847 | PROCESS_INFORMATION proc; | ||
848 | DWORD exit_value; | ||
849 | |||
850 | GNUNET_snprintf(parameters, sizeof(parameters), "-d %s", params); | ||
851 | memset(&start, 0, sizeof(start)); | ||
852 | start.cb = sizeof(start); | ||
853 | memset(&proc, 0, sizeof(proc)); | ||
854 | |||
855 | |||
856 | // Start the child process. | ||
857 | if (!(CreateProcess( | ||
858 | p, // current windows (2k3 and up can handle / instead of \ in paths)) | ||
859 | parameters, // execute dryrun/priviliege checking mode | ||
860 | NULL, // Process handle not inheritable | ||
861 | NULL, // Thread handle not inheritable | ||
862 | FALSE, // Set handle inheritance to FALSE | ||
863 | CREATE_DEFAULT_ERROR_MODE, // No creation flags | ||
864 | NULL, // Use parent's environment block | ||
865 | NULL, // Use parent's starting directory | ||
866 | &start, // Pointer to STARTUPINFO structure | ||
867 | &proc) // Pointer to PROCESS_INFORMATION structure | ||
868 | )) | ||
869 | { | ||
870 | LOG(GNUNET_ERROR_TYPE_ERROR, | ||
871 | _("CreateProcess failed for binary %s (%d).\n"), | ||
872 | p, | ||
873 | GetLastError()); | ||
874 | return GNUNET_SYSERR; | ||
875 | } | ||
876 | |||
877 | // Wait until child process exits. | ||
878 | WaitForSingleObject(proc.hProcess, INFINITE); | ||
879 | |||
880 | if (!GetExitCodeProcess(proc.hProcess, &exit_value)) | ||
881 | { | ||
882 | LOG(GNUNET_ERROR_TYPE_ERROR, | ||
883 | _("GetExitCodeProcess failed for binary %s (%d).\n"), | ||
884 | p, | ||
885 | GetLastError()); | ||
886 | return GNUNET_SYSERR; | ||
887 | } | ||
888 | // Close process and thread handles. | ||
889 | CloseHandle(proc.hProcess); | ||
890 | CloseHandle(proc.hThread); | ||
891 | |||
892 | if (!exit_value) | ||
893 | return GNUNET_YES; | ||
894 | #endif | ||
895 | } | 823 | } |
896 | GNUNET_free(p); | 824 | GNUNET_free(p); |
897 | return GNUNET_NO; | 825 | return GNUNET_NO; |