Alien-SNMP

 view release on metacpan or  search on metacpan

lib/Alien/SNMP.pm  view on Meta::CPAN

package Alien::SNMP;

use strict;
use warnings;
use 5.010001;
use parent qw(Alien::Base);

our $VERSION = '4.0509050200';

# Preload the dynamic Net-SNMP library with global symbol visibility so that
# the bundled SNMP XS module -- which has `use Alien::SNMP;` injected ahead of
# its XSLoader call -- and any downstream XS resolve libnetsnmp by SONAME from
# our share dir, independent of a baked-in RUNPATH.  This is what lets the test
# suite pass before `make install` populates the final share dir (the window
# CPAN Testers run in), and lets the distribution work with no system-level
# libnetsnmp present.
# Best-effort: never let a failure here break `use Alien::SNMP` (e.g. when the
# module is loaded from source before the share dir exists) -- the baked-in
# RUNPATH still resolves libnetsnmp once the share is installed.
eval { __PACKAGE__->_preload_netsnmp };

sub _preload_netsnmp {
    my ($class) = @_;
    return unless $class->install_type eq 'share';
    require DynaLoader;
    for my $shared_lib ($class->dynamic_libs) {
        # Capture (untaint) the trusted share-dir path; skip non-libnetsnmp libs.
        next unless $shared_lib =~ m{(/.*/libnetsnmp\.so(?:\.[0-9]+)*)\z};
        DynaLoader::dl_load_file($1, 0x01);   # 0x01 = RTLD_GLOBAL
    }
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Alien::SNMP - Alien package for the Net-SNMP library

=cut

=head1 SYNOPSIS

 use Alien::SNMP;
 # then it's just like SNMP.pm
 
 say Alien::SNMP->bin_dir;
 # where the net-snmp apps (snmptranslate, etc) live

=head1 DESCRIPTION

L<Alien::SNMP> downloads and installs the Net-SNMP library and
associated perl modules.

The library is built with the following options:

=over

=item C<--disable-agent>

=item C<--disable-manuals>

=item C<--disable-scripts>

=item C<--disable-mibs>

=item C<--enable-ipv6>

=item C<--with-mibs="">

=item C<--with-perl-modules>

=item C<--disable-embedded-perl>

=item C<--enable-blumenthal-aes>

=item C<--with-defaults>

=back

=head1 METHODS

=head2 bin_dir

 my $bin_dir = Alien::SNMP->bin_dir;

Returns the location of the net-snmp apps (snmptranslate, etc).

=head2 cflags

 my $cflags = Alien::SNMP->cflags;

Returns the C compiler flags.

=head2 libs

 my $libs = Alien::SNMP->libs;

Returns the linker flags.

=head1 SEE ALSO

=over 4

=item L<Alien>

=item L<Alien::Base>



( run in 4.220 seconds using v1.01-cache-2.11-cpan-9169edd2b0e )