diff options
author | Tom Cherry <tomcherry@google.com> | 2018-02-13 16:50:08 -0800 |
---|---|---|
committer | Tom Cherry <tomcherry@google.com> | 2018-02-28 10:45:45 -0800 |
commit | de6bd50d4238d19ec401127bcf2321dc679d908d (patch) | |
tree | f181f4acfa59f642c5927fc706060b192a2638e6 /init/service.cpp | |
parent | 304dacae8acd6c3469a7c5ff05357478ad2ff074 (diff) | |
download | system_core-de6bd50d4238d19ec401127bcf2321dc679d908d.tar.gz system_core-de6bd50d4238d19ec401127bcf2321dc679d908d.tar.bz2 system_core-de6bd50d4238d19ec401127bcf2321dc679d908d.zip |
init: add host side parser for init
Create a host side parser for init such that init rc files can be
verified for syntax correctness before being used on the device.
Bug: 36970783
Test: run the parser on init files on host
Change-Id: I7e8772e278ebaff727057308596ebacf28b6fdda
Diffstat (limited to 'init/service.cpp')
-rw-r--r-- | init/service.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/init/service.cpp b/init/service.cpp index 35dd3196c..09d8dae11 100644 --- a/init/service.cpp +++ b/init/service.cpp @@ -24,7 +24,6 @@ #include <sys/prctl.h> #include <sys/resource.h> #include <sys/stat.h> -#include <sys/system_properties.h> #include <sys/time.h> #include <sys/wait.h> #include <termios.h> @@ -33,8 +32,6 @@ #include <android-base/file.h> #include <android-base/logging.h> #include <android-base/parseint.h> -#include <android-base/properties.h> -#include <android-base/scopeguard.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <hidl-util/FQName.h> @@ -42,15 +39,23 @@ #include <selinux/selinux.h> #include <system/thread_defs.h> -#include "init.h" -#include "property_service.h" #include "rlimit_parser.h" #include "util.h" +#if defined(__ANDROID__) +#include <sys/system_properties.h> + +#include <android-base/properties.h> + +#include "init.h" +#include "property_service.h" +#else +#include "host_init_stubs.h" +#endif + using android::base::boot_clock; using android::base::GetProperty; using android::base::Join; -using android::base::make_scope_guard; using android::base::ParseInt; using android::base::StartsWith; using android::base::StringPrintf; @@ -1168,7 +1173,7 @@ bool ServiceParser::IsValidName(const std::string& name) const { // Property values can contain any characters, but may only be a certain length. // (The latter restriction is needed because `start` and `stop` work by writing // the service name to the "ctl.start" and "ctl.stop" properties.) - return is_legal_property_name("init.svc." + name) && name.size() <= PROP_VALUE_MAX; + return IsLegalPropertyName("init.svc." + name) && name.size() <= PROP_VALUE_MAX; } } // namespace init |