Commit Graph

164 Commits

Author SHA1 Message Date
Wolfgang Bumiller
952fd95e84 Tools: add unshare system call
Including the important CLONE_* constants.
2015-09-17 13:20:15 +02:00
Wolfgang Bumiller
fcdc0cfc8a Tools::run_command: array of arrays special case
Passing an array of arrays to run_command will cause each
array to be treated like a command piped to the following
command. Each argument is shell-quoted unless its passed by
reference.
2015-09-16 09:08:53 +02:00
Wolfgang Bumiller
bd9c3a3654 document run_command 2015-09-16 09:07:42 +02:00
Wolfgang Bumiller
c38cea65b6 Tools::run_with_timeout improvement + hires alarm
The following situations could lead to the 'unknown error':
1) As commented, when the alarm triggered after the first
signal handler was installed and before the new alarm was
installed. In this case the $signalcount was increased,
and worse: the original signal handler was never called.

2) When $code died, since the call itself wasn't in an eval
block, we'd leave the eval block containing the inner alarm
signal handler. Then there's a time window from leaving the
signal block (and with that restoring the first installed
only-counting signal-handler) and reaching the code to
restore the previous alarm where the counting alarm handler
could get triggered by our own alarm set before running
$code. In this case at least the the old alarm would be
restored, but we'd still trigger the 'unknown error'.

The new code starts off by suspending the original alarm
before installing any signal handler, then installing the
timeout handler inside the first eval block. The $code is
then run inside another eval block to make sure we reach the
alarm(0) statement before restoring the old signal handler
and alarm timeout.
2015-08-28 10:45:26 +02:00
Wolfgang Bumiller
b261377727 Add generic parse_host_and_port function
Added a generic function to split a host+port string to the
host and port part supporting the two most common ipv6
notations beside domains and ipv4: with brackets for the
address or a dot as port separator.
2015-08-25 12:58:09 +02:00
Dietmar Maurer
6de95a662f new helper dump_journal to view systemd journal 2015-06-09 12:15:41 +02:00
Wolfgang Bumiller
22d4efe612 fix a regex typo in run_command
m/|/ is always true as it effectively matches 'nothing or nothing
anywhere in a string'
looks like it was supposed to be m/\|/
2015-05-28 10:28:44 +02:00
Wolfgang Bumiller
e43b3a0f50 prevent the use of AI_ADDRCONFIG
perl's IO::Socket::IP passes AI_ADDRCONFIG if no GetAddrInfoFlags are passed,
which is often useful but also causes it to error when explicitly trying to
bind to 127.0.0.1 when there are no _other_ IPv4 addresses present.
2015-05-27 15:32:08 +02:00
Wolfgang Bumiller
a0b6ef523a new helper: getaddrinfo_all
As it's commonly used in ipv6 support code a getaddrinfo wrapper passing
default flags and dealing with the (err,result) tuple was added.
2015-05-12 10:35:35 +02:00
Wolfgang Bumiller
467752183d add a socket family argument to next_*_port functions
Instead of assuming a local address of 0.0.0.0, the next_*_port family
of functions now takes an optional packet family argument (AF_INET/AF_INET6),
used for ipv6 support.
2015-05-12 10:35:31 +02:00
Wolfgang Bumiller
a956854f8d add utility to fetch the socket family for a hostname 2015-05-08 12:36:30 +02:00
Wolfgang Bumiller
8df6b79439 provide Tools::unpack_sockaddr_in46 2015-05-08 12:36:11 +02:00
Wolfgang Bumiller
00dc9d0fa9 Use IO::Socket::IP instead of INET 2015-05-08 12:35:15 +02:00
Dietmar Maurer
b51b16e6f5 rename data to src 2015-02-27 16:57:20 +01:00