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

Commit 4c664d8c authored by Tom Cherry's avatar Tom Cherry Committed by android-build-merger
Browse files

Merge "ueventd: do not reference init's sehandle" am: 672dd970

am: e4988c9a

Change-Id: I3b33dea59f54f3807f2d1e1e7872f79f1dbada70
parents 8d982553 e4988c9a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -205,7 +205,7 @@ static int do_mkdir(const std::vector<std::string>& args) {
        mode = std::strtoul(args[2].c_str(), 0, 8);
    }

    ret = make_dir(args[1].c_str(), mode);
    ret = make_dir(args[1].c_str(), mode, sehandle);
    /* chmod in case the directory already exists */
    if (ret == -1 && errno == EEXIST) {
        ret = fchmodat(AT_FDCWD, args[1].c_str(), mode, AT_SYMLINK_NOFOLLOW);
@@ -809,7 +809,7 @@ static int do_wait_for_prop(const std::vector<std::string>& args) {
 * Callback to make a directory from the ext4 code
 */
static int do_installkeys_ensure_dir_exists(const char* dir) {
    if (make_dir(dir, 0700) && errno != EEXIST) {
    if (make_dir(dir, 0700, sehandle) && errno != EEXIST) {
        return -1;
    }

+1 −1
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ int SocketInfo::Create(const std::string& context) const {
  int flags = ((type() == "stream" ? SOCK_STREAM :
                (type() == "dgram" ? SOCK_DGRAM :
                 SOCK_SEQPACKET)));
  return create_socket(name().c_str(), flags, perm(), uid(), gid(), context.c_str());
  return create_socket(name().c_str(), flags, perm(), uid(), gid(), context.c_str(), sehandle);
}

const std::string SocketInfo::key() const {
+8 −4
Original line number Diff line number Diff line
@@ -54,7 +54,11 @@
#include "ueventd.h"
#include "util.h"

extern struct selabel_handle *sehandle;
#ifdef _INIT_INIT_H
#error "Do not include init.h in files used by ueventd or watchdogd; it will expose init's globals"
#endif

static selabel_handle* sehandle;

static android::base::unique_fd device_fd;

@@ -554,7 +558,7 @@ std::vector<std::string> get_block_device_symlinks(uevent* uevent) {
}

static void make_link_init(const std::string& oldpath, const std::string& newpath) {
    if (mkdir_recursive(dirname(newpath.c_str()), 0755)) {
    if (mkdir_recursive(dirname(newpath.c_str()), 0755, sehandle)) {
        PLOG(ERROR) << "Failed to create directory " << dirname(newpath.c_str());
    }

@@ -599,7 +603,7 @@ static void handle_block_device_event(uevent* uevent) {
    if (uevent->major < 0 || uevent->minor < 0) return;

    const char* base = "/dev/block/";
    make_dir(base, 0755);
    make_dir(base, 0755, sehandle);

    std::string name = android::base::Basename(uevent->path);
    std::string devpath = base + name;
@@ -641,7 +645,7 @@ static void handle_generic_device_event(uevent* uevent) {
        devpath = "/dev/" + android::base::Basename(uevent->path);
    }

    mkdir_recursive(android::base::Dirname(devpath), 0755);
    mkdir_recursive(android::base::Dirname(devpath), 0755, sehandle);

    auto links = get_character_device_symlinks(uevent);

+3 −0
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@

#include <string>

// Note: These globals are *only* valid in init, so they should not be used in ueventd,
// watchdogd, or any files that may be included in those, such as devices.cpp and util.cpp.
// TODO: Have an Init class and remove all globals.
extern const char *ENV[32];
extern std::string default_console;
extern struct selabel_handle *sehandle;
+1 −1
Original line number Diff line number Diff line
@@ -659,7 +659,7 @@ void start_property_service() {
    property_set("ro.property_service.version", "2");

    property_set_fd = create_socket(PROP_SERVICE_NAME, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK,
                                    0666, 0, 0, NULL);
                                    0666, 0, 0, nullptr, sehandle);
    if (property_set_fd == -1) {
        PLOG(ERROR) << "start_property_service socket creation failed";
        exit(1);
Loading