Loading init/init.cpp +16 −8 Original line number Diff line number Diff line Loading @@ -585,6 +585,19 @@ std::string build_triggers_string(struct action *cur_action) { return result; } bool expand_command_arguments(int nargs, char** args, std::vector<std::string>* expanded_args) { std::vector<std::string>& strs = *expanded_args; strs.resize(nargs); strs[0] = args[0]; for (int i = 1; i < nargs; ++i) { if (expand_props(args[i], &strs[i]) == -1) { ERROR("%s: cannot expand '%s'\n", args[0], args[i]); return false; } } return true; } void execute_one_command() { Timer t; Loading @@ -606,14 +619,9 @@ void execute_one_command() { return; } int result = 0; std::vector<std::string> arg_strs(cur_command->nargs); arg_strs[0] = cur_command->args[0]; for (int i = 1; i < cur_command->nargs; ++i) { if (expand_props(cur_command->args[i], &arg_strs[i]) == -1) { ERROR("%s: cannot expand '%s'\n", cur_command->args[0], cur_command->args[i]); std::vector<std::string> arg_strs; if (!expand_command_arguments(cur_command->nargs, cur_command->args, &arg_strs)) { result = -EINVAL; break; } } if (result == 0) { std::vector<char*> args; Loading init/init.h +1 −0 Original line number Diff line number Diff line Loading @@ -161,5 +161,6 @@ int selinux_reload_policy(void); void zap_stdio(void); void register_epoll_handler(int fd, void (*fn)()); bool expand_command_arguments(int nargs, char** args, std::vector<std::string>* expanded_args); #endif /* _INIT_INIT_H */ init/signal_handler.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -136,7 +136,14 @@ static bool wait_for_one_process() { struct listnode* node; list_for_each(node, &svc->onrestart.commands) { command* cmd = node_to_item(node, struct command, clist); cmd->func(cmd->nargs, cmd->args); std::vector<std::string> arg_strs; if (expand_command_arguments(cmd->nargs, cmd->args, &arg_strs)) { std::vector<char*> args; for (auto& s : arg_strs) { args.push_back(&s[0]); } cmd->func(args.size(), &args[0]); } } svc->NotifyStateChange("restarting"); return true; Loading Loading
init/init.cpp +16 −8 Original line number Diff line number Diff line Loading @@ -585,6 +585,19 @@ std::string build_triggers_string(struct action *cur_action) { return result; } bool expand_command_arguments(int nargs, char** args, std::vector<std::string>* expanded_args) { std::vector<std::string>& strs = *expanded_args; strs.resize(nargs); strs[0] = args[0]; for (int i = 1; i < nargs; ++i) { if (expand_props(args[i], &strs[i]) == -1) { ERROR("%s: cannot expand '%s'\n", args[0], args[i]); return false; } } return true; } void execute_one_command() { Timer t; Loading @@ -606,14 +619,9 @@ void execute_one_command() { return; } int result = 0; std::vector<std::string> arg_strs(cur_command->nargs); arg_strs[0] = cur_command->args[0]; for (int i = 1; i < cur_command->nargs; ++i) { if (expand_props(cur_command->args[i], &arg_strs[i]) == -1) { ERROR("%s: cannot expand '%s'\n", cur_command->args[0], cur_command->args[i]); std::vector<std::string> arg_strs; if (!expand_command_arguments(cur_command->nargs, cur_command->args, &arg_strs)) { result = -EINVAL; break; } } if (result == 0) { std::vector<char*> args; Loading
init/init.h +1 −0 Original line number Diff line number Diff line Loading @@ -161,5 +161,6 @@ int selinux_reload_policy(void); void zap_stdio(void); void register_epoll_handler(int fd, void (*fn)()); bool expand_command_arguments(int nargs, char** args, std::vector<std::string>* expanded_args); #endif /* _INIT_INIT_H */
init/signal_handler.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -136,7 +136,14 @@ static bool wait_for_one_process() { struct listnode* node; list_for_each(node, &svc->onrestart.commands) { command* cmd = node_to_item(node, struct command, clist); cmd->func(cmd->nargs, cmd->args); std::vector<std::string> arg_strs; if (expand_command_arguments(cmd->nargs, cmd->args, &arg_strs)) { std::vector<char*> args; for (auto& s : arg_strs) { args.push_back(&s[0]); } cmd->func(args.size(), &args[0]); } } svc->NotifyStateChange("restarting"); return true; Loading