summaryrefslogtreecommitdiff
path: root/init/service_utils.h
diff options
context:
space:
mode:
authorTom Cherry <tomcherry@google.com>2019-07-09 13:33:36 -0700
committerTom Cherry <tomcherry@google.com>2019-07-15 12:17:30 -0700
commit2e4c85f157bd52d4daaf0b4e67280aa72f98da07 (patch)
treebb553134c66c156072cc747c99d93812acc5bc5f /init/service_utils.h
parent8a779ee959996b413a8539d2a571e34803be0bf5 (diff)
init: clean up file / socket descriptor creation
clang-tidy hinted that some of this code wasn't right. Looking deeper, there is really not much related to file and socket descriptors, except that they're published in similar ways to the environment. All of the abstraction into a 'Descriptor' class takes us further away from specifying what we really mean. This removes that abstraction, adds stricter checks and better errors for parsing init scripts, reports sockets and files that are unable to be acquired before exec, and updates the README.md for the passcred option. Test: build, logd (uses files and sockets) works Change-Id: I59e611e95c85bdbefa779ef69b32b9dd4ee203e2
Diffstat (limited to 'init/service_utils.h')
-rw-r--r--init/service_utils.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/init/service_utils.h b/init/service_utils.h
index 365cb298b..befce253a 100644
--- a/init/service_utils.h
+++ b/init/service_utils.h
@@ -29,6 +29,25 @@
namespace android {
namespace init {
+struct SocketDescriptor {
+ std::string name;
+ int type = 0;
+ uid_t uid = 0;
+ gid_t gid = 0;
+ int perm = 0;
+ std::string context;
+ bool passcred = false;
+
+ Result<void> CreateAndPublish(const std::string& global_context) const;
+};
+
+struct FileDescriptor {
+ std::string name;
+ std::string type;
+
+ Result<void> CreateAndPublish() const;
+};
+
struct NamespaceInfo {
int flags;
// Pair of namespace type, path to name.