Respond to signals consistently during the startup delay

Make inadyn's response to signals during the startup delay match how it
responds the rest of the time.  This avoids unnecessary inconsistencies
in the administrative interface.

Response to signals during the startup delay is now:
    HUP   Interrupt sleep and restart;
    TERM  Interrupt sleep and exit;
    INT   Interrupt sleep and exit;
    USR1  Interrupt sleep and perform forced update.
Therefore using SIGHUP is recommended to end the startup delay early.

Signed-off-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
Minor white space update to conditional operator setting sleep_sec

signed-off-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
Support for SIGUSR2 to wake up earlier from sleep and check for IP change

This change to inadyn further clarifies the behavior of signals, making
it consistent at all times.  As discussed in GitHub pull request #46.

Big thanks to Mike Fleetwood for his patience!

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Massive cleanup, mostly indentation and do-while(0) removal.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Fix issue #47: On error, retry sooner than configured check interval.

- Set ctx->sleep_sec to a lower value on error, recheck again soon
- Check that we can write /var/run/inadyn/inadyn.cache exit otherwise

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Handle connect() better, may get EINPROGRESS at times.

Yes, even though the socket isn't non-blocking we can get EINPROGRESS.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
confg: Refactor boundary checks in update period callbacks.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Update time_since_last_update with sleep time *before* setting new sleep time ...

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
tcp: Initial cleanup.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Make sure to write pidfile *after* forking background process.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
http-client: Initial cleanup.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
dyndns: Cleanup update_alias_table() & C:o

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Fix issue #15: On external trig. force update to random addr.

This commit implements support for -z, --fake-address which is only used
on SIGUSR1, forced update.  When --fake-address is given and the user
sends SIGUSR1 inadyn will send a DDNS server update for all records
using the "random" address 203.0.113.42, it then waits a second before
sending another update for all records using real address.

Needless to say, this is entirely out of spec, but could be useful for
some users who always get the same lease and would then be deregistered
by their DDNS provider.  See issue #15 on GitHub for more details.

   https://github.com/troglobit/inadyn/issues/15

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Compilation fixes for OpenBSD

- add missing includes
- initialize variable to prevent "may be used uninitialized" warning which is
  treated as error
Allow underscores in user and group names
Correct alias syntax in inadyn(8) man page
ip: Initial cleanup.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
http-client: http_client_init() --> http_client_initialize()

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Rename http_client.[ch] --> http.[ch]

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
http: Shorten all function names s/http_client_/http_/

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>