++ed by:

1 non-PAUSE user.

Karl Gaissmaier
and 1 contributors


Captive::Portal::Role::Utils - common utils for Captive::Portal


Utility roles needed by other modules. All roles die on error.



Returns the corresponding MAC address for given IP address from /proc/net/arp on success or undef on failure.


Helper method, convert ipv4 address to hexadecimal representation.

Example: '' -> '0a0102fe'


Helper method, normalize ip adresses, strip leading zeros in octets.

Example: '' -> ''


Running under root, like normal cronjobs do, should drop to the same uid/gid as the http daemon (and fcgi script). uid/gid is taken from config as RUN_USER/RUN_GROUP.

$capo->spawn_cmd(@cmd_with_options, [$spawn_cmd_options])

Wrapper to run external commands, capture and return (stdout/stderr).

Last optional parameter item is a hashref with options for spawn_cmd itself:

        timeout           => 2,    # default 2s
        ignore_exit_codes => [],   # exit codes without exception

If the external command doesn't return after timeout, the command is interrupted and an exception is thrown.

Exit codes != 0 and not defined in ignore_exit_codes throw exceptions.


Template callback converting DNS name(s) to ip address(es), see perldoc Template::Manual::Variables. With this helper, DNS-names in firewall templates are translated to ipv4 adresses.


 ''                    ->  ''
 'www.acme.rog'                   -> [,,, ...]
 [ftp.uni-ulm.de, www.uni-ulm.de] -> [,]


Karl Gaissmaier, <gaissmai at cpan.org>


Copyright 2010-2012 Karl Gaissmaier, all rights reserved.

This distribution is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version, or

b) the Artistic License version 2.0.