dimikot / vzfirewall

vzfirewall is an extremely simple tool to configure opened ports and hosts for incoming connections in OpenVZ environment
GNU Lesser General Public License v2.1
15 stars 6 forks source link

remove host command #4

Open jnorell opened 10 years ago

jnorell commented 10 years ago

Some systems don't have "host" and it's called "hostx" on others .. probably should just rewrite resolve() to use Net::DNS.

dimikot commented 10 years ago

Net::DNS is a non-standard module:

# perl -e "use Net::DNS;"
Can't locate Net/DNS.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

So we cannot use it. Maybe add an "if" which checks whether host or hostx is available and use it? But before this check, get a configuration option like

RESOLVER_CMD = host %s
RESOLVER_CMD = super_duper_host_Z %s | grep "la-la" | sed -e s/foo/bar/ 

where %s is processed with the following function before:

sub escape_shell_arg {
    my ($arg) = @_;
    my $q = qq{\x27};
    my $qq = qq{\x22};
    return $arg if $arg !~ m/[\s$q$qq\\]/s && length($arg);
    # aaa'bbb  =>  'aaa'\'bbb'
    $arg =~ s/$q/$q\\$q$q/sg;
    return $q . $arg . $q;
}