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

Commit fddb6279 authored by Pete Bentley's avatar Pete Bentley Committed by Automerger Merge Worker
Browse files

Merge "init: Add option to listen on sockets before starting service." am:...

Merge "init: Add option to listen on sockets before starting service." am: 39fee4c4 am: fbf5cb06 am: 669bdbef

Original change: https://android-review.googlesource.com/c/platform/system/core/+/2215044



Change-Id: Ie44eae0f3113c71e4212d38cecbdca0a8596f63a
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 9b3927f4 669bdbef
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -352,9 +352,10 @@ runs the service.

`socket <name> <type> <perm> [ <user> [ <group> [ <seclabel> ] ] ]`
> Create a UNIX domain socket named /dev/socket/_name_ and pass its fd to the
  launched process.  _type_ must be "dgram", "stream" or "seqpacket".  _type_
  may end with "+passcred" to enable SO_PASSCRED on the socket. User and
  group default to 0.  'seclabel' is the SELinux security context for the
  launched process.  The socket is created synchronously when the service starts.
  _type_ must be "dgram", "stream" or "seqpacket".  _type_ may end with "+passcred"
  to enable SO_PASSCRED on the socket or "+listen" to synchronously make it a listening socket.
  User and group default to 0.  'seclabel' is the SELinux security context for the
  socket.  It defaults to the service security context, as specified by
  seclabel or computed based on the service executable file security context.
  For native executables see libcutils android\_get\_control\_socket().
+2 −1
Original line number Diff line number Diff line
@@ -1404,7 +1404,8 @@ void StartPropertyService(int* epoll_socket) {
    StartSendingMessages();

    if (auto result = CreateSocket(PROP_SERVICE_NAME, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK,
                                   false, 0666, 0, 0, {});
                                   /*passcred=*/false, /*should_listen=*/false, 0666, /*uid=*/0,
                                   /*gid=*/0, /*socketcon=*/{});
        result.ok()) {
        property_set_fd = *result;
    } else {
+6 −3
Original line number Diff line number Diff line
@@ -434,11 +434,14 @@ Result<void> ServiceParser::ParseSocket(std::vector<std::string>&& args) {
                       << "' instead.";
    }

    if (types.size() > 1) {
        if (types.size() == 2 && types[1] == "passcred") {
    for (size_t i = 1; i < types.size(); i++) {
        if (types[i] == "passcred") {
            socket.passcred = true;
        } else if (types[i] == "listen") {
            socket.listen = true;
        } else {
            return Error() << "Only 'passcred' may be used to modify the socket type";
            return Error() << "Unknown socket type decoration '" << types[i]
                           << "'. Known values are ['passcred', 'listen']";
        }
    }

+2 −1
Original line number Diff line number Diff line
@@ -168,7 +168,8 @@ void Descriptor::Publish() const {

Result<Descriptor> SocketDescriptor::Create(const std::string& global_context) const {
    const auto& socket_context = context.empty() ? global_context : context;
    auto result = CreateSocket(name, type | SOCK_CLOEXEC, passcred, perm, uid, gid, socket_context);
    auto result = CreateSocket(name, type | SOCK_CLOEXEC, passcred, listen, perm, uid, gid,
                               socket_context);
    if (!result.ok()) {
        return result.error();
    }
+1 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ struct SocketDescriptor {
    int perm = 0;
    std::string context;
    bool passcred = false;
    bool listen = false;
    bool persist = false;

    // Create() creates the named unix domain socket in /dev/socket and returns a Descriptor object.
Loading