attestationd: fork before starting the daemon.

This change adds a call to daemon(3) function to fork in the background.
This is required so upstart can know when the program has been
initialized (post-start scripts are executed after upstart gets the
child pid).

This change is required in order to support zerotouch enrollment in
attestationd the same way it is being used in cryptohomed: there's a
file that has to be read and deleted as soon as possible. This change
gives us a synchronization point to know when the program has been
initialized (forked).

BUG=chromium:641153
TEST=tested on a fizz board: both cryptohomed and attestationd can
communicate with each other. start and stop works for both daemons, and
there were no crashes in /var/log/messages. I was able to run commands
with trunks_client, tpm_manager_client, attestation_client and
cryptohome.

Change-Id: I88f4b26b90cbc75fe361c219213091379ada4bd8
Reviewed-on: https://chromium-review.googlesource.com/580697
Commit-Ready: Marco Vanotti <mvanotti@google.com>
Tested-by: Marco Vanotti <mvanotti@google.com>
Reviewed-by: Yves Arrouye <drcrash@chromium.org>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
2 files changed