imageloader: replace Init function with static factory method

The static factory method prevents use between construction and
initialization by only returning a value if initialization succeeds.
This allows us to get rid of the initialized_ member and several
CHECKs, since users will never see a value if it fails during
LoadManifest. This is preferred style (see go/totw/42).

This also makes IsValidFingerprintFile static since it doesn't
depend on any members, which slightly simplifies a test. The
CopyValidImage test is left untouched because it is marked a friend
and has access to the private constructor and because its use case
is somewhat more complicated.

BUG=None
TEST=unit tests

Change-Id: I1af21db9b3b8af285b191e4982898ddec46e35c9
Reviewed-on: https://chromium-review.googlesource.com/456042
Commit-Ready: Eric Caruso <ejcaruso@chromium.org>
Tested-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-by: Greg Kerr <kerrnel@chromium.org>
4 files changed
tree: fcd6c06bf171b0721f86c376f51d0910c721203b
  1. .presubmitignore
  2. README.md
  3. component.cc
  4. component.h
  5. component_unittest.cc
  6. dbus_adaptors/
  7. dbus_permissions/
  8. dbus_service/
  9. helper_process.cc
  10. helper_process.h
  11. imageloader.cc
  12. imageloader.conf
  13. imageloader.gyp
  14. imageloader.h
  15. imageloader_impl.cc
  16. imageloader_impl.h
  17. imageloader_main.cc
  18. imageloader_unittest.cc
  19. imageloader_wrapper
  20. ipc.proto
  21. mock_helper_process.h
  22. mock_verity_mounter.h
  23. mount_helper.cc
  24. mount_helper.h
  25. public_keys/
  26. run_tests.cc
  27. seccomp/
  28. test_utilities.cc
  29. test_utilities.h
  30. testdata/
  31. verity_mounter.cc
  32. verity_mounter.h
README.md

src/platform/imageloader

This aims to provide a generic utility to verify and load (mount) signed disk images through DBUS IPC.

Binaries

  • imageloader

imageloader handles the mounting of disk images. imageloader should be executed via the imageloader_wrapper script, which ensures that imageloader's storage exists and is owned by imageloaderd user. When imageloader is not running, DBus will automatically invoke it. After 20 seconds of inactivity, the service exits.