+
+
+/**
+ * Check whether an executable exists and possibly
+ * if the suid bit is set on the file.
+ * Attempts to find the file using the current
+ * PATH environment variable as a search path.
+ *
+ * @param binary the name of the file to check.
+ * W32: must not have an .exe suffix.
+ * @return GNUNET_YES if the file is SUID,
+ * GNUNET_NO if not SUID (but binary exists)
+ * GNUNET_SYSERR on error (no such binary or not executable)
+ */
+int
+GNUNET_OS_check_helper_binary (const char *binary)
+{
+ struct stat statbuf;
+ char *p;
+ char *pf;
+#ifdef MINGW
+ SOCKET rawsock;
+ char *binaryexe;
+
+ GNUNET_asprintf (&binaryexe, "%s.exe", binary);
+ if ( (GNUNET_YES == GNUNET_STRINGS_path_is_absolute (binaryexe, GNUNET_NO,
+ NULL, NULL)) ||
+ (0 == strncmp (binary, "./", 2)) )
+ p = GNUNET_strdup (binaryexe);
+ else
+ {
+ p = get_path_from_PATH (binaryexe);
+ if (NULL != p)
+ {
+ GNUNET_asprintf (&pf, "%s/%s", p, binaryexe);
+ GNUNET_free (p);
+ p = pf;
+ }
+ }
+ GNUNET_free (binaryexe);
+#else
+ if ( (GNUNET_YES == GNUNET_STRINGS_path_is_absolute (binary, GNUNET_NO,
+ NULL, NULL)) ||
+ (0 == strncmp (binary, "./", 2)) )
+ p = GNUNET_strdup (binary);
+ else
+ {
+ p = get_path_from_PATH (binary);
+ if (NULL != p)
+ {
+ GNUNET_asprintf (&pf, "%s/%s", p, binary);
+ GNUNET_free (p);
+ p = pf;
+ }
+ }