Working bot.
[xavierbot.git] / ocamlbotwrapper.c.in
index 76aa4cd..b10b9c7 100644 (file)
@@ -1,5 +1,5 @@
 /* -*- C -*-
 /* -*- C -*-
- * $Id: ocamlbotwrapper.c.in,v 1.1 2007/06/28 19:47:26 rjones Exp $
+ * $Id: ocamlbotwrapper.c.in,v 1.2 2007/06/28 20:49:10 rjones Exp $
  * SUID wrapper around ocaml program.
  */
 
  * SUID wrapper around ocaml program.
  */
 
@@ -16,8 +16,32 @@ const char *new_environ[] = {
 int
 main ()
 {
 int
 main ()
 {
+  /* Don't worry about races here because we're just checking that
+   * the installation looks reasonable.
+   *
+   * Die if the init script does not exist. */
+  if (access ("@INITSCRIPT@", R_OK) == -1) {
+    perror ("@INITSCRIPT@");
+    exit (1);
+  }
+
+  /* Die if the ocaml program does not exist. */
+  if (access ("@OCAML@", R_OK|X_OK) == -1) {
+    perror ("@OCAML@");
+    exit (1);
+  }
+
+  /* Die if the chroot directory does not exist. */
+  if (access ("@CHROOTDIR@", R_OK|X_OK) == -1) {
+    perror ("@CHROOTDIR@");
+    exit (1);
+  }
+
   /* Run the ocaml program with the correct args. */
   /* Run the ocaml program with the correct args. */
-  execle ("@OCAML@", "@OCAML@", "-init", "@INITSCRIPT@", NULL, new_environ);
+  execle ("@OCAML@", "@OCAML@",
+         "-init", "@INITSCRIPT@",
+         "-noprompt",
+         NULL, new_environ);
 
   /* If it failed, die with an error message. */
   perror ("@OCAML@");
 
   /* If it failed, die with an error message. */
   perror ("@OCAML@");