Loading init/service.cpp +10 −8 Original line number Diff line number Diff line Loading @@ -135,17 +135,21 @@ static void SetUpPidNamespace(const std::string& service_name) { } } static void ExpandArgs(const std::vector<std::string>& args, std::vector<char*>* strs) { static bool ExpandArgsAndExecv(const std::vector<std::string>& args) { std::vector<std::string> expanded_args; std::vector<char*> c_strings; expanded_args.resize(args.size()); strs->push_back(const_cast<char*>(args[0].c_str())); c_strings.push_back(const_cast<char*>(args[0].data())); for (std::size_t i = 1; i < args.size(); ++i) { if (!expand_props(args[i], &expanded_args[i])) { LOG(FATAL) << args[0] << ": cannot expand '" << args[i] << "'"; } strs->push_back(const_cast<char*>(expanded_args[i].c_str())); c_strings.push_back(expanded_args[i].data()); } strs->push_back(nullptr); c_strings.push_back(nullptr); return execv(c_strings[0], c_strings.data()) == 0; } unsigned long Service::next_start_order_ = 1; Loading Loading @@ -785,10 +789,8 @@ Result<Success> Service::Start() { // priority. Aborts on failure. SetProcessAttributes(); std::vector<char*> strs; ExpandArgs(args_, &strs); if (execv(strs[0], (char**)&strs[0]) < 0) { PLOG(ERROR) << "cannot execve('" << strs[0] << "')"; if (!ExpandArgsAndExecv(args_)) { PLOG(ERROR) << "cannot execve('" << args_[0] << "')"; } _exit(127); Loading Loading
init/service.cpp +10 −8 Original line number Diff line number Diff line Loading @@ -135,17 +135,21 @@ static void SetUpPidNamespace(const std::string& service_name) { } } static void ExpandArgs(const std::vector<std::string>& args, std::vector<char*>* strs) { static bool ExpandArgsAndExecv(const std::vector<std::string>& args) { std::vector<std::string> expanded_args; std::vector<char*> c_strings; expanded_args.resize(args.size()); strs->push_back(const_cast<char*>(args[0].c_str())); c_strings.push_back(const_cast<char*>(args[0].data())); for (std::size_t i = 1; i < args.size(); ++i) { if (!expand_props(args[i], &expanded_args[i])) { LOG(FATAL) << args[0] << ": cannot expand '" << args[i] << "'"; } strs->push_back(const_cast<char*>(expanded_args[i].c_str())); c_strings.push_back(expanded_args[i].data()); } strs->push_back(nullptr); c_strings.push_back(nullptr); return execv(c_strings[0], c_strings.data()) == 0; } unsigned long Service::next_start_order_ = 1; Loading Loading @@ -785,10 +789,8 @@ Result<Success> Service::Start() { // priority. Aborts on failure. SetProcessAttributes(); std::vector<char*> strs; ExpandArgs(args_, &strs); if (execv(strs[0], (char**)&strs[0]) < 0) { PLOG(ERROR) << "cannot execve('" << strs[0] << "')"; if (!ExpandArgsAndExecv(args_)) { PLOG(ERROR) << "cannot execve('" << args_[0] << "')"; } _exit(127); Loading