Initial version.
[xavierbot.git] / ocamlbotwrapper.c.in
diff --git a/ocamlbotwrapper.c.in b/ocamlbotwrapper.c.in
new file mode 100644 (file)
index 0000000..76aa4cd
--- /dev/null
@@ -0,0 +1,25 @@
+/* -*- C -*-
+ * $Id: ocamlbotwrapper.c.in,v 1.1 2007/06/28 19:47:26 rjones Exp $
+ * SUID wrapper around ocaml program.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+
+const char *new_environ[] = {
+  "PATH=/usr/bin",
+  NULL
+};
+
+int
+main ()
+{
+  /* Run the ocaml program with the correct args. */
+  execle ("@OCAML@", "@OCAML@", "-init", "@INITSCRIPT@", NULL, new_environ);
+
+  /* If it failed, die with an error message. */
+  perror ("@OCAML@");
+  exit (1);
+}