When specifying the Perl bash directive to use the /usr/bin/env utility, the Perl script will not execute when invoked by the TCP Wrappers spawn rule in /etc/hosts.allow. I've run this as a crude and simple test. This is the first rule in the /etc/hosts.allow file:
It does not generate a line of output in the foo.out file when spawned by a ftp connection; however, it will generate the output when run from a command line.
This is the hello.pl Perl script:
(notice using env)
However, this hello.sh shell script when initiated by the spawn:
. . .does write to the /foo.out file
Apparently the environment utility is part of the problem.
If I remove the environment utility from the script, and simply hard-code
then the spawn rule executes the script, and generates the following line in /foo.out:
At this point, I'm not sure . . .what I don't understand about the env utility.
The paths are:
To verify:
and perl v5.22.0 is installed in /usr/local/bin/perl
. . .so why is ./perl not found by the environment utility when invoked by the spawn rule? This must have something to do with the path as perceived/specified by the spawn? I would think(expect) that it would follow root's paths.
Code:
ftpd : ALL : spawn /usr/local/test/hello.pl : allow
This is the hello.pl Perl script:
(notice using env)
Code:
#!/usr/bin/env perl
use strict;
use warnings;
my $datestring = localtime();
open(STDOUT, ">>foo.out") || die "Can't redirect stdout";
print STDOUT "HELLO from the Perl script! GOT HERE at $datestring.\n";
close(STDOUT);
exit;
Code:
echo "Hello from the csh, GOT HERE at `date`." >> foo.out
# cat /foo.out
Code:
Hello from the csh, GOT HERE at Mon Jul 13 18:32:04 CDT 2015.
Apparently the environment utility is part of the problem.
Code:
#!/usr/bin/env perl
Code:
#!/usr/local/bin/perl
#cat /foo.out
Code:
HELLO from the Perl script! GOT HERE at Tue Jul 14 10:45:27 2015.
At this point, I'm not sure . . .what I don't understand about the env utility.
The paths are:
# echo $PATH
Code:
/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/root/bin
# env
Code:
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/root/bin
. . .so why is ./perl not found by the environment utility when invoked by the spawn rule? This must have something to do with the path as perceived/specified by the spawn? I would think(expect) that it would follow root's paths.
Last edited by a moderator: