On 25 February 2009 c. 08:51:20 Jerome Santos wrote:
> hello, I want to put a php script in a site on an openbsd 4.2
> webserver. From what I understand because apache is chrooted, a
> function that uses an exec to a system call cannot work.
> ie.
> <?php
>         $s = explode( " ", exec("/var/run/usr/bin/uptime") );
>         $a = str_replace( ",", "", $s[3]);
>         $uptime = time() - $a;
>
>         $days = floor($uptime/60/60/24);
>         $hours = $uptime/60/60%24;
>         $mins = $uptime/60%60;
>         $secs = $uptime%60;
>         echo "This server is up " . $days . " days, " .  $hours  . "
> hours, " . $mins . " minutes and " . $secs . "seconds";
>
> ?>
>
> only echoes epoch time, "This server is up 14300 days, 5 hours, 49
> minutes and 24seconds"
>
> any ideas how to fix this?

a) Create a daemon running out of chroot that will open socket inside
chroot area or open a local port, and make your PHP app talk to it.
Until you'll do security mistakes in this daemon you'll be safe enough
(do not forget authentication). But this could be much work in some
cases.

b) Put needed static-linked executable ("/bin/sh" in your case inside
chroot). It's a mostly bad but easy way.

--
  Best wishes,
    Vadim Zhukov

Reply via email to