From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 8F005BC48 for ; Sun, 27 Mar 2005 12:01:48 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j2RA1mTu003445 for ; Sun, 27 Mar 2005 12:01:48 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA28861 for ; Sun, 27 Mar 2005 12:01:47 +0200 (MET DST) Received: from ms001msg.fastwebnet.it (ms001msg.fastwebnet.it [213.140.2.51]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j2RA1lNc003442 for ; Sun, 27 Mar 2005 12:01:47 +0200 Received: from fistandantilus.takhisis.org (37.10.140.106) by ms001msg.fastwebnet.it (7.2.052.3) id 4235CA0700278F4C for caml-list@inria.fr; Sun, 27 Mar 2005 12:01:47 +0200 Received: by fistandantilus.takhisis.org (Postfix, from userid 3148) id B77B027405C; Sun, 27 Mar 2005 12:01:45 +0200 (CEST) Date: Sun, 27 Mar 2005 12:01:45 +0200 From: Stefano Zacchiroli To: Inria Ocaml Mailing List Subject: on ocaml and set-user-id programs Message-ID: <20050327100145.GA9332@fistandantilus.takhisis.org> Mail-Followup-To: Inria Ocaml Mailing List Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6+20040907i X-Miltered: at nez-perce with ID 4246848C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4246848B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; zacchiroli:01 ocaml:01 ocaml:01 bytecode:01 ocamlrun:01 bytecode:01 compiler:01 cheers:01 ocamlrun:01 usr:01 usr:01 topfind:01 printf:01 printf:01 chmod:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: I've wrote an ocaml program that needs to be executed set-user-id root. I managed to have it being executed with effective user id 0 only compiling in native code or in custom bytecode. Both executing it as a script using "ocamlrun ocaml" and compiling it to non-custom bytecode make the program having effective user id of the user executing it. (Example session at the end of this mail) This behaviour is annoying and makes impossible to run ocaml set-user-id programs where the native code compiler isn't available. Am I missing something or is this a shortcoming of the current ocaml interpreter? Thanks in advance, Cheers. Attempt using ocamlrun ocaml (FAILED) $ cat a.ml #!/usr/bin/ocamlrun /usr/bin/ocaml #use "topfind";; #require "unix";; Printf.printf "UID = %d\nEUID = %d\n" (Unix.getuid ()) (Unix.geteuid ()) $ su Password: # chown root a.ml # chmod 4755 a.ml # ls -l a.ml -rwsr-xr-x 1 root zack 143 2005-03-27 11:50 a.ml* # exit $ ./a.ml UID = 3148 EUID = 3148 $ Attempt using non-custom bytecode (FAILED) $ cat b.ml Printf.printf "UID = %d\nEUID = %d\n" (Unix.getuid ()) (Unix.geteuid ()) $ ocamlfind ocamlc -package unix -linkpkg -o b b.ml $ head -1 b #!/usr/bin/ocamlrun $ su Password: # chown root b # chmod 4755 b # ls -l b -rwsr-xr-x 1 root zack 70145 2005-03-27 11:52 b* # exit $ ./b UID = 3148 EUID = 3148 Attempt using custom bytecode (OK) $ ocamlfind ocamlc -custom -package unix -linkpkg -o b b.ml $ su Password: # chown root b # chmod 4755 b # exit $ ./b UID = 3148 EUID = 0 Attempt using native code (OK) $ ocamlfind opt -package unix -linkpkg -o b b.ml $ su Password: # chown root b # chmod 4755 b # exit $ ./b UID = 3148 EUID = 0 -- Stefano Zacchiroli -*- Computer Science PhD student @ Uny Bologna, Italy zack@{cs.unibo.it,debian.org,bononia.it} -%- http://www.bononia.it/zack/ If there's any real truth it's that the entire multidimensional infinity of the Universe is almost certainly being run by a bunch of maniacs. -!-