return CreateProcess (appname, cmdline, NULL, NULL, FALSE, create_flags, env, cwd, startup, process_info);
}
+static gboolean
+is_readable (const char *prog)
+{
+ struct stat buf;
+ if (access (prog, R_OK) != 0)
+ return FALSE;
+ if (stat (prog, &buf))
+ return FALSE;
+ if (S_ISREG (buf.st_mode))
+ return TRUE;
+ return FALSE;
+}
+
static gboolean
is_executable (const char *prog)
{
prog = g_strdup (unquoted);
/* Executable existing ? */
- if (!is_executable (prog)) {
+ if (!is_readable (prog)) {
DEBUG ("%s: Couldn't find executable %s",
__func__, prog);
g_free (unquoted);
prog = g_strdup_printf ("%s/%s", curdir, unquoted);
g_free (curdir);
- /* And make sure it's executable */
- if (!is_executable (prog)) {
+ /* And make sure it's readable */
+ if (!is_readable (prog)) {
DEBUG ("%s: Couldn't find executable %s",
__func__, prog);
g_free (unquoted);
prog = g_strdup (token);
/* Executable existing ? */
- if (!is_executable (prog)) {
+ if (!is_readable (prog)) {
DEBUG ("%s: Couldn't find executable %s",
__func__, token);
g_free (token);
/* I assume X_OK is the criterion to use,
* rather than F_OK
+ *
+ * X_OK is too strict *if* the target is a CLR binary
*/
- if (!is_executable (prog)) {
+ if (!is_readable (prog)) {
g_free (prog);
prog = g_find_program_in_path (token);
if (prog == NULL) {
goto free_strings;
}
}
+ } else {
+ if (!is_executable (prog)) {
+ DEBUG ("%s: Executable permisson not set on %s", __func__, prog);
+ g_free (prog);
+ SetLastError (ERROR_ACCESS_DENIED);
+ goto free_strings;
+ }
}
if (args_after_prog != NULL && *args_after_prog) {
unload-appdomain-on-shutdown.cs \
block_guard_restore_aligment_on_exit.cs \
thread_static_gc_layout.cs \
- sleep.cs
+ sleep.cs \
+ bug-17537.cs
TEST_CS_SRC_DIST= \
$(BASE_TEST_CS_SRC) \
bug-382986.exe: bug-382986.cs bug-382986-lib.dll
$(MCS) -out:$@ -r:bug-382986-lib.dll $(srcdir)/bug-382986.cs
+EXTRA_DIST += bug-17537-helper.cs
+bug-17537-helper.exe: bug-17537-helper.cs
+ $(MCS) -out:$@ $(srcdir)/bug-17537-helper.cs
+ chmod -x $@
+
+bug-17537.exe: bug-17537.cs bug-17537-helper.exe
+ $(MCS) -out:$@ $(srcdir)/bug-17537.cs
+
EXTRA_DIST += coreclr-security.cs
coreclr-security.exe : coreclr-security.cs
--- /dev/null
+using System;
+using System.IO;
+using System.Diagnostics;
+
+public class Test {
+ public static int Main(string[] args)
+ {
+ // Only run this test on Unix
+ int pl = (int) Environment.OSVersion.Platform;
+ if ((pl != 4) && (pl != 6) && (pl != 128)) {
+ return 0;
+ }
+
+ // Try to invoke the helper assembly
+ // Return 0 only if it is successful
+ try
+ {
+ var name = "bug-17537-helper.exe";
+ Console.WriteLine ("Launching subprocess: {0}", name);
+ var p = new Process();
+ p.StartInfo.FileName = Path.Combine (AppDomain.CurrentDomain.BaseDirectory + name);
+ p.StartInfo.UseShellExecute = false;
+
+ var result = p.Start();
+ p.WaitForExit(1000);
+ if (result) {
+ Console.WriteLine ("Subprocess started successfully");
+ return 0;
+ } else {
+ Console.WriteLine ("Subprocess failure");
+ return 1;
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine ("Subprocess exception");
+ Console.WriteLine (e.Message);
+ return 1;
+ }
+ }
+}