<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -83,7 +83,13 @@ class CompilerGenericGNU {
    * @return string
    */
   public function get_exec_string() {
-
+	if (!empty (config::$chroot_dir)) {
+		$chroot = realpath (config::$chroot_dir);
+		$output = realpath ($this-&gt;output_exec);
+		assert (substr ($output, 0, strlen ($chroot))
+			== $chroot);
+		return substr ($output, strlen($chroot));
+	}
 	return $this-&gt;output_exec;
   }
 </diff>
      <filename>backend/programs/compiler/CompilerGenericGNU.inc</filename>
    </modified>
    <modified>
      <diff>@@ -40,7 +40,10 @@ class CompilerGenericInterpreter
 	public function compile($pathtocode)  
 	{
 		$this-&gt;pathtocode = tempnam (config::$compile_temp_directory, &quot;a&quot;);
+		assert (is_file ($pathtocode));
 		copy ($pathtocode, $this-&gt;pathtocode);
+		assert (is_file ($this-&gt;pathtocode));
+		chmod ($this-&gt;pathtocode, 0755);
 		return true;
 	}
 
@@ -53,8 +56,11 @@ class CompilerGenericInterpreter
 	{
 		$prefix = &quot;&quot;;
 		if (!empty (config::$chroot_dir)) $prefix = config::$chroot_dir;
-		return &quot;$prefix/usr/bin/env &quot; . $this-&gt;interpreter 
-			. &quot;  &quot; .$this-&gt;pathtocode ;
+	
+		assert (substr ($this-&gt;pathtocode, 0, strlen ($prefix)) == $prefix);
+		$relpath = substr ($this-&gt;pathtocode, strlen ($prefix));
+		return &quot;/usr/bin/env &quot; . $this-&gt;interpreter 
+			. &quot; &quot; .$relpath ;
 	}
 	
 	public function get_exec_dir() </diff>
      <filename>backend/programs/compiler/CompilerGenericInterpreter.inc</filename>
    </modified>
    <modified>
      <diff>@@ -257,12 +257,6 @@ int subprocess (int argc, char* argv[])
 			fprintf (stderr, &quot;debug: not redirecting stderr on purpose.\n&quot;);
 	}
 	
-	if (chrootdir) {
-		argv[0] = argv[0] + strlen(chrootdir) - 1 ;
-		argv[0][0] = '/' ; 
-		fprintf(stderr, &quot;The exec is at %s relative to %s\n&quot;, argv[0], chrootdir);
-	}
-	
 	commands = (char**) malloc (sizeof (char*)*(argc + 1));
 	for (i = 0; i &lt; argc; i++)
 		commands [i] = argv[i];
@@ -286,11 +280,6 @@ int main (int argc, char* argv[])
 	if (limit_timehard &lt; 1 + (int) ceil (limit_time))
 		limit_timehard = 1 + (int) ceil (limit_time);
 	
-	if (chrootdir &amp;&amp; strncmp(chrootdir, argv[cmd_start_index], strlen(chrootdir)) != 0 ) {
-		fprintf(stderr, &quot;The executable file must be on the chroot directory&quot;);
-		exit (1);
-	}
-	
 	/* close inherited file descriptors. Is there a better way? */
 	for (i = 3; i &lt; (1&lt;&lt;16); i++)
 		close (i);</diff>
      <filename>backend/programs/runner.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d60624a303ea3c3d986cd75da806f120d61f9fb1</id>
    </parent>
  </parents>
  <author>
    <name>Arnold Noronha</name>
    <email>arnstein87@gmail.com</email>
  </author>
  <url>http://github.com/tdrhq/opc/commit/916abfb9ac3a8c5db89f10d0510d767c34b4a85d</url>
  <id>916abfb9ac3a8c5db89f10d0510d767c34b4a85d</id>
  <committed-date>2009-10-15T07:33:09-07:00</committed-date>
  <authored-date>2009-10-15T07:33:09-07:00</authored-date>
  <message>make the runner code not do the filename replacement to the chroot dir, since arguments then become hard to send. Instead, make the compiler code do that.</message>
  <tree>58318352f9cf6b503c5bfabf3eab0ab4d45aaf1a</tree>
  <committer>
    <name>Arnold Noronha</name>
    <email>arnstein87@gmail.com</email>
  </committer>
</commit>
