2009-03-04 11:32:55 +08:00
|
|
|
# Copyright 2005 The Android Open Source Project
|
|
|
|
|
|
|
|
LOCAL_PATH:= $(call my-dir)
|
|
|
|
|
2015-02-05 06:46:36 +08:00
|
|
|
# --
|
|
|
|
|
|
|
|
ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
|
2015-04-29 03:39:41 +08:00
|
|
|
init_options += -DALLOW_LOCAL_PROP_OVERRIDE=1 -DALLOW_PERMISSIVE_SELINUX=1
|
2015-02-05 06:46:36 +08:00
|
|
|
else
|
2015-04-29 03:39:41 +08:00
|
|
|
init_options += -DALLOW_LOCAL_PROP_OVERRIDE=0 -DALLOW_PERMISSIVE_SELINUX=0
|
2015-02-05 06:46:36 +08:00
|
|
|
endif
|
|
|
|
|
2015-02-07 04:19:48 +08:00
|
|
|
init_options += -DLOG_UEVENTS=0
|
|
|
|
|
|
|
|
init_cflags += \
|
|
|
|
$(init_options) \
|
|
|
|
-Wall -Wextra \
|
|
|
|
-Wno-unused-parameter \
|
|
|
|
-Werror \
|
2015-02-05 06:46:36 +08:00
|
|
|
|
|
|
|
# --
|
|
|
|
|
2015-07-31 00:27:11 +08:00
|
|
|
# If building on Linux, then build unit test for the host.
|
|
|
|
ifeq ($(HOST_OS),linux)
|
|
|
|
include $(CLEAR_VARS)
|
|
|
|
LOCAL_CPPFLAGS := $(init_cflags)
|
|
|
|
LOCAL_SRC_FILES:= \
|
|
|
|
parser/tokenizer.cpp \
|
|
|
|
|
|
|
|
LOCAL_MODULE := libinit_parser
|
|
|
|
LOCAL_CLANG := true
|
|
|
|
include $(BUILD_HOST_STATIC_LIBRARY)
|
|
|
|
|
|
|
|
include $(CLEAR_VARS)
|
|
|
|
LOCAL_MODULE := init_parser_tests
|
|
|
|
LOCAL_SRC_FILES := \
|
|
|
|
parser/tokenizer_test.cpp \
|
|
|
|
|
|
|
|
LOCAL_STATIC_LIBRARIES := libinit_parser
|
|
|
|
LOCAL_CLANG := true
|
|
|
|
include $(BUILD_HOST_NATIVE_TEST)
|
|
|
|
endif
|
|
|
|
|
2015-02-07 04:19:48 +08:00
|
|
|
include $(CLEAR_VARS)
|
|
|
|
LOCAL_CPPFLAGS := $(init_cflags)
|
|
|
|
LOCAL_SRC_FILES:= \
|
2015-07-24 08:53:11 +08:00
|
|
|
action.cpp \
|
init: Add support for ambient capabilities.
Ambient capabilities are inherited in a straightforward way across
execve(2):
"
If you are nonroot but you have a capability, you can add it to pA.
If you do so, your children get that capability in pA, pP, and pE.
For example, you can set pA = CAP_NET_BIND_SERVICE, and your
children can automatically bind low-numbered ports.
"
This will allow us to get rid of the special meaning for AID_NET_ADMIN
and AID_NET_RAW, and if desired, to reduce the use of file capabilities
(which grant capabilities to any process that can execute the file). An
additional benefit of the latter is that a single .rc file can specify
all properties for a service, without having to rely on a separate file
for file capabilities.
Ambient capabilities are supported starting with kernel 4.3 and have
been backported to all Android common kernels back to 3.10.
I chose to not use Minijail here (though I'm still using libcap) for
two reasons:
1-The Minijail code is designed to work in situations where the process
is holding any set of capabilities, so it's more complex. The situation
when forking from init allows for simpler code.
2-The way Minijail is structured right now, we would not be able to
make the required SELinux calls between UID/GID dropping and other priv
dropping code. In the future, it will make sense to add some sort of
"hook" to Minijail so that it can be used in situations where we want
to do other operations between some of the privilege-dropping
operations carried out by Minijail.
Bug: 32438163
Test: Use sample service.
Change-Id: I3226cc95769d1beacbae619cb6c6e6a5425890fb
2016-10-27 22:33:03 +08:00
|
|
|
capabilities.cpp \
|
2016-10-27 22:45:34 +08:00
|
|
|
descriptors.cpp \
|
2015-08-27 02:43:36 +08:00
|
|
|
import_parser.cpp \
|
2015-02-07 04:19:48 +08:00
|
|
|
init_parser.cpp \
|
2015-03-28 14:20:44 +08:00
|
|
|
log.cpp \
|
2015-02-07 04:19:48 +08:00
|
|
|
parser.cpp \
|
2015-08-01 03:45:25 +08:00
|
|
|
service.cpp \
|
2015-02-07 04:19:48 +08:00
|
|
|
util.cpp \
|
|
|
|
|
2017-01-04 00:37:54 +08:00
|
|
|
LOCAL_STATIC_LIBRARIES := libbase libselinux liblog libprocessgroup libnl
|
init: Add support for ambient capabilities.
Ambient capabilities are inherited in a straightforward way across
execve(2):
"
If you are nonroot but you have a capability, you can add it to pA.
If you do so, your children get that capability in pA, pP, and pE.
For example, you can set pA = CAP_NET_BIND_SERVICE, and your
children can automatically bind low-numbered ports.
"
This will allow us to get rid of the special meaning for AID_NET_ADMIN
and AID_NET_RAW, and if desired, to reduce the use of file capabilities
(which grant capabilities to any process that can execute the file). An
additional benefit of the latter is that a single .rc file can specify
all properties for a service, without having to rely on a separate file
for file capabilities.
Ambient capabilities are supported starting with kernel 4.3 and have
been backported to all Android common kernels back to 3.10.
I chose to not use Minijail here (though I'm still using libcap) for
two reasons:
1-The Minijail code is designed to work in situations where the process
is holding any set of capabilities, so it's more complex. The situation
when forking from init allows for simpler code.
2-The way Minijail is structured right now, we would not be able to
make the required SELinux calls between UID/GID dropping and other priv
dropping code. In the future, it will make sense to add some sort of
"hook" to Minijail so that it can be used in situations where we want
to do other operations between some of the privilege-dropping
operations carried out by Minijail.
Bug: 32438163
Test: Use sample service.
Change-Id: I3226cc95769d1beacbae619cb6c6e6a5425890fb
2016-10-27 22:33:03 +08:00
|
|
|
LOCAL_WHOLE_STATIC_LIBRARIES := libcap
|
2015-02-07 04:19:48 +08:00
|
|
|
LOCAL_MODULE := libinit
|
2015-08-15 23:24:23 +08:00
|
|
|
LOCAL_SANITIZE := integer
|
2015-06-11 13:43:51 +08:00
|
|
|
LOCAL_CLANG := true
|
2015-02-07 04:19:48 +08:00
|
|
|
include $(BUILD_STATIC_LIBRARY)
|
|
|
|
|
|
|
|
include $(CLEAR_VARS)
|
|
|
|
LOCAL_CPPFLAGS := $(init_cflags)
|
2009-03-04 11:32:55 +08:00
|
|
|
LOCAL_SRC_FILES:= \
|
2015-02-05 02:25:09 +08:00
|
|
|
bootchart.cpp \
|
2015-02-04 09:12:07 +08:00
|
|
|
builtins.cpp \
|
|
|
|
devices.cpp \
|
|
|
|
init.cpp \
|
|
|
|
keychords.cpp \
|
|
|
|
property_service.cpp \
|
2016-10-22 04:13:02 +08:00
|
|
|
seccomp.cpp \
|
2015-02-04 09:12:07 +08:00
|
|
|
signal_handler.cpp \
|
|
|
|
ueventd.cpp \
|
|
|
|
ueventd_parser.cpp \
|
|
|
|
watchdogd.cpp \
|
|
|
|
|
2009-03-04 11:32:55 +08:00
|
|
|
LOCAL_MODULE:= init
|
2015-05-08 23:30:33 +08:00
|
|
|
LOCAL_C_INCLUDES += \
|
|
|
|
system/core/mkbootimg
|
|
|
|
|
2009-03-04 11:32:55 +08:00
|
|
|
LOCAL_FORCE_STATIC_EXECUTABLE := true
|
|
|
|
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
|
|
|
|
LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
|
|
|
|
|
2012-10-17 14:07:05 +08:00
|
|
|
LOCAL_STATIC_LIBRARIES := \
|
2015-02-07 04:19:48 +08:00
|
|
|
libinit \
|
2016-06-25 09:28:03 +08:00
|
|
|
libbootloader_message \
|
2015-02-07 04:19:48 +08:00
|
|
|
libfs_mgr \
|
2015-05-22 22:43:50 +08:00
|
|
|
libfec \
|
|
|
|
libfec_rs \
|
2015-04-09 08:59:19 +08:00
|
|
|
libsquashfs_utils \
|
2015-02-07 04:19:48 +08:00
|
|
|
liblogwrap \
|
|
|
|
libcutils \
|
2017-01-12 06:03:11 +08:00
|
|
|
libext4_utils \
|
2016-02-04 05:44:44 +08:00
|
|
|
libbase \
|
2015-02-07 04:19:48 +08:00
|
|
|
libc \
|
|
|
|
libselinux \
|
2016-10-22 04:13:02 +08:00
|
|
|
libseccomp_policy \
|
2015-08-05 05:23:04 +08:00
|
|
|
liblog \
|
2016-08-06 06:47:57 +08:00
|
|
|
libcrypto_utils \
|
|
|
|
libcrypto \
|
2015-03-26 23:49:42 +08:00
|
|
|
libc++_static \
|
2015-04-14 07:29:05 +08:00
|
|
|
libdl \
|
2017-01-12 06:37:50 +08:00
|
|
|
libsparse \
|
2016-06-02 05:03:55 +08:00
|
|
|
libz \
|
2017-01-04 00:37:54 +08:00
|
|
|
libprocessgroup \
|
|
|
|
libnl \
|
2012-01-13 21:48:47 +08:00
|
|
|
|
init: Add support for ambient capabilities.
Ambient capabilities are inherited in a straightforward way across
execve(2):
"
If you are nonroot but you have a capability, you can add it to pA.
If you do so, your children get that capability in pA, pP, and pE.
For example, you can set pA = CAP_NET_BIND_SERVICE, and your
children can automatically bind low-numbered ports.
"
This will allow us to get rid of the special meaning for AID_NET_ADMIN
and AID_NET_RAW, and if desired, to reduce the use of file capabilities
(which grant capabilities to any process that can execute the file). An
additional benefit of the latter is that a single .rc file can specify
all properties for a service, without having to rely on a separate file
for file capabilities.
Ambient capabilities are supported starting with kernel 4.3 and have
been backported to all Android common kernels back to 3.10.
I chose to not use Minijail here (though I'm still using libcap) for
two reasons:
1-The Minijail code is designed to work in situations where the process
is holding any set of capabilities, so it's more complex. The situation
when forking from init allows for simpler code.
2-The way Minijail is structured right now, we would not be able to
make the required SELinux calls between UID/GID dropping and other priv
dropping code. In the future, it will make sense to add some sort of
"hook" to Minijail so that it can be used in situations where we want
to do other operations between some of the privilege-dropping
operations carried out by Minijail.
Bug: 32438163
Test: Use sample service.
Change-Id: I3226cc95769d1beacbae619cb6c6e6a5425890fb
2016-10-27 22:33:03 +08:00
|
|
|
# Create symlinks.
|
2014-11-25 07:43:34 +08:00
|
|
|
LOCAL_POST_INSTALL_CMD := $(hide) mkdir -p $(TARGET_ROOT_OUT)/sbin; \
|
|
|
|
ln -sf ../init $(TARGET_ROOT_OUT)/sbin/ueventd; \
|
|
|
|
ln -sf ../init $(TARGET_ROOT_OUT)/sbin/watchdogd
|
2014-03-07 07:07:42 +08:00
|
|
|
|
2015-08-15 23:24:23 +08:00
|
|
|
LOCAL_SANITIZE := integer
|
2015-06-11 13:43:51 +08:00
|
|
|
LOCAL_CLANG := true
|
2009-03-04 11:32:55 +08:00
|
|
|
include $(BUILD_EXECUTABLE)
|
2015-02-07 04:19:48 +08:00
|
|
|
|
|
|
|
|
init: Add support for ambient capabilities.
Ambient capabilities are inherited in a straightforward way across
execve(2):
"
If you are nonroot but you have a capability, you can add it to pA.
If you do so, your children get that capability in pA, pP, and pE.
For example, you can set pA = CAP_NET_BIND_SERVICE, and your
children can automatically bind low-numbered ports.
"
This will allow us to get rid of the special meaning for AID_NET_ADMIN
and AID_NET_RAW, and if desired, to reduce the use of file capabilities
(which grant capabilities to any process that can execute the file). An
additional benefit of the latter is that a single .rc file can specify
all properties for a service, without having to rely on a separate file
for file capabilities.
Ambient capabilities are supported starting with kernel 4.3 and have
been backported to all Android common kernels back to 3.10.
I chose to not use Minijail here (though I'm still using libcap) for
two reasons:
1-The Minijail code is designed to work in situations where the process
is holding any set of capabilities, so it's more complex. The situation
when forking from init allows for simpler code.
2-The way Minijail is structured right now, we would not be able to
make the required SELinux calls between UID/GID dropping and other priv
dropping code. In the future, it will make sense to add some sort of
"hook" to Minijail so that it can be used in situations where we want
to do other operations between some of the privilege-dropping
operations carried out by Minijail.
Bug: 32438163
Test: Use sample service.
Change-Id: I3226cc95769d1beacbae619cb6c6e6a5425890fb
2016-10-27 22:33:03 +08:00
|
|
|
# Unit tests.
|
|
|
|
# =========================================================
|
2015-02-07 04:19:48 +08:00
|
|
|
include $(CLEAR_VARS)
|
|
|
|
LOCAL_MODULE := init_tests
|
|
|
|
LOCAL_SRC_FILES := \
|
2015-02-07 12:15:18 +08:00
|
|
|
init_parser_test.cpp \
|
2015-02-07 04:19:48 +08:00
|
|
|
util_test.cpp \
|
|
|
|
|
|
|
|
LOCAL_SHARED_LIBRARIES += \
|
|
|
|
libcutils \
|
2015-03-17 01:08:46 +08:00
|
|
|
libbase \
|
2015-02-07 04:19:48 +08:00
|
|
|
|
|
|
|
LOCAL_STATIC_LIBRARIES := libinit
|
2015-08-15 23:24:23 +08:00
|
|
|
LOCAL_SANITIZE := integer
|
2015-06-11 13:43:51 +08:00
|
|
|
LOCAL_CLANG := true
|
2016-10-27 22:45:34 +08:00
|
|
|
LOCAL_CPPFLAGS := -Wall -Wextra -Werror
|
2015-02-07 04:19:48 +08:00
|
|
|
include $(BUILD_NATIVE_TEST)
|