X-Git-Url: http://git.annexia.org/?p=xavierbot.git;a=blobdiff_plain;f=ocamlbotwrapper.c.in;h=b10b9c75cfe2cc30544cd97a1fbe1549ae3587c0;hp=76aa4cdb0193203905a5469ffb54919e648cdec1;hb=1e6d6c08bec29a317316f107b7d9bde285c1f798;hpb=d165f93ed79c62a1fa76f391d87ffc4d215b9efe diff --git a/ocamlbotwrapper.c.in b/ocamlbotwrapper.c.in index 76aa4cd..b10b9c7 100644 --- a/ocamlbotwrapper.c.in +++ b/ocamlbotwrapper.c.in @@ -1,5 +1,5 @@ /* -*- 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. */ @@ -16,8 +16,32 @@ const char *new_environ[] = { 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. */ - 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@");