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

Commit c5cf85db authored by Tom Cherry's avatar Tom Cherry
Browse files

init: don't log in expand_props directly

It's better to pass the error message to the caller to determine how
best to print the error.

Test: build
Change-Id: Id8857c459df2f26c031650166609608d20e4d051
parent 244d9b8f
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -35,9 +35,11 @@ Result<void> RunBuiltinFunction(const BuiltinFunction& function,
    builtin_arguments.args.resize(args.size());
    builtin_arguments.args[0] = args[0];
    for (std::size_t i = 1; i < args.size(); ++i) {
        if (!expand_props(args[i], &builtin_arguments.args[i])) {
            return Error() << "cannot expand '" << args[i] << "'";
        auto expanded_arg = ExpandProps(args[i]);
        if (!expanded_arg) {
            return expanded_arg.error();
        }
        builtin_arguments.args[i] = std::move(*expanded_arg);
    }

    return function(builtin_arguments);
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@

// android/api-level.h
#define __ANDROID_API_P__ 28
#define __ANDROID_API_R__ 30

// sys/system_properties.h
#define PROP_VALUE_MAX 92
+5 −6
Original line number Diff line number Diff line
@@ -29,15 +29,14 @@ Result<void> ImportParser::ParseSection(std::vector<std::string>&& args,
        return Error() << "single argument needed for import\n";
    }

    std::string conf_file;
    bool ret = expand_props(args[1], &conf_file);
    if (!ret) {
        return Error() << "error while expanding import";
    auto conf_file = ExpandProps(args[1]);
    if (!conf_file) {
        return Error() << "Could not expand import: " << conf_file.error();
    }

    LOG(INFO) << "Added '" << conf_file << "' to import list";
    LOG(INFO) << "Added '" << *conf_file << "' to import list";
    if (filename_.empty()) filename_ = filename;
    imports_.emplace_back(std::move(conf_file), line);
    imports_.emplace_back(std::move(*conf_file), line);
    return {};
}

+5 −4
Original line number Diff line number Diff line
@@ -648,13 +648,14 @@ static void LoadProperties(char* data, const char* filter, const char* filename,
            }

            std::string raw_filename(fn);
            std::string expanded_filename;
            if (!expand_props(raw_filename, &expanded_filename)) {
                LOG(ERROR) << "Could not expand filename '" << raw_filename << "'";
            auto expanded_filename = ExpandProps(raw_filename);

            if (!expanded_filename) {
                LOG(ERROR) << "Could not expand filename ': " << expanded_filename.error();
                continue;
            }

            load_properties_from_file(expanded_filename.c_str(), key, properties);
            load_properties_from_file(expanded_filename->c_str(), key, properties);
        } else {
            value = strchr(key, '=');
            if (!value) continue;
+19 −15
Original line number Diff line number Diff line
@@ -497,6 +497,7 @@ void SelinuxSetupKernelLogging() {
// This function returns the Android version with which the vendor SEPolicy was compiled.
// It is used for version checks such as whether or not vendor_init should be used
int SelinuxGetVendorAndroidVersion() {
    static int vendor_android_version = [] {
        if (!IsSplitPolicyDevice()) {
            // If this device does not split sepolicy files, it's not a Treble device and therefore,
            // we assume it's always on the latest platform.
@@ -511,10 +512,13 @@ int SelinuxGetVendorAndroidVersion() {
        int major_version;
        std::string major_version_str(version, 0, version.find('.'));
        if (!ParseInt(major_version_str, &major_version)) {
        PLOG(FATAL) << "Failed to parse the vendor sepolicy major version " << major_version_str;
            PLOG(FATAL) << "Failed to parse the vendor sepolicy major version "
                        << major_version_str;
        }

        return major_version;
    }();
    return vendor_android_version;
}

// This function initializes SELinux then execs init to run in the init SELinux context.
Loading