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

Commit ad1efe4a authored by Chris Manton's avatar Chris Manton
Browse files

root_canal: Add CLOSE_N_EXEC flag for rootcanal

Bug: 162114100
Test: cert/run
Tag: #refactor

Change-Id: Ia952dbe4adf726c351363ab0ab9c7db000f8499e
parent a67c7123
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -154,7 +154,7 @@ class AsyncManager::AsyncFdWatcher {
    }
    }
    // set up the communication channel
    // set up the communication channel
    int pipe_fds[2];
    int pipe_fds[2];
    if (pipe2(pipe_fds, O_NONBLOCK)) {
    if (pipe2(pipe_fds, O_NONBLOCK | O_CLOEXEC)) {
      LOG_ERROR(
      LOG_ERROR(
          "%s:Unable to establish a communication channel to the reading "
          "%s:Unable to establish a communication channel to the reading "
          "thread",
          "thread",
+1 −1
Original line number Original line Diff line number Diff line
@@ -39,7 +39,7 @@ PosixAsyncSocketConnector::ConnectToRemoteServer(
    const std::chrono::milliseconds timeout) {
    const std::chrono::milliseconds timeout) {
  LOG_INFO("Connecting to %s:%d in %d ms", server.c_str(), port,
  LOG_INFO("Connecting to %s:%d in %d ms", server.c_str(), port,
           (int)timeout.count());
           (int)timeout.count());
  int socket_fd = socket(AF_INET, SOCK_STREAM, 0);
  int socket_fd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
  std::shared_ptr<PosixAsyncSocket> pas =
  std::shared_ptr<PosixAsyncSocket> pas =
      std::make_shared<PosixAsyncSocket>(socket_fd, am_);
      std::make_shared<PosixAsyncSocket>(socket_fd, am_);


+3 −2
Original line number Original line Diff line number Diff line
@@ -36,7 +36,7 @@ PosixAsyncSocketServer::PosixAsyncSocketServer(int port, AsyncManager* am)
  struct sockaddr_in listen_address {};
  struct sockaddr_in listen_address {};
  socklen_t sockaddr_in_size = sizeof(struct sockaddr_in);
  socklen_t sockaddr_in_size = sizeof(struct sockaddr_in);


  OSI_NO_INTR(listen_fd = socket(AF_INET, SOCK_STREAM, 0));
  OSI_NO_INTR(listen_fd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0));
  if (listen_fd < 0) {
  if (listen_fd < 0) {
    LOG_INFO("Error creating socket for test channel.");
    LOG_INFO("Error creating socket for test channel.");
    return;
    return;
@@ -99,7 +99,8 @@ bool PosixAsyncSocketServer::Connected() {


void PosixAsyncSocketServer::AcceptSocket() {
void PosixAsyncSocketServer::AcceptSocket() {
  int accept_fd = 0;
  int accept_fd = 0;
  OSI_NO_INTR(accept_fd = accept(server_socket_->fd(), NULL, NULL));
  OSI_NO_INTR(accept_fd =
                  accept4(server_socket_->fd(), NULL, NULL, SOCK_CLOEXEC));


  if (accept_fd < 0) {
  if (accept_fd < 0) {
    LOG_INFO("Error accepting test channel connection errno=%d (%s).", errno,
    LOG_INFO("Error accepting test channel connection errno=%d (%s).", errno,