From: Kevin Day Date: Tue, 5 Jul 2022 13:43:31 +0000 (-0500) Subject: Refactor: Rename "script" setting to "engine". X-Git-Tag: 0.6.0~87 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=2fecb98ab148c8ed1dba5d7180974c330ff4eefa;p=fll Refactor: Rename "script" setting to "engine". The scripting engine is now called "engine". This fixes ambiguity issues between the "script" action and the scripting engine. This makes the code and configuration files easier to read and understand. --- diff --git a/level_3/controller/c/common.h b/level_3/controller/c/common.h index 938a159..2e851c7 100644 --- a/level_3/controller/c/common.h +++ b/level_3/controller/c/common.h @@ -167,22 +167,30 @@ extern "C" { /** * The main program data. * - * child: Reserved for a child process, often representing the child return status or the child process ID. - * context: The color context. - * default_path_setting: The default setting path. - * default_path_pid: The default PID file path. - * default_path_socket: The default socket file path. - * error: The output file for error printing. - * as_init: Designate whether or not this is running as an init program. - * output: The output file for general printing. - * parameters: The state of pre-defined parameters passed to the program. - * pid: The PID of the program. - * process_pipe: Designate whether or not to process the input pipe. - * program_name: The name of the program. - * program_name_long: The long name of the program. - * signal: The process signal management structure. - * umask: The umask settings, needed for avoiding calls to umask() to read the current umask. - * warning: The output file for warning printing. + * child: Reserved for a child process, often representing the child return status or the child process ID. + * context: The color context. + * default_engine: The default scripting engine. + * default_path_pid: The default PID file path. + * default_path_pid_init: The default PID file path, when run as init. + * default_path_pid_prefix: The default PID file path prefix. + * default_path_pid_suffix: The default PID file path suffix. + * default_path_setting: The default setting path. + * default_path_setting_init: The default setting path, when run as init. + * default_path_socket: The default socket file path. + * default_path_socket_init: The default socket file path, when run as init. + * default_path_socket_prefix: The default socket file path prefix. + * default_path_socket_suffix: The default socket file path suffix. + * error: The output file for error printing. + * as_init: Designate whether or not this is running as an init program. + * output: The output file for general printing. + * parameters: The state of pre-defined parameters passed to the program. + * pid: The PID of the program. + * process_pipe: Designate whether or not to process the input pipe. + * program_name: The name of the program. + * program_name_long: The long name of the program. + * signal: The process signal management structure. + * umask: The umask settings, needed for avoiding calls to umask() to read the current umask. + * warning: The output file for warning printing. */ #ifndef _di_controller_main_t_ typedef struct { @@ -201,6 +209,7 @@ extern "C" { mode_t umask; int child; + const f_string_static_t *default_engine; const f_string_static_t *default_path_pid; const f_string_static_t *default_path_pid_init; const f_string_static_t *default_path_pid_prefix; @@ -211,7 +220,6 @@ extern "C" { const f_string_static_t *default_path_socket_init; const f_string_static_t *default_path_socket_prefix; const f_string_static_t *default_path_socket_suffix; - const f_string_static_t *default_program_script; const f_string_static_t *program_name; const f_string_static_t *program_name_long; diff --git a/level_3/controller/c/common/private-common.c b/level_3/controller/c/common/private-common.c index bced2e7..6cb1c2e 100644 --- a/level_3/controller/c/common/private-common.c +++ b/level_3/controller/c/common/private-common.c @@ -31,6 +31,7 @@ extern "C" { const f_string_static_t controller_define_s = macro_f_string_static_t_initialize(CONTROLLER_define_s, 0, CONTROLLER_define_s_length); const f_string_static_t controller_delay_s = macro_f_string_static_t_initialize(CONTROLLER_delay_s, 0, CONTROLLER_delay_s_length); const f_string_static_t controller_disable_s = macro_f_string_static_t_initialize(CONTROLLER_disable_s, 0, CONTROLLER_disable_s_length); + const f_string_static_t controller_engine_s = macro_f_string_static_t_initialize(CONTROLLER_engine_s, 0, CONTROLLER_engine_s_length); const f_string_static_t controller_entry_s = macro_f_string_static_t_initialize(CONTROLLER_entry_s, 0, CONTROLLER_entry_s_length); const f_string_static_t controller_entries_s = macro_f_string_static_t_initialize(CONTROLLER_entries_s, 0, CONTROLLER_entries_s_length); const f_string_static_t controller_environment_s = macro_f_string_static_t_initialize(CONTROLLER_environment_s, 0, CONTROLLER_environment_s_length); diff --git a/level_3/controller/c/common/private-common.h b/level_3/controller/c/common/private-common.h index c0cf3c0..e265982 100644 --- a/level_3/controller/c/common/private-common.h +++ b/level_3/controller/c/common/private-common.h @@ -56,6 +56,7 @@ extern "C" { #define CONTROLLER_define_s "define" #define CONTROLLER_delay_s "delay" #define CONTROLLER_disable_s "disable" + #define CONTROLLER_engine_s "engine" #define CONTROLLER_entry_s "entry" #define CONTROLLER_entries_s "entries" #define CONTROLLER_environment_s "environment" @@ -186,6 +187,7 @@ extern "C" { #define CONTROLLER_define_s_length 6 #define CONTROLLER_delay_s_length 5 #define CONTROLLER_disable_s_length 7 + #define CONTROLLER_engine_s_length 6 #define CONTROLLER_entry_s_length 5 #define CONTROLLER_entries_s_length 7 #define CONTROLLER_environment_s_length 11 @@ -316,6 +318,7 @@ extern "C" { extern const f_string_static_t controller_define_s; extern const f_string_static_t controller_delay_s; extern const f_string_static_t controller_disable_s; + extern const f_string_static_t controller_engine_s; extern const f_string_static_t controller_entry_s; extern const f_string_static_t controller_entries_s; extern const f_string_static_t controller_environment_s; diff --git a/level_3/controller/c/common/private-rule.c b/level_3/controller/c/common/private-rule.c index a638272..ecd60b1 100644 --- a/level_3/controller/c/common/private-rule.c +++ b/level_3/controller/c/common/private-rule.c @@ -57,9 +57,9 @@ extern "C" { void controller_rule_delete_simple(controller_rule_t * const rule) { f_string_dynamic_resize(0, &rule->alias); + f_string_dynamic_resize(0, &rule->engine); f_string_dynamic_resize(0, &rule->name); f_string_dynamic_resize(0, &rule->path); - f_string_dynamic_resize(0, &rule->script); f_string_maps_resize(0, &rule->define); f_string_maps_resize(0, &rule->parameter); diff --git a/level_3/controller/c/common/private-rule.h b/level_3/controller/c/common/private-rule.h index bba3702..d454a92 100644 --- a/level_3/controller/c/common/private-rule.h +++ b/level_3/controller/c/common/private-rule.h @@ -265,6 +265,7 @@ extern "C" { * - capability: Setting type representing a capability. * - cgroup: Setting type representing a control group. * - define: Setting type representing a define. + * - engine: Setting type representing a engine. * - environment: Setting type representing a environment. * - group: Setting type representing a group. * - limit: Setting type representing a limit. @@ -274,7 +275,6 @@ extern "C" { * - parameter: Setting type representing a parameter. * - path: Setting type representing a path. * - scheduler: Setting type representing a scheduler. - * - script: Setting type representing a script. * - user: Setting type representing a user. * * controller_rule_has_*: @@ -289,6 +289,7 @@ extern "C" { * capability: The capability setting if the Rule "has" a capability. * cgroup: The control group setting if the Rule "has" a control group. * define: Any defines (environment variables) made available to the Rule for IKI substitution or just as environment variables. + * engine: The program or path to the program of the scripting engine to use when processing scripts in this Rule. * environment: All environment variables allowed to be exposed to the Rule when processing. * group: The group ID if the Rule "has" a group. * groups: A set of group IDs to run the process with (first specified group is the primary group). @@ -301,7 +302,6 @@ extern "C" { * parameter: Any parameters made available to the Rule for IKI substitution. * path: The path to the Rule file. * scheduler: The scheduler setting if the Rule "has" a scheduler. - * script: The program or path to the program of the scripting engine to use when processing scripts in this Rule. * status: A set of action-specific success/failure status of the Rule. Each index represents a controller_rule_action_type_* enum value. Index 0 represents a global status. * timeout_kill: The timeout to wait relating to using a kill signal. * timeout_start: The timeout to wait relating to starting a process. @@ -315,6 +315,7 @@ extern "C" { controller_rule_setting_type_capability_e, controller_rule_setting_type_cgroup_e, controller_rule_setting_type_define_e, + controller_rule_setting_type_engine_e, controller_rule_setting_type_environment_e, controller_rule_setting_type_group_e, controller_rule_setting_type_limit_e, @@ -324,7 +325,6 @@ extern "C" { controller_rule_setting_type_parameter_e, controller_rule_setting_type_path_e, controller_rule_setting_type_scheduler_e, - controller_rule_setting_type_script_e, controller_rule_setting_type_timeout_e, controller_rule_setting_type_user_e, }; @@ -357,9 +357,9 @@ extern "C" { f_time_spec_t timestamp; f_string_dynamic_t alias; + f_string_dynamic_t engine; f_string_dynamic_t name; f_string_dynamic_t path; - f_string_dynamic_t script; f_string_maps_t define; f_string_maps_t parameter; diff --git a/level_3/controller/c/common/private-task.c b/level_3/controller/c/common/private-task.c index 08f5396..d50f4e9 100644 --- a/level_3/controller/c/common/private-task.c +++ b/level_3/controller/c/common/private-task.c @@ -52,10 +52,10 @@ extern "C" { void controller_task_delete_simple(controller_task_t * const task) { f_string_dynamic_resize(0, &task->alias); + f_string_dynamic_resize(0, &task->engine); f_string_dynamic_resize(0, &task->help); f_string_dynamic_resize(0, &task->name); f_string_dynamic_resize(0, &task->path); - f_string_dynamic_resize(0, &task->script); f_string_maps_resize(0, &task->arguments); f_string_maps_resize(0, &task->defines); diff --git a/level_3/controller/c/common/private-task.h b/level_3/controller/c/common/private-task.h index f450499..eec60d3 100644 --- a/level_3/controller/c/common/private-task.h +++ b/level_3/controller/c/common/private-task.h @@ -81,11 +81,12 @@ extern "C" { * A Task structure. * * controller_task_setting_type_*: - * - affinity: Setting type representing a affinity. + * - affinity: Setting type representing an affinity. * - capability: Setting type representing a capability. * - cgroup: Setting type representing a cgroup (control group). * - define: Setting type representing a define. - * - environment: Setting type representing a environment. + * - engine: Setting type representing an engine. + * - environment: Setting type representing an environment. * - group: Setting type representing a group. * - limit: Setting type representing a limit. * - name: Setting type representing a name. @@ -93,7 +94,6 @@ extern "C" { * - parameter: Setting type representing a parameter. * - path: Setting type representing a path. * - scheduler: Setting type representing a scheduler. - * - script: Setting type representing a script. * - user: Setting type representing a user. * * controller_task_has_*: @@ -109,6 +109,7 @@ extern "C" { * capability: The capability setting if the Task "has" a capability. * cgroup: The cgroup (control group) setting if the Task "has" a cgroup (control group). * define: Any defines (environment variables) made available to the Task for IKI substitution or just as environment variables. + * engine: The program or path to the program of the scripting engine to use when processing scripts in this Task. * environment: All environment variables allowed to be exposed to the Task when processing. * group: The group ID if the Task "has" a group. * groups: A set of group IDs to run the process with (first specified group is the primary group). @@ -119,7 +120,6 @@ extern "C" { * parameter: Any parameters made available to the Task for IKI substitution. * path: The path to the Task file. * scheduler: The scheduler setting if the Task "has" a scheduler. - * script: The program or path to the program of the scripting engine to use when processing scripts in this Task. * state: The current active/inactive state of the Task. * status: The last returned status of the Task. * timestamp: The timestamp when the Task was last updated. @@ -131,6 +131,7 @@ extern "C" { controller_task_setting_type_capability_e, controller_task_setting_type_cgroup_e, controller_task_setting_type_define_e, + controller_task_setting_type_engine_e, controller_task_setting_type_environment_e, controller_task_setting_type_group_e, controller_task_setting_type_limit_e, @@ -139,7 +140,6 @@ extern "C" { controller_task_setting_type_parameter_e, controller_task_setting_type_path_e, controller_task_setting_type_scheduler_e, - controller_task_setting_type_script_e, controller_task_setting_type_user_e, }; @@ -163,10 +163,10 @@ extern "C" { f_time_spec_t timestamp; f_string_dynamic_t alias; + f_string_dynamic_t engine; f_string_dynamic_t help; f_string_dynamic_t name; f_string_dynamic_t path; - f_string_dynamic_t script; f_string_maps_t arguments; f_string_maps_t defines; diff --git a/level_3/controller/c/main-common.c b/level_3/controller/c/main-common.c index bae8976..49a9afc 100644 --- a/level_3/controller/c/main-common.c +++ b/level_3/controller/c/main-common.c @@ -11,7 +11,7 @@ extern "C" { #endif // _di_controller_program_name_ #ifndef _di_controller_defines_ - const f_string_static_t controller_default_program_script_s = macro_f_string_static_t_initialize(CONTROLLER_default_program_script_s, 0, CONTROLLER_default_program_script_s_length); + const f_string_static_t controller_default_engine_s = macro_f_string_static_t_initialize(CONTROLLER_default_engine_s, 0, CONTROLLER_default_engine_s_length); const f_string_static_t controller_path_pid_s = macro_f_string_static_t_initialize(CONTROLLER_path_pid_s, 0, CONTROLLER_path_pid_s_length); const f_string_static_t controller_path_pid_init_s = macro_f_string_static_t_initialize(CONTROLLER_path_pid_init_s, 0, CONTROLLER_path_pid_init_s_length); const f_string_static_t controller_path_pid_prefix_s = macro_f_string_static_t_initialize(CONTROLLER_path_pid_prefix_s, 0, CONTROLLER_path_pid_prefix_s_length); diff --git a/level_3/controller/c/main-common.h b/level_3/controller/c/main-common.h index 0653421..bfb5271 100644 --- a/level_3/controller/c/main-common.h +++ b/level_3/controller/c/main-common.h @@ -150,14 +150,14 @@ extern "C" { #endif // defined(_override_controller_path_socket_suffix_) && defined(_override_controller_path_socket_suffix_length_) #if defined(_override_controller_default_program_script_) && defined(_override_controller_default_program_script_length_) - #define CONTROLLER_default_program_script_s _override_controller_default_program_script_ - #define CONTROLLER_default_program_script_s_length _override_controller_default_program_script_length_ + #define CONTROLLER_default_engine_s _override_controller_default_engine_ + #define CONTROLLER_default_engine_s_length _override_controller_default_engine_length_ #else - #define CONTROLLER_default_program_script_s "bash" - #define CONTROLLER_default_program_script_s_length 4 + #define CONTROLLER_default_engine_s "bash" + #define CONTROLLER_default_engine_s_length 4 #endif // defined(_override_controller_default_program_script_) && defined(_override_controller_default_program_script_length_) - extern const f_string_static_t controller_default_program_script_s; + extern const f_string_static_t controller_default_engine_s; extern const f_string_static_t controller_path_pid_s; extern const f_string_static_t controller_path_pid_init_s; extern const f_string_static_t controller_path_pid_prefix_s; diff --git a/level_3/controller/c/main.c b/level_3/controller/c/main.c index c8698bf..b4b8570 100644 --- a/level_3/controller/c/main.c +++ b/level_3/controller/c/main.c @@ -20,6 +20,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_file_umask_get(&data.umask); + data.default_engine = &controller_default_engine_s; data.default_path_setting = &controller_path_settings_s; data.default_path_setting_init = &controller_path_settings_init_s; data.default_path_pid = &controller_path_pid_s; @@ -30,7 +31,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.default_path_socket_init = &controller_path_socket_init_s; data.default_path_socket_prefix = &controller_path_socket_prefix_s; data.default_path_socket_suffix = &controller_path_socket_suffix_s; - data.default_program_script = &controller_default_program_script_s; data.program_name = &controller_program_name_s; data.program_name_long = &controller_program_name_long_s; diff --git a/level_3/controller/c/rule/private-rule.c b/level_3/controller/c/rule/private-rule.c index 301780b..1ca1958 100644 --- a/level_3/controller/c/rule/private-rule.c +++ b/level_3/controller/c/rule/private-rule.c @@ -764,9 +764,9 @@ extern "C" { destination->timestamp.nanoseconds = source.timestamp.nanoseconds; destination->alias.used = 0; + destination->engine.used = 0; destination->name.used = 0; destination->path.used = 0; - destination->script.used = 0; destination->define.used = 0; destination->parameter.used = 0; @@ -794,13 +794,13 @@ extern "C" { status = f_string_dynamic_append(source.alias, &destination->alias); if (F_status_is_error(status)) return status; - status = f_string_dynamic_append(source.name, &destination->name); + status = f_string_dynamic_append(source.engine, &destination->engine); if (F_status_is_error(status)) return status; - status = f_string_dynamic_append(source.path, &destination->path); + status = f_string_dynamic_append(source.name, &destination->name); if (F_status_is_error(status)) return status; - status = f_string_dynamic_append(source.script, &destination->script); + status = f_string_dynamic_append(source.path, &destination->path); if (F_status_is_error(status)) return status; status = f_string_maps_append_all(source.define, &destination->define); @@ -1127,11 +1127,11 @@ extern "C" { } do { - if (process->rule.script.used) { - status = controller_rule_execute_foreground(process->rule.items.array[i].type, process->rule.script, arguments_none, options, &execute_set, process); + if (process->rule.engine.used) { + status = controller_rule_execute_foreground(process->rule.items.array[i].type, process->rule.engine, arguments_none, options, &execute_set, process); } else { - status = controller_rule_execute_foreground(process->rule.items.array[i].type, *global.main->default_program_script, arguments_none, options, &execute_set, process); + status = controller_rule_execute_foreground(process->rule.items.array[i].type, *global.main->default_engine, arguments_none, options, &execute_set, process); } if (status == F_child || F_status_set_fine(status) == F_lock) break; @@ -1207,7 +1207,7 @@ extern "C" { } do { - status = controller_rule_execute_pid_with(process->rule.items.array[i].pid_file, process->rule.items.array[i].type, process->rule.script.used ? process->rule.script : *global.main->default_program_script, arguments_none, options, process->rule.items.array[i].with, &execute_set, process); + status = controller_rule_execute_pid_with(process->rule.items.array[i].pid_file, process->rule.items.array[i].type, process->rule.engine.used ? process->rule.engine : *global.main->default_engine, arguments_none, options, process->rule.items.array[i].with, &execute_set, process); if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break; if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break; @@ -1365,7 +1365,7 @@ extern "C" { const f_string_statics_t simulated_arguments = f_string_statics_t_initialize; fl_execute_parameter_t simulated_parameter = macro_fl_execute_parameter_t_initialize(execute_set->parameter.option, execute_set->parameter.wait, process->rule.has & controller_rule_has_environment_d ? execute_set->parameter.environment : 0, execute_set->parameter.signals, &f_string_empty_s); - status = fll_execute_program(*main->default_program_script, simulated_arguments, &simulated_parameter, &execute_set->as, (void *) &result); + status = fll_execute_program(*main->default_engine, simulated_arguments, &simulated_parameter, &execute_set->as, (void *) &result); } } else { @@ -1622,7 +1622,7 @@ extern "C" { const f_string_statics_t simulated_arguments = f_string_statics_t_initialize; fl_execute_parameter_t simulated_parameter = macro_fl_execute_parameter_t_initialize(execute_set->parameter.option, execute_set->parameter.wait, process->rule.has & controller_rule_has_environment_d ? execute_set->parameter.environment : 0, execute_set->parameter.signals, &f_string_empty_s); - status = fll_execute_program(*main->default_program_script, simulated_arguments, &simulated_parameter, &execute_set->as, (void *) &result); + status = fll_execute_program(*main->default_engine, simulated_arguments, &simulated_parameter, &execute_set->as, (void *) &result); } } else { @@ -3496,9 +3496,9 @@ extern "C" { macro_f_time_spec_t_clear(rule->timestamp); rule->alias.used = 0; + rule->engine.used = 0; rule->name.used = 0; rule->path.used = 0; - rule->script.used = 0; rule->define.used = 0; rule->parameter.used = 0; @@ -3817,6 +3817,9 @@ extern "C" { else if (fl_string_dynamic_compare(controller_define_s, cache->action.name_item) == F_equal_to) { type = controller_rule_setting_type_define_e; } + else if (fl_string_dynamic_compare(controller_engine_s, cache->action.name_item) == F_equal_to) { + type = controller_rule_setting_type_engine_e; + } else if (fl_string_dynamic_compare(controller_environment_s, cache->action.name_item) == F_equal_to) { type = controller_rule_setting_type_environment_e; empty_disallow = F_false; @@ -3845,9 +3848,6 @@ extern "C" { else if (fl_string_dynamic_compare(controller_scheduler_s, cache->action.name_item) == F_equal_to) { type = controller_rule_setting_type_scheduler_e; } - else if (fl_string_dynamic_compare(controller_script_s, cache->action.name_item) == F_equal_to) { - type = controller_rule_setting_type_script_e; - } else if (fl_string_dynamic_compare(controller_timeout_s, cache->action.name_item) == F_equal_to) { type = controller_rule_setting_type_timeout_e; } @@ -4410,7 +4410,7 @@ extern "C" { continue; } - if (type == controller_rule_setting_type_name_e || type == controller_rule_setting_type_path_e || type == controller_rule_setting_type_script_e) { + if (type == controller_rule_setting_type_name_e || type == controller_rule_setting_type_path_e || type == controller_rule_setting_type_engine_e) { if (type == controller_rule_setting_type_name_e) { setting_value = &rule->name; @@ -4418,8 +4418,8 @@ extern "C" { else if (type == controller_rule_setting_type_path_e) { setting_value = &rule->path; } - else if (type == controller_rule_setting_type_script_e) { - setting_value = &rule->script; + else if (type == controller_rule_setting_type_engine_e) { + setting_value = &rule->engine; } if (setting_value->used || cache->content_actions.array[i].used != 1) { @@ -4432,7 +4432,7 @@ extern "C" { continue; } - if (type == controller_rule_setting_type_name_e || type == controller_rule_setting_type_script_e) { + if (type == controller_rule_setting_type_name_e || type == controller_rule_setting_type_engine_e) { status = fl_string_dynamic_partial_rip_nulless(cache->buffer_item, cache->content_actions.array[i].array[0], setting_value); if (F_status_is_error(status)) { @@ -4505,7 +4505,7 @@ extern "C" { continue; } - controller_rule_setting_read_print_value(global, type == controller_rule_setting_type_name_e ? controller_name_s : controller_script_s, f_string_empty_s, *setting_value, 0); + controller_rule_setting_read_print_value(global, type == controller_rule_setting_type_name_e ? controller_name_s : controller_engine_s, f_string_empty_s, *setting_value, 0); } else if (type == controller_rule_setting_type_path_e) { status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[0], setting_value); @@ -5613,8 +5613,8 @@ extern "C" { f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); - // Script. - fl_print_format(" %[%r%] %Q%r", main->output.to.stream, main->context.set.important, controller_script_s, main->context.set.important, rule.script, f_string_eol_s); + // Engine. + fl_print_format(" %[%r%] %Q%r", main->output.to.stream, main->context.set.important, controller_engine_s, main->context.set.important, rule.engine, f_string_eol_s); // User. fl_print_format(" %[%r%]", main->output.to.stream, main->context.set.important, controller_user_s, main->context.set.important); diff --git a/level_3/controller/c/rule/private-rule_print.c b/level_3/controller/c/rule/private-rule_print.c index a9287d0..543933f 100644 --- a/level_3/controller/c/rule/private-rule_print.c +++ b/level_3/controller/c/rule/private-rule_print.c @@ -85,7 +85,7 @@ extern "C" { controller_lock_print(print->to, (controller_thread_t *) process->main_thread); - fl_print_format("%r%[%QThe %r '%]", print->to.stream, f_string_eol_s, print->context, print->prefix, script_is ? controller_script_s : controller_program_s, print->context); + fl_print_format("%r%[%QThe %r '%]", print->to.stream, f_string_eol_s, print->context, print->prefix, script_is ? controller_engine_s : controller_program_s, print->context); fl_print_format("%[%Q%]", print->to.stream, print->notable, name, print->notable); if (status == F_control_group || status == F_limit || status == F_processor || status == F_schedule) { diff --git a/level_3/controller/data/build/defines b/level_3/controller/data/build/defines index 1555c43..63c654f 100644 --- a/level_3/controller/data/build/defines +++ b/level_3/controller/data/build/defines @@ -3,8 +3,8 @@ _di_libcap_ Disable libcap support, allow for compiling and linking without libcap (-lcap). _libcap_legacy_only_ Disable functionality provided by later versions of libcap (2.43 and later). _controller_as_init_ Build the program to run as if it were "init" by default, including displaying the program name as "Init Program" or "Init". This changes the main.c file only, leaving the library shareable between both "controller" and "init". -_override_controller_default_program_script_ Provide a custom script name string to execute (such as php). -_override_controller_default_program_script_length_ The number of bytes representing the string in _override_controller_default_program_script_ (not including the terminating NULL). +_override_controller_default_engine_ Provide a custom scripting engine name string to execute (such as php). +_override_controller_default_engine_length_ The number of bytes representing the string in _override_controller_default_engine_ (not including the terminating NULL). _override_controller_path_pid_ Use this as the default custom directory path representing the location of the controller program pid. _override_controller_path_pid_init_ Provide a custom init path for the pid file rather than the default. _override_controller_path_pid_init_length_ The number of bytes representing the string in _override_controller_path_pid_init_ (not including the terminating NULL). diff --git a/level_3/controller/data/settings/example/rules/environment/default.rule b/level_3/controller/data/settings/example/rules/environment/default.rule index 642e3e7..9b21b7a 100644 --- a/level_3/controller/data/settings/example/rules/environment/default.rule +++ b/level_3/controller/data/settings/example/rules/environment/default.rule @@ -2,7 +2,7 @@ setting: name "Environment default" - script bash + engine bash script: start { diff --git a/level_3/controller/data/settings/example/rules/environment/empty.rule b/level_3/controller/data/settings/example/rules/environment/empty.rule index c1dba2e..7305fa8 100644 --- a/level_3/controller/data/settings/example/rules/environment/empty.rule +++ b/level_3/controller/data/settings/example/rules/environment/empty.rule @@ -3,7 +3,7 @@ setting: name "Environment set to nothing" environment - script bash + engine bash script: start { diff --git a/level_3/controller/data/settings/example/rules/environment/exported.rule b/level_3/controller/data/settings/example/rules/environment/exported.rule index ede7d2d..66e5183 100644 --- a/level_3/controller/data/settings/example/rules/environment/exported.rule +++ b/level_3/controller/data/settings/example/rules/environment/exported.rule @@ -3,7 +3,7 @@ setting: name "Environment with PATH" environment PATH - script bash + engine bash script: start { diff --git a/level_3/controller/data/settings/example/rules/environment/exporting.rule b/level_3/controller/data/settings/example/rules/environment/exporting.rule index 4353948..d02cf22 100644 --- a/level_3/controller/data/settings/example/rules/environment/exporting.rule +++ b/level_3/controller/data/settings/example/rules/environment/exporting.rule @@ -3,7 +3,7 @@ setting: name "Environment with PATH" environment PATH custom_variable - script bash + engine bash script: start { diff --git a/level_3/controller/data/settings/example/rules/maintenance/boom.rule b/level_3/controller/data/settings/example/rules/maintenance/boom.rule index 97b6fba..170a27b 100644 --- a/level_3/controller/data/settings/example/rules/maintenance/boom.rule +++ b/level_3/controller/data/settings/example/rules/maintenance/boom.rule @@ -2,7 +2,7 @@ setting: name "Explosion!" - script sh + engine sh script: start { diff --git a/level_3/controller/data/settings/example/rules/script/php.rule b/level_3/controller/data/settings/example/rules/script/php.rule index bf6c405..9b07be1 100644 --- a/level_3/controller/data/settings/example/rules/script/php.rule +++ b/level_3/controller/data/settings/example/rules/script/php.rule @@ -3,7 +3,7 @@ setting: name "PHP script" environment PATH - script php + engine php script: start { diff --git a/level_3/controller/data/settings/example/rules/script/python.rule b/level_3/controller/data/settings/example/rules/script/python.rule index 57fabb2..6e6a22c 100644 --- a/level_3/controller/data/settings/example/rules/script/python.rule +++ b/level_3/controller/data/settings/example/rules/script/python.rule @@ -3,7 +3,7 @@ setting: name "Python (Version 3.X) script" environment PATH - script python3 + engine python3 script: start { diff --git a/level_3/controller/data/settings/example/rules/script/require_me.rule b/level_3/controller/data/settings/example/rules/script/require_me.rule index 2cc1cc8..afb8106 100644 --- a/level_3/controller/data/settings/example/rules/script/require_me.rule +++ b/level_3/controller/data/settings/example/rules/script/require_me.rule @@ -3,7 +3,7 @@ setting: name "Example script for needs, wants, and wishes." environment PATH - script sh + engine sh script: start { diff --git a/level_3/controller/data/settings/example/rules/script/succeed.rule b/level_3/controller/data/settings/example/rules/script/succeed.rule index be066b2..5c88fc3 100644 --- a/level_3/controller/data/settings/example/rules/script/succeed.rule +++ b/level_3/controller/data/settings/example/rules/script/succeed.rule @@ -3,7 +3,7 @@ setting: name "Script #1" environment PATH - script sh + engine sh script: start { diff --git a/level_3/controller/documents/rule.txt b/level_3/controller/documents/rule.txt index 9d4c53c..4c6040d 100644 --- a/level_3/controller/documents/rule.txt +++ b/level_3/controller/documents/rule.txt @@ -16,6 +16,7 @@ Rule Documentation: - "capability": Define a set of capabilities in which to use, using the capability "text" format (such as "= cap_chown+ep"). - "cgroup": Define a cgroup (control group) in which everything within this rule executes under. - "define": A single environment variable name and its associated value that is automatically exposed to processes executed within this rule. + - "engine": An executable name of a script, such as "bash", to use for the "script" Rule Type (which likely defaults to "bash" if not specified). - "environment": A set of environment variables to expose to the processes executed within this rule (PATH is always exposed). - "group": A set of group names or IDs to execute as with the first group being the primary group and all remaining being supplementary groups. - "limit": Define a resource limit to use (multiple limits may be specified, but only once for each type). @@ -24,7 +25,6 @@ Rule Documentation: - "on": Define a Rule Action in which a specified dependency is needed, wanted, or wished for. - "parameter": An IKI name and its associated value for use in this rule file. - "path": A single Content used to set a custom PATH environment variable value. - - "script": An executable name of a script, such as "bash", to use for the "script" Rule Type (which likely defaults to "bash" if not specified). - "scheduler": A valid name of a scheduler to use followed by an optional priority number. - "timeout": A set of timeouts to wait for in which to perform a set action or to consider failure. - "user": A single user name or ID to execute as. @@ -46,6 +46,10 @@ Rule Documentation: All environment variables, including those defined using this, must be in the "environment" list to be exported to the executed process. Environment variables added here that are not added to the environment are still exposed as an IKI variable. + - In the case of "engine"\: + This engine is used for both "script" and "utility" Rule Types. + The program that engine refers to must accept a standard input pipe to be supported. + - In the case of "group" and "user"\: Only users and groups that the user the controller program is being run as is allowed to use may be used. @@ -99,7 +103,7 @@ Rule Documentation: The "service" Rule Type provides a "command" accompanied with a PID file (Process Identifier file). - The "script" Rule Type provides a series of lines to be executed by a (Bash) script. + The "script" Rule Type provides a series of lines to be executed by some engine, such as GNU Bash. This "script" operates in the foreground, but individual things done within the script may operate in foreground or background. The last return state is treated as an error, so be sure to finish the script with a return code of 0 to designate no error and any other whole number, such a 1, to designate an error. Therefore passing "exit 1" would return as an error and passing "exit 0" would return as a success. diff --git a/level_3/controller/specifications/rule.txt b/level_3/controller/specifications/rule.txt index 3de527d..b4b52d7 100644 --- a/level_3/controller/specifications/rule.txt +++ b/level_3/controller/specifications/rule.txt @@ -36,6 +36,7 @@ Rule Specification: - "capability": One Content representing capabilities. - "cgroup": Two or more Content, the first Content being either "existing" or "new" and the remaining representing a valid cgroup (control group) name, must have at least 1 graph character (non white space printing character) (leading and trailing white space are trimmed off). - "define": Two Content, the first Content must be a case-sensitive valid environment variable name (alpha-numeric or underscore, but no leading digits). + - "engine": One Content representing a valid program name or path (such as "bash" or "/bin/bash"). - "environment": Zero or more Content, each must be a case-sensitive valid environment variable name (alpha-numeric or underscore, but no leading digits). - "group": One or more Content representing group names or group ids. - "limit": Three Content, with the first representing a valid resource type and the second and third being a valid resource limit number (positive whole number or 0). @@ -45,7 +46,6 @@ Rule Specification: - "parameter": Two Content, the first Content must be a case-sensitive valid IKI name and the second being an IKI value. - "path": One Content representing a valid PATH environment string (such as "/bin:/sbin:/usr/bin"). - "scheduler": One or Two Content representing a scheduler name and the optional numeric priority (Any whole number inclusively between 0 and 99). - - "script": One Content representing a valid program name or path (such as "bash" or "/bin/bash"). - "user": One Content representing a user name or user id. The "command" and "script" Rule Types allow the following the FSS-0001 (Extended)\: