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

Commit 5f12c799 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic 'update-verified-priority-bump' into oc-dev

* changes:
  init.rc: launch update_verifier with exec_start
  init: replace property_get with its android::base equivalent
  init: remove unused cutils includes
  init: add exec_start command
parents ed6aad1c aaeb7923
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -311,6 +311,12 @@ Commands
  groups can be provided. No other commands will be run until this one
  finishes. _seclabel_ can be a - to denote default. Properties are expanded
  within _argument_.
  Init halts executing commands until the forked process exits.

`exec_start <service>`
> Start service a given service and halt processing of additional init commands
  until it returns.  It functions similarly to the `exec` command, but uses an
  existing service definition instead of providing them as arguments.

`export <name> <value>`
> Set the environment variable _name_ equal to _value_ in the
+4 −5
Original line number Diff line number Diff line
@@ -18,14 +18,14 @@

#include <errno.h>

#include <android-base/strings.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>

#include "builtins.h"
#include "error.h"
#include "init_parser.h"
#include "log.h"
#include "property_service.h"
#include "util.h"

using android::base::Join;
@@ -219,9 +219,8 @@ bool Action::CheckPropertyTriggers(const std::string& name,
                found = true;
            }
        } else {
            std::string prop_val = property_get(trigger_name.c_str());
            if (prop_val.empty() || (trigger_value != "*" &&
                                     trigger_value != prop_val)) {
            std::string prop_val = android::base::GetProperty(trigger_name, "");
            if (prop_val.empty() || (trigger_value != "*" && trigger_value != prop_val)) {
                return false;
            }
        }
+2 −3
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

#include "bootchart.h"

#include "property_service.h"

#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
@@ -39,6 +37,7 @@

#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>

using android::base::StringPrintf;
@@ -72,7 +71,7 @@ static void log_header() {
  utsname uts;
  if (uname(&uts) == -1) return;

  std::string fingerprint = property_get("ro.build.fingerprint");
  std::string fingerprint = android::base::GetProperty("ro.build.fingerprint", "");
  if (fingerprint.empty()) return;

  std::string kernel_cmdline;
+12 −18
Original line number Diff line number Diff line
@@ -45,16 +45,16 @@
#include <selinux/selinux.h>
#include <selinux/label.h>

#include <fs_mgr.h>
#include <android-base/file.h>
#include <android-base/parseint.h>
#include <android-base/strings.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <bootloader_message/bootloader_message.h>
#include <cutils/partition_utils.h>
#include <cutils/android_reboot.h>
#include <ext4_utils/ext4_crypt.h>
#include <ext4_utils/ext4_crypt_init_extensions.h>
#include <fs_mgr.h>
#include <logwrap/logwrap.h>

#include "action.h"
@@ -167,19 +167,11 @@ static int do_enable(const std::vector<std::string>& args) {
}

static int do_exec(const std::vector<std::string>& args) {
    Service* svc = ServiceManager::GetInstance().MakeExecOneshotService(args);
    if (!svc) {
        return -1;
    return ServiceManager::GetInstance().Exec(args) ? 0 : -1;
}
    if (!start_waiting_for_exec()) {
        return -1;
    }
    if (!svc->Start()) {
        stop_waiting_for_exec();
        ServiceManager::GetInstance().RemoveService(*svc);
        return -1;
    }
    return 0;

static int do_exec_start(const std::vector<std::string>& args) {
    return ServiceManager::GetInstance().ExecStart(args[1]) ? 0 : -1;
}

static int do_export(const std::vector<std::string>& args) {
@@ -880,8 +872,7 @@ static int do_installkeys_ensure_dir_exists(const char* dir) {
}

static bool is_file_crypto() {
    std::string value = property_get("ro.crypto.type");
    return value == "file";
    return android::base::GetProperty("ro.crypto.type", "") == "file";
}

static int do_installkey(const std::vector<std::string>& args) {
@@ -898,6 +889,7 @@ static int do_init_user0(const std::vector<std::string>& args) {

BuiltinFunctionMap::Map& BuiltinFunctionMap::map() const {
    constexpr std::size_t kMax = std::numeric_limits<std::size_t>::max();
    // clang-format off
    static const Map builtin_functions = {
        {"bootchart",               {1,     1,    do_bootchart}},
        {"chmod",                   {2,     2,    do_chmod}},
@@ -910,6 +902,7 @@ BuiltinFunctionMap::Map& BuiltinFunctionMap::map() const {
        {"domainname",              {1,     1,    do_domainname}},
        {"enable",                  {1,     1,    do_enable}},
        {"exec",                    {1,     kMax, do_exec}},
        {"exec_start",              {1,     1,    do_exec_start}},
        {"export",                  {2,     2,    do_export}},
        {"hostname",                {1,     1,    do_hostname}},
        {"ifup",                    {1,     1,    do_ifup}},
@@ -943,5 +936,6 @@ BuiltinFunctionMap::Map& BuiltinFunctionMap::map() const {
        {"wait_for_prop",           {2,     2,    do_wait_for_prop}},
        {"write",                   {2,     2,    do_write}},
    };
    // clang-format on
    return builtin_functions;
}
+11 −32
Original line number Diff line number Diff line
@@ -41,13 +41,10 @@
#include <selinux/android.h>

#include <android-base/file.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
#include <cutils/fs.h>
#include <cutils/iosched_policy.h>
#include <cutils/list.h>
#include <cutils/sockets.h>
#include <libavb/libavb.h>
#include <private/android_filesystem_config.h>

@@ -72,6 +69,7 @@
#include "util.h"
#include "watchdogd.h"

using android::base::GetProperty;
using android::base::StringPrintf;

struct selabel_handle *sehandle;
@@ -86,8 +84,6 @@ static time_t process_needs_restart_at;

const char *ENV[32];

static std::unique_ptr<Timer> waiting_for_exec(nullptr);

static int epoll_fd = -1;

static std::unique_ptr<Timer> waiting_for_prop(nullptr);
@@ -135,29 +131,12 @@ int add_environment(const char *key, const char *val)
    return -1;
}

bool start_waiting_for_exec()
{
    if (waiting_for_exec) {
        return false;
    }
    waiting_for_exec.reset(new Timer());
    return true;
}

void stop_waiting_for_exec()
{
    if (waiting_for_exec) {
        LOG(INFO) << "Wait for exec took " << *waiting_for_exec;
        waiting_for_exec.reset();
    }
}

bool start_waiting_for_property(const char *name, const char *value)
{
    if (waiting_for_prop) {
        return false;
    }
    if (property_get(name) != value) {
    if (GetProperty(name, "") != value) {
        // Current property value is not equal to expected value
        wait_prop_name = name;
        wait_prop_value = value;
@@ -445,7 +424,7 @@ static int keychord_init_action(const std::vector<std::string>& args)

static int console_init_action(const std::vector<std::string>& args)
{
    std::string console = property_get("ro.boot.console");
    std::string console = GetProperty("ro.boot.console", "");
    if (!console.empty()) {
        default_console = "/dev/" + console;
    }
@@ -469,11 +448,11 @@ static void import_kernel_nv(const std::string& key, const std::string& value, b
}

static void export_oem_lock_status() {
    if (property_get("ro.oem_unlock_supported") != "1") {
    if (!android::base::GetBoolProperty("ro.oem_unlock_supported", false)) {
        return;
    }

    std::string value = property_get("ro.boot.verifiedbootstate");
    std::string value = GetProperty("ro.boot.verifiedbootstate", "");

    if (!value.empty()) {
        property_set("ro.boot.flash.locked", value == "orange" ? "0" : "1");
@@ -494,7 +473,7 @@ static void export_kernel_boot_props() {
        { "ro.boot.revision",   "ro.revision",   "0", },
    };
    for (size_t i = 0; i < arraysize(prop_map); i++) {
        std::string value = property_get(prop_map[i].src_prop);
        std::string value = GetProperty(prop_map[i].src_prop, "");
        property_set(prop_map[i].dst_prop, (!value.empty()) ? value.c_str() : prop_map[i].default_value);
    }
}
@@ -1284,7 +1263,7 @@ int main(int argc, char** argv) {
    parser.AddSectionParser("service",std::make_unique<ServiceParser>());
    parser.AddSectionParser("on", std::make_unique<ActionParser>());
    parser.AddSectionParser("import", std::make_unique<ImportParser>());
    std::string bootscript = property_get("ro.boot.init_rc");
    std::string bootscript = GetProperty("ro.boot.init_rc", "");
    if (bootscript.empty()) {
        parser.ParseConfig("/init.rc");
        parser.set_is_system_etc_init_loaded(
@@ -1324,7 +1303,7 @@ int main(int argc, char** argv) {
    am.QueueBuiltinAction(mix_hwrng_into_linux_rng_action, "mix_hwrng_into_linux_rng");

    // Don't mount filesystems or start core system services in charger mode.
    std::string bootmode = property_get("ro.bootmode");
    std::string bootmode = GetProperty("ro.bootmode", "");
    if (bootmode == "charger") {
        am.QueueEventTrigger("charger");
    } else {
@@ -1338,10 +1317,10 @@ int main(int argc, char** argv) {
        // By default, sleep until something happens.
        int epoll_timeout_ms = -1;

        if (!(waiting_for_exec || waiting_for_prop)) {
        if (!(waiting_for_prop || ServiceManager::GetInstance().IsWaitingForExec())) {
            am.ExecuteOneCommand();
        }
        if (!(waiting_for_exec || waiting_for_prop)) {
        if (!(waiting_for_prop || ServiceManager::GetInstance().IsWaitingForExec())) {
            restart_processes();

            // If there's a process that needs restarting, wake up in time for that.
Loading