# -*- Makefile -*-
-# $Id: Makefile.config,v 1.5 2007/06/29 07:40:15 rjones Exp $
+# $Id: Makefile.config,v 1.6 2007/06/29 13:15:00 rjones Exp $
PACKAGE := xavierbot
-VERSION := 0.3
+VERSION := 0.4
# Prefix for installation.
# - Binaries are installed in $(PREFIX)/sbin
-(* Initialise the toplevel environment.
- * $Id: init,v 1.4 2007/06/29 07:55:47 rjones Exp $
+(* Initialise the toplevel environment. -*- tuareg -*-
+ * $Id: init,v 1.5 2007/06/29 13:15:02 rjones Exp $
* - Removes the Pervasives module and any dangerous functions.
* - Loads just the modules we want to give access to, and just
* the functions within those modules that we want to give.
* - Chroot to somewhere safe.
*)
+(* Load some libraries. *)
+#load "nums.cma";;
+#load "unix.cma";;
+
(* Remove the Pervasives module. *)
module Pervasives = struct end;;
let unsafe_really_input = ()
let do_at_exit = ()
-(* Allow the List function. *)
-module List : sig
- val length : 'a list -> int
- val hd : 'a list -> 'a
- val tl : 'a list -> 'a list
- val nth : 'a list -> int -> 'a
- val rev : 'a list -> 'a list
- val append : 'a list -> 'a list -> 'a list
- val rev_append : 'a list -> 'a list -> 'a list
- val concat : 'a list list -> 'a list
- val flatten : 'a list list -> 'a list
- val iter : ('a -> unit) -> 'a list -> unit
- val map : ('a -> 'b) -> 'a list -> 'b list
- val rev_map : ('a -> 'b) -> 'a list -> 'b list
- val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
- val fold_right : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
- val iter2 : ('a -> 'b -> unit) -> 'a list -> 'b list -> unit
- val map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
- val rev_map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
- val fold_left2 : ('a -> 'b -> 'c -> 'a) -> 'a -> 'b list -> 'c list -> 'a
- val fold_right2 : ('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> 'c -> 'c
- val for_all : ('a -> bool) -> 'a list -> bool
- val exists : ('a -> bool) -> 'a list -> bool
- val for_all2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
- val exists2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
- val mem : 'a -> 'a list -> bool
- val memq : 'a -> 'a list -> bool
- val find : ('a -> bool) -> 'a list -> 'a
- val filter : ('a -> bool) -> 'a list -> 'a list
- val find_all : ('a -> bool) -> 'a list -> 'a list
- val partition : ('a -> bool) -> 'a list -> 'a list * 'a list
- val assoc : 'a -> ('a * 'b) list -> 'b
- val assq : 'a -> ('a * 'b) list -> 'b
- val mem_assoc : 'a -> ('a * 'b) list -> bool
- val mem_assq : 'a -> ('a * 'b) list -> bool
- val remove_assoc : 'a -> ('a * 'b) list -> ('a * 'b) list
- val remove_assq : 'a -> ('a * 'b) list -> ('a * 'b) list
- val split : ('a * 'b) list -> 'a list * 'b list
- val combine : 'a list -> 'b list -> ('a * 'b) list
- val sort : ('a -> 'a -> int) -> 'a list -> 'a list
- val stable_sort : ('a -> 'a -> int) -> 'a list -> 'a list
- val fast_sort : ('a -> 'a -> int) -> 'a list -> 'a list
- val merge : ('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
-end = struct include List end
+(* Modules which have been checked and appear to be all safe. *)
+let _ = Big_int.zero_big_int
+let _ = Buffer.create
+let _ = Complex.zero
+let _ = Hashtbl.create
+let _ = Int32.to_string
+let _ = Int64.to_string
+let _ = List.length
+let _ = Nativeint.to_string
+let _ = Num.add_num
+let _ = Ratio.null_denominator
+let _ = Stack.create
(* Allow only safe functions from String. *)
module String : sig
val compare: t -> t -> int
end = struct include String end
+(* Allow only safe functions from Filename. *)
+module Filename : sig
+ val current_dir_name : string
+ val parent_dir_name : string
+ val concat : string -> string -> string
+ val is_relative : string -> bool
+ val is_implicit : string -> bool
+ val check_suffix : string -> string -> bool
+ val chop_suffix : string -> string -> string
+ val chop_extension : string -> string
+ val basename : string -> string
+ val dirname : string -> string
+ val quote : string -> string
+end = struct include Filename end
+
+(* Allow only safe functions from Char. *)
+module Char : sig
+ external code : char -> int = "%identity"
+ val chr : int -> char
+ val escaped : char -> string
+ val lowercase : char -> char
+ val uppercase : char -> char
+ type t = char
+ val compare: t -> t -> int
+end = struct include Char end
+
+(* Allow only safe functions from Array. *)
+module Array : sig
+ external length : 'a array -> int = "%array_length"
+ external get : 'a array -> int -> 'a = "%array_safe_get"
+ external set : 'a array -> int -> 'a -> unit = "%array_safe_set"
+ external make : int -> 'a -> 'a array = "caml_make_vect"
+ external create : int -> 'a -> 'a array = "caml_make_vect"
+ val init : int -> (int -> 'a) -> 'a array
+ val make_matrix : int -> int -> 'a -> 'a array array
+ val create_matrix : int -> int -> 'a -> 'a array array
+ val append : 'a array -> 'a array -> 'a array
+ val concat : 'a array list -> 'a array
+ val sub : 'a array -> int -> int -> 'a array
+ val copy : 'a array -> 'a array
+ val fill : 'a array -> int -> int -> 'a -> unit
+ val blit : 'a array -> int -> 'a array -> int -> int -> unit
+ val to_list : 'a array -> 'a list
+ val of_list : 'a list -> 'a array
+ val iter : ('a -> unit) -> 'a array -> unit
+ val map : ('a -> 'b) -> 'a array -> 'b array
+ val iteri : (int -> 'a -> unit) -> 'a array -> unit
+ val mapi : (int -> 'a -> 'b) -> 'a array -> 'b array
+ val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b array -> 'a
+ val fold_right : ('b -> 'a -> 'a) -> 'b array -> 'a -> 'a
+ val sort : ('a -> 'a -> int) -> 'a array -> unit
+ val stable_sort : ('a -> 'a -> int) -> 'a array -> unit
+ val fast_sort : ('a -> 'a -> int) -> 'a array -> unit
+end = struct include Array end
+
+(* Set and Map. *)
+module StringSet = Set.Make(String)
+module StringMap = Map.Make(String)
+
(* Create an object, so we get the CamlinternalOO module. *)
(* XXX Are any of the methods unsafe? *)
let _ = object end
#load "./pa_noexternal.cmo";;
(* Chroot and setuid to nobody. If this fails, die. *)
-#load "unix.cma";;
let () =
try
let pw = Unix.getpwnam "nobody" in
-(* Initialise the toplevel environment.
- * $Id: init.in,v 1.2 2007/06/28 23:18:28 rjones Exp $
+(* Initialise the toplevel environment. -*- tuareg -*-
+ * $Id: init.in,v 1.3 2007/06/29 13:15:02 rjones Exp $
* - Removes the Pervasives module and any dangerous functions.
* - Loads just the modules we want to give access to, and just
* the functions within those modules that we want to give.
* - Chroot to somewhere safe.
*)
+(* Load some libraries. *)
+#load "nums.cma";;
+#load "unix.cma";;
+
(* Remove the Pervasives module. *)
module Pervasives = struct end;;
let unsafe_really_input = ()
let do_at_exit = ()
-(* Allow the List function. *)
-module List : sig
- val length : 'a list -> int
- val hd : 'a list -> 'a
- val tl : 'a list -> 'a list
- val nth : 'a list -> int -> 'a
- val rev : 'a list -> 'a list
- val append : 'a list -> 'a list -> 'a list
- val rev_append : 'a list -> 'a list -> 'a list
- val concat : 'a list list -> 'a list
- val flatten : 'a list list -> 'a list
- val iter : ('a -> unit) -> 'a list -> unit
- val map : ('a -> 'b) -> 'a list -> 'b list
- val rev_map : ('a -> 'b) -> 'a list -> 'b list
- val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
- val fold_right : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
- val iter2 : ('a -> 'b -> unit) -> 'a list -> 'b list -> unit
- val map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
- val rev_map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
- val fold_left2 : ('a -> 'b -> 'c -> 'a) -> 'a -> 'b list -> 'c list -> 'a
- val fold_right2 : ('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> 'c -> 'c
- val for_all : ('a -> bool) -> 'a list -> bool
- val exists : ('a -> bool) -> 'a list -> bool
- val for_all2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
- val exists2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
- val mem : 'a -> 'a list -> bool
- val memq : 'a -> 'a list -> bool
- val find : ('a -> bool) -> 'a list -> 'a
- val filter : ('a -> bool) -> 'a list -> 'a list
- val find_all : ('a -> bool) -> 'a list -> 'a list
- val partition : ('a -> bool) -> 'a list -> 'a list * 'a list
- val assoc : 'a -> ('a * 'b) list -> 'b
- val assq : 'a -> ('a * 'b) list -> 'b
- val mem_assoc : 'a -> ('a * 'b) list -> bool
- val mem_assq : 'a -> ('a * 'b) list -> bool
- val remove_assoc : 'a -> ('a * 'b) list -> ('a * 'b) list
- val remove_assq : 'a -> ('a * 'b) list -> ('a * 'b) list
- val split : ('a * 'b) list -> 'a list * 'b list
- val combine : 'a list -> 'b list -> ('a * 'b) list
- val sort : ('a -> 'a -> int) -> 'a list -> 'a list
- val stable_sort : ('a -> 'a -> int) -> 'a list -> 'a list
- val fast_sort : ('a -> 'a -> int) -> 'a list -> 'a list
- val merge : ('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
-end = struct include List end
+(* Modules which have been checked and appear to be all safe. *)
+let _ = Big_int.zero_big_int
+let _ = Buffer.create
+let _ = Complex.zero
+let _ = Hashtbl.create
+let _ = Int32.to_string
+let _ = Int64.to_string
+let _ = List.length
+let _ = Nativeint.to_string
+let _ = Num.add_num
+let _ = Ratio.null_denominator
+let _ = Stack.create
(* Allow only safe functions from String. *)
module String : sig
val compare: t -> t -> int
end = struct include String end
+(* Allow only safe functions from Filename. *)
+module Filename : sig
+ val current_dir_name : string
+ val parent_dir_name : string
+ val concat : string -> string -> string
+ val is_relative : string -> bool
+ val is_implicit : string -> bool
+ val check_suffix : string -> string -> bool
+ val chop_suffix : string -> string -> string
+ val chop_extension : string -> string
+ val basename : string -> string
+ val dirname : string -> string
+ val quote : string -> string
+end = struct include Filename end
+
+(* Allow only safe functions from Char. *)
+module Char : sig
+ external code : char -> int = "%identity"
+ val chr : int -> char
+ val escaped : char -> string
+ val lowercase : char -> char
+ val uppercase : char -> char
+ type t = char
+ val compare: t -> t -> int
+end = struct include Char end
+
+(* Allow only safe functions from Array. *)
+module Array : sig
+ external length : 'a array -> int = "%array_length"
+ external get : 'a array -> int -> 'a = "%array_safe_get"
+ external set : 'a array -> int -> 'a -> unit = "%array_safe_set"
+ external make : int -> 'a -> 'a array = "caml_make_vect"
+ external create : int -> 'a -> 'a array = "caml_make_vect"
+ val init : int -> (int -> 'a) -> 'a array
+ val make_matrix : int -> int -> 'a -> 'a array array
+ val create_matrix : int -> int -> 'a -> 'a array array
+ val append : 'a array -> 'a array -> 'a array
+ val concat : 'a array list -> 'a array
+ val sub : 'a array -> int -> int -> 'a array
+ val copy : 'a array -> 'a array
+ val fill : 'a array -> int -> int -> 'a -> unit
+ val blit : 'a array -> int -> 'a array -> int -> int -> unit
+ val to_list : 'a array -> 'a list
+ val of_list : 'a list -> 'a array
+ val iter : ('a -> unit) -> 'a array -> unit
+ val map : ('a -> 'b) -> 'a array -> 'b array
+ val iteri : (int -> 'a -> unit) -> 'a array -> unit
+ val mapi : (int -> 'a -> 'b) -> 'a array -> 'b array
+ val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b array -> 'a
+ val fold_right : ('b -> 'a -> 'a) -> 'b array -> 'a -> 'a
+ val sort : ('a -> 'a -> int) -> 'a array -> unit
+ val stable_sort : ('a -> 'a -> int) -> 'a array -> unit
+ val fast_sort : ('a -> 'a -> int) -> 'a array -> unit
+end = struct include Array end
+
+(* Set and Map. *)
+module StringSet = Set.Make(String)
+module StringMap = Map.Make(String)
+
(* Create an object, so we get the CamlinternalOO module. *)
(* XXX Are any of the methods unsafe? *)
let _ = object end
#load "./pa_noexternal.cmo";;
(* Chroot and setuid to nobody. If this fails, die. *)
-#load "unix.cma";;
let () =
try
let pw = Unix.getpwnam "@OCAMLUSER@" in