Get rid of the call to pkcs11_startup and avoid duplicate tokens

pkcs11_startup does a bunch of stuff that we already do or isn't necessary
(like setting up a soft token). Replace the call to it by doing the needed
steps programmatically.

Also change token initialization to use the minimum privileges necessary. None
of the tools and daemons run as root now.

BUG=chromium-os:15403
TEST=manual (see below)

// Check that pkcs initialization succeeds from scratch
1) Blow away /var/lib/opencryptoki and /home/chronos/user/.tpm/
2) Run cryptohome --action=pkcs11_init
3) Pin reset should succeed.

// Entd is correctly able to detect token is being initialized.
// Also, only one token is displayed.
1) Configure cryptohomed to perform TPM initialization instead of entd
2) Install enterprise policy extension.
2) Blow away /home/chronos/user/tpm.
3) Login with a @google.com account
4) Open extension policy Options page
5) Let token initialization complete
6) Only one TPM token should be visible under Tokens

Change-Id: I4af7229b36c882ca6dffc0d9555192664411a671
Reviewed-on: http://gerrit.chromium.org/gerrit/893
Reviewed-by: Ken Mixter <kmixter@chromium.org>
Tested-by: Gaurav Shah <gauravsh@chromium.org>
5 files changed