Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ae347a6 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "set-verity-state: Simplify args parsing logic" am: f78b2d17 am: 742c3c5e

parents 6f34dc26 742c3c5e
Loading
Loading
Loading
Loading
+10 −21
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@
#include <fs_mgr_overlayfs.h>
#include <log/log_properties.h>

using namespace std::string_literals;

#ifdef ALLOW_DISABLE_VERITY
static const bool kAllowDisableVerity = true;
#else
@@ -95,31 +97,18 @@ int main(int argc, char* argv[]) {
    LOG(FATAL) << "set-verity-state called with empty argv";
  }

  std::optional<bool> enable_opt;
  bool enable = false;
  std::string procname = android::base::Basename(argv[0]);
  if (procname == "enable-verity") {
    enable_opt = true;
    enable = true;
  } else if (procname == "disable-verity") {
    enable_opt = false;
  }

  if (!enable_opt.has_value()) {
    if (argc != 2) {
      printf("usage: %s [1|0]\n", argv[0]);
      return 1;
    }

    if (strcmp(argv[1], "1") == 0) {
      enable_opt = true;
    } else if (strcmp(argv[1], "0") == 0) {
      enable_opt = false;
    enable = false;
  } else if (argc == 2 && (argv[1] == "1"s || argv[1] == "0"s)) {
    enable = (argv[1] == "1"s);
  } else {
    printf("usage: %s [1|0]\n", argv[0]);
    return 1;
  }
  }

  bool enable = enable_opt.value();

  // Figure out if we're using VB1.0 or VB2.0 (aka AVB) - by
  // contract, androidboot.vbmeta.digest is set by the bootloader