Add some utilities

How can I get the diff better here?
Add warning if dependencies are missing

I don't really like this, it would be better to check only for
cryptsetup here, other checks can go where they're used or not at all.

The best might be to not do anything like this at all.
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.

Co-authored-by: Dave Reisner <dreisner@archlinux.org>
Automatically tag volumes with %random
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
Check device with blkid before cryptsetup create

Currently in rc.sysinit we check that blkid returns 2 before running
mkswap. This is a little bit stronger. Even without mkswap "cryptsetup
create" can be dangerous, so do the blkid check for all plain (non-LUKS)
mappings. Furthermore, just check for a non-zero return status, if this
is too broad we can get more specific.

Note: A user can still destroy her data if she enters the wrong password
for a cryptsetup create. This we'll leave as the user's fault; she
should be aware of the limitations of a plain mapping and the
--verify-passphrase cryptsetup option.
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.
Support Arch Linux idioms for the key field (ASK,SWAP)
Legacy support for key as <dev>:<offset>:<length>

Give a deprecation notice though.
Support the tmp= option for running mkfs on mapped device

It seems like some people use this. Use a new variable "tmpfs" to
contain the file system type. Default to ext4 (Debian does this). Use
the same variable to track the swap option too because we can only do
one or the other.
Add Arch Linux mkinitcpio hook for encrypted root

This should support all of the current syntax. If that sentance is
false, please let me know. This might be a good time to drop support for
root=... without a cryptdevice=...?
Support encrypted /usr with the the hook as well
Add manpage and example for crypttab

There are a couple of issues with the asciidoc. I'm also really tired
right now so I'm sure there's plenty of awkward wording (this msg
included).

The format should be described almost completely in the manpage. The
only thing I think I'm leaving out intentionally right now though is the
support for dev:offset:length for the key field.

The example file should include enough information to be useful, but
little enough to be a good overview. And certainly not enough to be
dangerous.
Add manpage for cryptmount

Ditto the last commit about awkward wording, even though I'm not quite
as tired =)