[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Jailkit-users] [Fwd: Trouble with perl program on Gentoo Linux]

From: John R Larsen
Subject: Re: [Jailkit-users] [Fwd: Trouble with perl program on Gentoo Linux]
Date: Tue, 21 Mar 2006 12:53:46 -0500

Hi Stephen,

Thanks for your efforts.  I meant to email the list yesterday.  On Sunday after 
much frustration I finally 
figured out what was wrong.  Perl's File::Basename module has functions named 
"dirname" and 
"basename".  What I didn't realize until Sunday was that the perl code in the 
test case was using the 
native system calls for "dirname" and "basename", which is what you discovered. 
 This line of perl code 
has dirname in back ticks:

       chomp ($working_dir=`dirname $0`);

The back ticks ` ` tell perl to make a system call.  The results of the system 
call are put in $working_dir.  
My jail didn't have the native dirname and basename so the fork failed.  The 
correct way to write this 
line to use the perl File::Basename functions is:

       chomp ($working_dir=dirname ($0));

Once I tweaked the code to do that perl worked fine.  I went through all sorts 
of trouble shooting steps.  
I actually got a different "jail" program working and it failed there as well.  
I copied all the functions from 
the perl File::Basename module into the test case so it was self contained and 
it still failed.  At that 
point I started digging into the perl source code itself.  Finally I looked at 
the test case again very 
carefully and it hit me what was going on.  Sorry for the misdirection, but 
that's what happens when 
trying out new things with multiple variables.  Jailkit is pretty cool.  I've 
been able to create a jail which 
was essential for security.

Thanks again,


On 20 Mar 2006 at 21:24, Stephen Tallowitz wrote:

Date sent:              Mon, 20 Mar 2006 21:24:29 +0100
From:                   Stephen Tallowitz <address@hidden>
To:                     address@hidden, address@hidden
Subject:                Re: [Jailkit-users] [Fwd: Trouble with perl program on 

Hello John,

I like a challenge and so I've tried getting test.pl to work on my system in a 
jail. I've succeeded and this 
is how I did it:

jk_init /srv/jailtest/ uidbasic
jk_cp -v /srv/jailtest/ /bin/bash
# create jailuser with login shell /bin/bash, copy test.pl to users' directory 
and change test.pl 
permissions and mode bits
# then create a perl binary package using quickpkg from gentoolkit (gentoo 
specific) and install that 
package in the jail directory.
# Users of other distributions may want to consult their distributors' manuals 
to find out how to install a 
package to a second location in the filetree
quickpkg perl
tar -xvjf /usr/portage/packages/All/perl-5.8.7-r3.tbz2 -C /srv/jailtest/
# install different, missing libraries (see messages when trying to run 
# test.pl):
jk_cp -v /srv/jailtest/ /lib/libxyz.so.x
# install missing executables:
jk_cp -v /srv/jailtest/ /bin/dirname
jk_cp -v /srv/jailtest/ /bin/pwd
jk_cp -v /srv/jailtest/ /bin/basename
# "login" to jail and execute script
su - jailuser

bash-3.00$ ./test.pl 
$0: ./test.pl
pgm: not_set
working_dir: not_set
$0: ./test.pl
pgm: test.pl
working_dir: /home/jailtest1


On Fri, 17 Mar 2006 12:16:14 -0500
"John R Larsen" wrote:

> I'm still having the same problem, but I've tried some things in an attempt 
> to isolate the problem.  I 
> downloaded the sources for perl 5.8.8 and built it locally.  It passes all 
> the tests.  I then installed it to 
> /usr/local/bin..  Next I used tar to copy the /usr/local/bin, /usr/local/lib, 
> and /usr/local/man directories into 
> the jail.  This insures that symbolic links and files in the directory trees 
> are faithfully copied into the jail.
> I still get the same errors when executing the test program in the jail.  The 
> fork call declares errors like 
> the following:
> fork(Can't exec "dirname": No such file or directory at ./test.pl line 12.
> )                                  = 11246
> The test program works fine when executed outside the jail.
> Has anyone else solved similar problems with perl in a jail?
John R Larsen <address@hidden>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]