diff options
author | alk3pInjection <webmaster@raspii.tech> | 2023-04-20 00:08:54 +0800 |
---|---|---|
committer | alk3pInjection <webmaster@raspii.tech> | 2023-04-20 00:08:54 +0800 |
commit | a7dd355e8fe8ad0c579a4f0acd06b2e3b52dfc3a (patch) | |
tree | 2b552b59793a33466247fc6fb8cf89ecbfdc4a05 /init/util.cpp | |
parent | f0103ea35d56ccebbae16a43cac19ac38b11a9a2 (diff) | |
parent | 43816573a268998f892081eebf3ffe91d65b7e18 (diff) |
Merge tag 'LA.QSSI.13.0.r1-09800-qssi.0' into tachibanatachibana
"LA.QSSI.13.0.r1-09800-qssi.0"
Change-Id: I06ecf682f4d5595bce3383b6031506cc56bc0db2
Diffstat (limited to 'init/util.cpp')
-rw-r--r-- | init/util.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/init/util.cpp b/init/util.cpp index d1e518b57..5b3a73c0d 100644 --- a/init/util.cpp +++ b/init/util.cpp @@ -86,8 +86,8 @@ Result<uid_t> DecodeUid(const std::string& name) { * daemon. We communicate the file descriptor's value via the environment * variable ANDROID_SOCKET_ENV_PREFIX<name> ("ANDROID_SOCKET_foo"). */ -Result<int> CreateSocket(const std::string& name, int type, bool passcred, mode_t perm, uid_t uid, - gid_t gid, const std::string& socketcon) { +Result<int> CreateSocket(const std::string& name, int type, bool passcred, bool should_listen, + mode_t perm, uid_t uid, gid_t gid, const std::string& socketcon) { if (!socketcon.empty()) { if (setsockcreatecon(socketcon.c_str()) == -1) { return ErrnoError() << "setsockcreatecon(\"" << socketcon << "\") failed"; @@ -142,6 +142,9 @@ Result<int> CreateSocket(const std::string& name, int type, bool passcred, mode_ if (fchmodat(AT_FDCWD, addr.sun_path, perm, AT_SYMLINK_NOFOLLOW)) { return ErrnoError() << "Failed to fchmodat socket '" << addr.sun_path << "'"; } + if (should_listen && listen(fd, /* use OS maximum */ 1 << 30)) { + return ErrnoError() << "Failed to listen on socket '" << addr.sun_path << "'"; + } LOG(INFO) << "Created socket '" << addr.sun_path << "'" << ", mode " << std::oct << perm << std::dec |