Karthik Krishnamurthy > Unix-Conf-Bind8-0.3 > Unix::Conf::Bind8::Conf::Acl

Download:
Unix-Conf-Bind8-0.3.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Unix::Conf::Bind8::Conf::Acl - Class for handling Bind8 configuration directive `acl'.

SYNOPSIS ^

        use Unix::Conf::Bind8;

        my ($conf, $acl, $zone, $tmpacl, $ret);
        $conf = Unix::Conf::Bind8->new_conf (
                FILE        => '/etc/named.conf',
                SECURE_OPEN => 1,
        ) or $conf->die ("couldn't open `named.conf'");

        #
        # Ways to get an acl object.
        #

        $zone = $conf->get_zone ('extremix.net')
                or $zone->die ("couldn't get zone `extremix.net'");

        # create a new acl to be defined before the zone directive
        # 'extremix.net'.
        $acl = $conf->new_acl (
                NAME     => 'extremix.com-slaves', 
                ELEMENTS => [ qw (element1 element2) ],
                WHERE    => 'BEFORE',
                WARG     => $zone,
        ) or $acl->die ("couldn't create `extremix.com-slaves'");

        # OR

        # get an existing acl named 'extremix.com-slaves'
        $acl = $conf->get_acl ('extremix.com-slaves')
                or $acl->die ("couldn't get ACL `extremix.com-slaves');

        #
        # Operations that can be performed on an Acl object.
        #

        # create an unnamed acl
        $tmpacl = $conf->new_acl (
                ELEMENTS => [ 'key key1', 'localhost' ]
        ) or $tmpacl->die ("couldn't create unnamed acl");

        # Following operations can be performed on an Acl object.
        # NOTE: Legal Acl elements, are IP addresses, defined Acl 
        # names ('any','none','localhost','localnets') defined keys, 
        # and unnamed Acl objects

        # set the elements of the ACL. old values are deleted
        $ret = $acl->elements (qw (10.0.0.1 10.0.0.2))
                or $ret->die ("couldn't set elements on ACL `extremix.net-slaves'");

        # add elements
        $ret = $acl->add_elements ('10.0.0.3', '10.0.0.4', $tmpacl)
                or $ret->die ("couldn't add elements to ACL `extremix.net-slaves'");
    
        # delete elements. This will delete the acl if no elements are
        # left and the object is a named acl.
        $ret = $acl->delete_elements (qw (10.0.0.5 10.0.0.6))
                or $ret->die ("couldn't delete elements from ACL `extremix.net-slaves'")

        # delete an existing acl named 'extremix.com-slaves'
        $ret = $acl->delete () 
                or $ret->die ('couldn't delete ACL `extremix.com-slaves');

        # OR 

        $ret = $conf->delete_acl ('extremix.com-slaves')
                or $ret->die ("couldn't delete ACL `extremix.com-slaves');

METHODS ^

new ()
 Arguments
 NAME       => 'ACL-NAME',
 ELEMENTS   => [ qw (element1 element2) ],
 WHERE  => 'FIRST'|'LAST'|'BEFORE'|'AFTER'
 WARG   => Unix::Conf::Bind8::Conf::Directive subclass object
                        # WARG is to be provided only in case WHERE eq 'BEFORE 
                        # or WHERE eq 'AFTER'
 PARENT => reference,   # to the Conf object datastructure.

Class constructor. Creates a new Unix::Conf::Bind8::Conf::Acl object and returns it if successful, an Err object otherwise. Direct use of this method is deprecated. Use Unix::Conf::Bind8::Conf::new_acl () instead.

name ()
 Arguments
 'ACL-NAME'     # optional

Object method. Get/set the object's name attribute. If an argument is passed, the method tries to set the name attribute to 'ACL-NAME' and returns true if successful, an Err object otherwise. If no argument passed, it returns the name.

elements ()
 Arguments
 LIST OF ELEMENTS
 or 
 [ LIST OF ELEMENTS ]

Object method. Get/set the object's elements attribute. If argument(s) is passed the method tries to set the elements attribute. It returns true on success, an Err object otherwise. If no argument is passed, returns an array reference consisting of the elements of the object (including Acl objects contained therein), if defined, an Err object otherwise.

add_elements ()
 Arguments
 LIST OF ELEMENTS
 or 
 [ LIST OF ELEMENTS ]

Object method. Adds the argument to the elements of the invocant object. Returns true on success, an Err object otherwise.

TODO ^

o Add new methods to access elements defined only in that Acl object instead of all the elements, to access contained objects only etc. o Change elements, add_elements, delete_elements, __render to use them. o Enforce that an Acl object passed as an element be unnamed.

syntax highlighting: