Add functions for iterating over crypttab

ct_check_filter - Compare $FILTER (-O) to an optlist. If a token from
filter starts with !opt, then "opt" must not be in optlist.

Other than somewhat emulating mount here, later we'll allow options to
have a % prefix, for example %usb will allow -O %usb to map all volumes
with the %usb tag.

We'll add an implicit tag called %random for devices which use
/dev/urandom or /dev/random as a key. This will allow -O !%random to be
done before the random seed is restored an -O %random afterwards. Of
course, %random may also be specified expliticly in crypttab.

ct_read_crypttab - Feed each line of /etc/crypttab to a function. each
line is divided into a name, device, key, and options. ct_check_filter
is applied to the options and if ok, the 4 fields are passed to the
function. All operations that require reading crypttab will use this

There is also a -1 option for ct_read_crypttab to exit after the first
successful call to the function, this will be useful for identifying a
specific volume.
Support Arch Linux idioms for the key field (ASK,SWAP)
Add support for -L, the list operation
Add support for -U, the unmap operation

Without any arguments, use crypttab. Otherwise try to unmap whatever is
given on the command line. This does not support automatically unmapping
volumes which are not in crypttab.

One FIXME might be that when using crypttab, volumes should be handled
in the reverse order.
Check for udevd to avoid waiting for devices

Without udevd, it is unlikely that new devices are going to show up. So
we will know not to wait for them.

Suggested-by: Dave Reisner <dreisner@archlinux.org>
Add function for finding and waiting on a device

This will be for the encrypted device and if the key is a file on an
external device.
Add function for parsing comma separated option list

As far as the structure of the rest of the code goes, this one is a
little different because it sets the swap variable. I'm trying to think
of a cleaner way to do this.

With the exception of some special values, convert the comma separated
list of options to pass directly to cryptsetup. This means we don't have
to explicitly support all of cryptsetups options.

'size' and 'device-size' are needed because (yes) systemd and Debian use
size for cryptsetup's --key-size option. "cryptsetup --size create"
limits the size of a device.

'swap' means run mkswap after mounting, this is standard as far as the
Debian and systemd format goes.

'luks' and 'plain' are also used by Debian and systemd, but they seem
like superfluous configuration because "cryptsetup isLuks" gives this
information.

'noauto' will work with the default $FILTER (-O) of !noauto

'tmp' isn't yet supported, but is by Debian and systemd. I'd like to
support this later on

There is a list of options which are supported by Debian that we'll
ignore.
Add ct_map function (without support for key device)

Resolve device, parse options, run cryptsetup and run mkswap if needed
Add support to ct_map for key devices

The key field may be device:key:fstype or device:key in which case the
device is resolved and mounted if necessary. For these, key must be
relative to the root of the filesystem on the device.

The keydevice is mounted to $(mktemp -d). It is only unmounted if we
mounted it.
Add support for -M, the map operation

There are a few different syntaxes here. With no arguments, the
ct_read_crypttab iterator is used. With 1 argument, a volume is found in
crypttab. With 2-4 arguments, the volume is defined on the command line
and crypttab is not used.