path: root/src/ctl.c
AgeCommit message (Collapse)AuthorFiles
10 daysUpdate copyright yearsHEADmasterSergey Poznyakoff1
2020-12-07New API endpoint /alive. Improve documentation.Sergey Poznyakoff1
* doc/ Add ctl.texi * doc/ctl.texi: New file. * doc/pies.texi: Add anchors for ctl.texi * src/ctl.c (json_error_reply_create): Set status depending on the HTTP response code. Use "message", instead of "error_message". New endpoint: /alive * src/inetd.c: Use grecs_getline instead of getline. * src/sysvinit.c: Likewise. * src/piesctl.c: Inspect "message", instead of "error_message".
2020-12-04Rewrite stdout/stderr redirectionSergey Poznyakoff1
Instead of spawning a subprocess for each redirection, read the output directly from pipe and send it to syslog using an asynchronous syslog implementation. * src/syslog.c: New file. * src/pies_syslog.h: New file. * src/ Add syslog.c and pies_syslog.h * src/comp.c (component_create): Use pies_log_facility. * src/ctl.c (auth_prog) (prog_serialize): Remove TYPE_REDIRECTOR case * src/diag.c (syslog_printer): Use pies_vsyslog. (syslog_open): Use pies_syslog_open. (syslog_close): Use pies_syslog_close. (diag_setup): Use pies_syslog_open. * src/pies.c (log_facility, log_tag): Remove globals. Use pies_log_facility and pies_log_tag instead. New configuration statement * src/pies.h: Include pies_syslog.h (register_socket,register_program_socket): Additional argument: free_data. * src/prog.h (TYPE_REDIRECTOR): Remove. (prog.v.p.redir): Change data type. (prog.v.r): Remove. * src/progman.c (prog_tag) (destroy_prog) (progman_cleanup): Remove TYPE_REDIRECTOR case (prog_stop_redirectors): Deregister fds (redir_tag,register_redir) (update_redir): Remove. (open_redirector): Rewrite. Set up direct reader from the stream, instead of spawning a subprocess. (prog_start): Change open_redirector actual arguments. * src/socket.c (sockinst): New member: free_data. (register_socket): Initialize the free_data member. (register_program_socket): Likewise.
2020-12-02Fix reporting of the argv over the control interface (improves c0f4c3b99b)Sergey Poznyakoff1
2020-10-17Update copyright yearsSergey Poznyakoff1
2019-06-24Enable/disable SystemV init code at compile timeSergey Poznyakoff1
* New option --enable-sysvinit. Disable the init code if RUN_LVL is not available. (PIES_SYSVINIT_ENABLED): New configuration define. (PIES_COND_SYSVINIT): New condition Print configuration settings summary. * src/pies.h (is_sysvinit): Check for PIES_SYSVINIT_ENABLED. (SYSVINIT_ACTIVE): New macro. * grecs: Upgrade. * src/ Conditionally link sysvinit-related code. * src/cmdline.opt: Disable the --telinit option if sysvinit support is not available. (parse_options): Use SYSVINIT_ACTIVE in the conditional. * src/comp.c (component_verify): Check if component definition is allowed by the current state of the sysvinit support. * src/ctl.c: Disable the /runlevel entry point if sysvinit support is not compiled. * src/diag.c (stderr_open): Make sure sysvinit-related code is not compiled if the sysvinit support is not available. * src/pies.c (config_syntax_tab): Add entry for CONF_INITTAB only if sysvinit support is available. (_cb_initdefault,_cb_runlevels): Remove. Use cb_initdefault and cb_runlevels instead. (component_keywords): Disable runlevels without sysvinit support. (pies_keywords): Same for initdefault. Use SYSVINIT_ACTIVE to suppress compilation of sysvinit code without sysvinit support. * src/progman.c: Use SYSVINIT_ACTIVE to suppress compilation of sysvinit code without sysvinit support. * src/sysvinit.c (cb_initdefault,cb_runlevels): New functions.
2019-05-24Don't remove finished startup components. Just mark them with status_finished.Sergey Poznyakoff1
* src/ctl.c (pies_comp_mode_str): Add pies_comp_startup and pies_comp_shutdown. * src/piesctl.c (mode_trans): Likewise. * src/progman.c (progman_startup_phase): Test the status of pies_comp_startup components. (progman_waiting_p): Test status instead of pid>0 to select running components. (progman_cleanup): Set status of the finished startup component to status_finished, instead of removing it. * src/comp.c (loaded): Remove unused variable. (component_config_commit): Remove special handling for pies_comp_startup.
2019-05-23Update copyright yearsSergey Poznyakoff1
2019-05-20Upgrade grecsSergey Poznyakoff1
2017-01-02Happy GNU YearSergey Poznyakoff1
2016-04-07Remove duplicate includesSergey Poznyakoff1
2016-02-28Synchronize changes in runlevel with configuration reloadsSergey Poznyakoff1
State transition algorithm used this far could cause spurious component wakeups in some cases. Consider the following scenario: being in runlevel N, the configuration is changed so that a component X is added at runlevel N. Then a change to runlevel N+1 is initiated. What happens then is that X is woken up (still being in runlevel N) and terminated shortly afterwards, upon entering runlevel N+1. To avoid this, configuration must be reloaded after runlevel changes. * src/ctl.c (res_runlevel): Don't initiate ACTION_RELOAD after setting the runlevel. * src/pies.c (main): Begin main event loop with call to pies_pause. * src/pies.h (pies_set_hook): New proto. (inittrans): Remove proto. * src/socket.c (pies_set_hook): New function. (pies_pause): Call pies_pause_hook if defined. * src/sysvinit.c (inittrans): Change to static. If transition was initiated by user (e.g. by invoking telinit), schedule ACTION_RELOAD. (sysvinit_begin): Set inittrans as pies_hook
2016-02-25Implement "telinit environ" ctl commandSergey Poznyakoff1
* src/ctl.c: New endpoint "environ" * src/pies.h (sysvinit_envlocate) (sysvinit_envdelete) (sysvinit_envupdate): New protos. * src/piesctl.c: New subcommand "telinit environ". * src/sysvinit.c (sysvinit_envlocate) (sysvinit_envdelete) (sysvinit_envupdate): New functions. (sysvinit_begin): Create allocated copies of instance and pies_master_argv to avoid them being rewritten by calls to mf_proctitle_format
2016-02-24Improve parsing and handling of stop, start, and restart ctl commands.Sergey Poznyakoff1
* src/ctl.c (pcond_active): New type. (pcond_eval): Handle pcond_active. (pcond_conv): New op: active. (pcond_conv_find): Skip array elements with NULL term value. (object_to_cond): Permit empty argument if no handler function is defined. (fun_stop): Work on all prog types. (fun_start): Work only on components. (fun_restart): Work only on running components. * src/piesctl.c (cmdline_parser_state): New member: command. (pcond_parse_unary): Handle "active" keyword. (parse_condition): Change signature. (parse_condition_to_uri): Likewise. (default_cond): New function, (com_stop, com_start, com_restart): If no arguments supplied, assume default condition "type component". (ctlcom_t): Change signature. All uses changed. (main): Pass a pointer to cmdline_parser_state to the command handler.
2016-02-24Changes in prog structureSergey Poznyakoff1
* src/prog.h (prog): Remove .facility. Use facility from the component. (active,wait,stop): Move from union into the main struct. All uses changed.
2016-02-24Remove spurious informational message on startupSergey Poznyakoff1
2016-02-23BugfixesSergey Poznyakoff1
* lib/addrfmt.c: Include limits.h * src/ctl.c (fun_stop,fun_start): Ignore non-component progs. * src/pies.c (request_restart_components): Fix piesctl invocation. * src/pies.h (PIES_CHLD_RESCHEDULE_ALARM): New flag. (progman_wait_until): Remove. (progman_recompute_alarm): New proto. * src/progman.c (recompute_alarm): Remove. All uses raise PIES_CHLD_RESCHEDULE_ALARM instead. (progman_wake_sleeping): Handle status_stopping components independently on their activity flag. (prog_stop_all, progman_wait_until): Remove. (progman_stop): Rewrite using mark+sweep approach.
2016-02-23Improve loggingSergey Poznyakoff1
* po/ Add missing source files. * grecs: Upgrade. * src/diag.c (pies_diag_printer): New function. (logfuncall): New function. * src/pies.h: Add new prototypes. * src/pies.c (main): Initialize grecs_print_diag_fun * src/acl.c: Uniformly use double-quotes in messages. Use logfuncall where applicable. * src/comp.c: Likewise. * src/ctl.c: Likewise. * src/inetd-bi.c: Likewise. * src/inetd.c: Likewise. * src/limits.c: Likewise. * src/piesctl.c: Likewise. * src/progman.c: Likewise. * src/socket.c: Likewise. * src/sysvinit.c: Likewise.
2016-02-21Fix memory leaksSergey Poznyakoff1
2016-02-20Improve control interfaceSergey Poznyakoff1
This commit implements the following operations on the new /conf endpoints: GET /conf/runtime - List configuration PUT /conf/runtime - Reload configuration POST /conf/runtime - Post new configuration GET /conf/files - List configuration files DELETE /conf/files - Delete some or all configuration files from the list POST /conf/files - Install new configuration file Piesctl supports the following new commands: piesctl config reload piesctl config file clear piesctl config file add SYNTAX NAME piesctl config file del[ete] NAME [NAME...] piesctl config file list * src/ctl.c (res_conf): New function. (restab): New endpoint /conf * src/pies.c (config_file_add): Set free_entry. (config_file_remove, config_file_remove_all) (config_file_list_serialize): New functions. (pies_config_parse): Bail out if tree processing fails. (pies_reload): Remove unused function. (main): Redo ACTION_RELOAD handling. Handle ACTION_COMMIT. * src/pies.h (ACTION_COMMIT): New action. (config_file_remove, config_file_remove_all) (config_file_list_serialize) (pies_read_config, progman_gc): New protos. * src/piesctl.c (cmdline_parser_state): New struct (next_token, peek_token): Take ptr to cmdline_parser_state as argument. (parse_error, require_token, assert_eol) (piesctl_format): New functions. (parse_condition_to_uri): Rewrite using piesctl_format. New subcommand: config. Improve help output.
2016-02-18Fix activation/deactivation of network listeners.Sergey Poznyakoff1
* src/ctl.c (prog_active): New function. (prog_serialize): Use prog_active to report prog's activity state. For listener components, return also their service and tcpmux master names, if applicable. (fun_stop): Stop listeners as well. (fun_start): Start listeners. (ctlio_end): Don't close fd: this is done by deregister_socket * src/inetd-bi.c (tcpmux_help): Don't list inactive components. * src/prog.h (prog_activate_listener) (prog_deactivate_listener): New protos. * src/progman.c (prog_lookup_by_tag) (prog_lookup_by_service): Remove. (progman_cleanup): Fix coredump (premature free). (progman_stop_component): If component is a listener, deactivate it. (prog_activate_listener) (prog_deactivate_listener): New functions. * src/socket.c (delete_sockinst): Close the socket descriptor. * src/sysvinit.c (sysvinit_fifo_handler, create_fifo): Don't close fd, leave that to deregister_socket.
2016-02-16Associate program's activity flag with prog, instead of with component.Sergey Poznyakoff1
The CF_DISABLED flag is still retained to indicate that the component is disabled administratively. * src/prog.h (prog.v.p) <active>: New member. (IS_ACTIVE_COMPONENT): Use active flag. * src/comp.c (component_finish): Don't modify component flags. * src/ctl.c (prog_serialize): Replace attribute "disabled" with "active". (fun_stop): Set prog-> * src/pies.c (main): Use pies_master_argv to check whether program name is absolute. * src/piesctl.c (print_comp): Check "active" attribute. * src/progman.c (register_prog0): Set prog-> (progman_create_sockets): Remove components if their socket cannot be opened. (progman_lookup_tcpmux, prog_open_socket) (prog_start, progman_start) (prog_start_prerequisites, react): Operate on prog-> to test/change prog's activity state. * src/sysvinit.c (enablecomp, runlevel_setup_prog): Operate on prog-> to test/change prog's activity state. (demand_prog, IS_RUNNING_DISABLED_PROG): Likewise.
2016-02-13Stop disabled components when switching runlevels.Sergey Poznyakoff1
* src/prog.h (status_enabled, status_disabled): Remove. (status_stopped, status_running): New modes. All uses updated. * src/comp.c (component_finish): Disable ondemand component by default. * src/ctl.c (json_object_set_bool): New function. (pies_status_str): Update. (prog_serialize): Set "disabled" attribute. (fun_stop, fun_start): Use CF_DISABLED flag. (res_runlevel): Schedule ACTION_RELOAD. * src/pies.h (json_object_set_bool): New proto. * src/piesctl.c (status_trans): Reflect changes in modes. (print_comp): Check the "disabled" attribute. * src/progman.c (register_prog0) (prog_open_socket,prog_start,prog_stop) (progman_wake_sleeping) (prog_start_prerequisites) (react, progman_cleanup) (progman_stop_component): Update. (no_children_left): Fix. * src/sysvinit.c (enablecomp): Make CF_DISABLED flag persist for ondemand components. (runlevel_setup_prog): Use CF_DISABLED flag. (inittrans): Stop inactivated processes. * doc/pies.texi: Update.
2016-02-13Implement on-demaind components; implement control socket telinit interface.Sergey Poznyakoff1
* src/pies.h: Include json.h (sysvinit_report, sysvinit_set_runlevel) (json_object_set_string, json_object_set_number): New protos. * src/ctl.c (ctlio_resource)<predicate>: New member. (restab): New endpoint: runlevel. Available only if run as pid 1. (find_resource): If predicate is not NULL, call it to confirm that the endpoint is available. * src/piesctl.c: New subcommand "telinit". * src/sysvinit.c (sysvinit_set_runlevel): New function. (sysvinit_fifo_handler): Implement on-demaind components.
2016-02-12Improve progman API (progman_foreach and progman_stop_component).Sergey Poznyakoff1
* src/progman.c (progman_foreach): Allow filter to remove its prog argument from the list. Return integer (result of the call to filter, that returned non-zero). All uses changed. (progman_running_count): Remove. (progman_stop_component): Take a pointer to pointer. Pass it to destroy_prog when needed. All uses changed. * src/comp.c (prog_is_leftover): New function. (cb_terminate_prog): Use prog_is_leftover. Don't raise CF_DISABLED flag, as prog will have been destroyed by progman_stop_component. (cb_kill_prog): Use prog_is_leftover. * src/ctl.c (fun_stop): Check if prog still exists after the call to progman_stop_component. * src/pies.h (progman_running_count): Removed. * src/prog.h (progman_foreach): Return int. (progman_stop_component): Change signature.
2016-01-31Support sysvinit ondemand components.Sergey Poznyakoff1
* src/ctl.c (fun_start): Handle status_finished same as status_sleeping (for restarting ondemand components). * src/progman.c: Respawn ondemand components. * src/sysvinit.c (enablecomp): Handle pies_comp_ondemand. (sysvinit_demand): New function. (sysvinit_fifo_handler): Handle ondemand runlevels. (inittab_parse): Support "off" fields. Convert runlevels to upper case.
2016-01-31Fix runlevel switching; handle powerfail commands.Sergey Poznyakoff1
* src/ctl.c (prog_serialize): List runlevels. * src/pies.c (main): Set got_alarm after reloading configuration. Handle ACTION_POWER. * src/pies.h (ACTION_POWER): New constant. (progman_running_p): Rename to progman_waiting_p. All uses changed. (sysvinit_power): New proto. (POWER_STAT_FILE): New define. (POWER_STAT_FAIL,POWER_STAT_LOW,POWER_STAT_OK): New constants. * src/prog.h (prog) <idx>: Remove. (prog) <wait>: New member. * src/progman.c (prog_lookup_by_idx): Remove. (progman_waiting_p): Return 1 only if there is at least one prog with v.p.wait set. (prog_start): Initialize v.p.wait for sysvinit components. (progman_start): Don't do anything if waiting for components from the previous runlevel. (progman_wake_sleeping): Likewise. (progman_cleanup): Assume expect_term if waiting for components from the previous runlevel. Clear v.p.wait on exited progs. * src/sysvinit.c (sysvinit_fifo_handler): Don't call progman_stop when handling runlevel changes. Handle INIT_CMD_POWERFAIL, INIT_CMD_POWERFAILNOW, and INIT_CMD_POWEROK. (sysvinit_sigtrans): Handle SIGPWR. (is_comp_wait): Rewrite. (power_stat_file): New variable. (sysvinit_power): New function.
2016-01-21Cleanup: redo configuration file handling and dependency tracking.Sergey Poznyakoff1
Implement clean configuration reload on SIGHUP. Use SIGUSR1 to restart the program (previously initiated by SIGHUP). * src/ (pies_SOURCES): Add comp.c * src/comp.c: New file. * src/acl.c (pies_acl_free): Don't coredump on NULL arg. (_parse_from): Set cmp function for the sockaddr list. (_acl_common_section_parser): Set cmp function for the ACL (pies_acl_cmp): New function. * src/acl.h (pies_acl_cmp): New proto. * src/cmdline.opt: Remove option --dump-prereq. Add options --trace-prereq and --trace-depend. * src/ctl.c: Use prog_tag to access tag of struct prog. * src/depmap.c (depmap_clear) (depmap_clear_all): New functions. * src/inetd.c (inetd_conf_file): Don't register prog right away. This is done later in component_config_commit. (inetd_parse_conf): Rename to inetd_config_parse. * src/limits.c (limits_cmp): New function. * src/pies.c (config_file): Replace with struct config_syntax. (str_to_config_syntax): Return a pointer to struct config_syntax. (add_config): Rename to config_file_add. (config_file_add_type): New function. (return_code_keywords, create_action): Change handling of actions. (return_code_section_parser): Likewise. (component_verify, component_create) (component_free, component_finish): Move to comp.c (config_parse): Remove. (pies_config_parse): New function. (pies_read_config,pies_reload): New function. (pies_reload): Rename to request_reload. (pies_status): Rename to request_status. (pies_stop): Rename to request_stop. (main): Change configuration file handling. SIGHUP reloads configuration, instead of restarting the program. (default_sigv,sig_handler): Handle SIGUSR1. * src/pies.h (component): New members: prev, next, listidx, arridx, ref_count, prog. Remove act_head, act_tail, act_temp. Add new prototypes. * src/prog.h (prog): Remove tag and prereq. * src/progman.c (prog_tag): New function. (destroy_prog): Update component reference count. (register_redir): Likewise. (register_prog0): Take one argument. Update component reference count. (register_prog): Update comp->prog (prog_rebuild_prerequisites): Remove. (component_fixup_depend): Remove. (fixup_prerequisites,rebuild_prerequisites) (print_dep,progman_dump_prereq) (progman_dump_depmap,progman_build_depmap): Remove. (prog_start_prerequisites): Scan depmap to find prerequisites. (prog_stop_dependents): Likewise. (progman_wait): Remove. (progman_wait_until): New function. (progman_stop): Rewrite using progman_wait_until. (react): Rewrite using grecs_list * src/sysvinit.c: Use prog_tag when needed. * src/userprivs.c (pies_privs_cmp, pies_privs_free): New functions. * grecs: Update. * lib/safe_strcmp.c: New file. * lib/ Add safe_strcmp.c * lib/libpies.h (safe_strcmp): New proto.
2016-01-09Minor improvementsSergey Poznyakoff1
* src/ctl.c (ctl_open): Return immediately if control.url is null. (fun_start): Start sleeping component. * src/meta1lex.h: Removed. * src/pies.c (config_parse): Move creation of the default control.url to main.
2016-01-08Uniformly use grecs memory management functions.Sergey Poznyakoff1
* gnulib.modules: Remove unneded modules. * ident/ident.h: Remove xalloc.h, include errno.h * ident/ident.c: Use standard allocation functions instead of x* * ident/pam.c: Remove. * ident/provider.c: Remove. * ident/system.c: Remove. * src/meta.c: Remove. * src/ Remove meta.c * src/progman.c: Use grecs_* allocation functions instead of x*. (notify): Use wordsplit to expand variables within message. Rename variables: program-name to program_name; canonical-program-name to canonical_program_name. * doc/pies.texi: Update. * src/depmap.c: Use grecs_* allocation functions instead of x*. (depmap_end): New function. * src/diag.c (logmsg_vprintf): Use grecs_txtacc instead of obstack. * src/pies.h (depmap_end): New proto. Remove unused includes. * src/acl.c: Use grecs_* allocation functions instead of x*. * src/ctl.c: Likewise. * src/inetd.c: Likewise. * src/limits.c: Likewise. * src/meta1gram.y: Likewise. * src/meta1lex.l: Likewise. * src/pies.c: Likewise. * src/socket.c: Likewise. * src/sysvinit.c: Likewise. * src/userprivs.c: Likewise.
2016-01-08Enable control socket when run as init process.Sergey Poznyakoff1
* (DEFAULT_CONTROL_URL): Rename to DEFAULT_PIES_CONTROL_URL. Change default value. (DEFAULT_INIT_CONTROL_URL): New subst variable. * lib/libpies.h (pies_basic_url_create): New prototype. * lib/url.c (pies_basic_url_create): New function (renamed from pies_url_create). (pies_url_create): Expand variable references in the input string. * src/ (AM_CPPFLAGS): Pass DEFAULT_INIT_CONTROL_URL * src/ctl.c (pies_control_url) (ctl_open): Don't exit on errors, return -1 instead. * src/pies.c (default_control_url): New variable. (config_parse): Create default socket url. (pies_control_url): New macro (main): Set environment variable PIES_INSTANCE. Try to open control socket in init process mode as well. * src/pies.h (default_control_url): New extern. (ctl_open): Change prototype. (pies_control_url): Remove. * src/piesctl-cl.opt (parse_options): Set environment variable PIES_INSTANCE. * src/piesctl.c (parse_config): Use pies_url_create and DEFAULT_PIES_CONTROL_URL when falling back to the default socket.
2016-01-07BugfixesSergey Poznyakoff1
* bootstrap.conf (bootstrap_epilogue): Declare the package as a GNU one. * Require gettext 0.19 Remove useless conditional * src/ctl.c (fun_stop, fun_start): Check prog->v.p.status, not the CF_DISABLED flag.
2016-01-06Revert to pre-32a337f3 two endpoint systemSergey Poznyakoff1
2016-01-05control interface: pass JSON as query for GET, DELETE, and PUTSergey Poznyakoff1
2016-01-05Include argv in the output of ctl id command.Sergey Poznyakoff1
* ctl.c (res_instance): Include "argv" in the return json. Use pies_master_argv[0] to report binary path. * pies.c (pies_master_argv,pies_master_argc): New globals. (main): Initialize them. Refuse to restart unless argv[0] begins with a slash. * pies.h (pies_master_argv,pies_master_argc): New globals. * piesctl.c (com_id): Rewrite output formatting.
2016-01-05Minor changes.Sergey Poznyakoff1
* src/ctl.c (ctlio_authenticate): Configurable realm name. (ctlio_do_command): Check the Accept header. * src/inetd.c (inetd_conf_file): Change line_no type. * src/pies.c (control_keywords): New keyword: realm. * src/pies.h (control) <realm>: New member.
2016-01-05Insert missing _() markersSergey Poznyakoff1
2016-01-05Select components to operate upon using conditional expressionSergey Poznyakoff1
* grecs: Upgrade. * src/ctl.c (restab): Split /programs in two endpoints. (eval_env): New members allowed_state, fun, total_count, success_count, and noperm_count. (pcond_type): pcond_and and pcond_or can take arbitrary number of arguments. All uses updated. (selector): Rewrite. * src/piesctl.c: All commands that operate on components take conditional expression as argument. (pcond_parse_and) (pcond_parse_or): Optimize consecutive operations.
2016-01-04Redo URI handling.Sergey Poznyakoff1
* src/ctl.c (res_instance) (res_programs): Take partial URI as argument (instead of full URI split on path delimiter) (ctlio_resource): New member uri_len; Change signature of handler. (find_resource): Compare URI prefix. (ctlio_do_command): Redo URI parsing. Improve error checking. * src/piesctl.c (shttp_print_error): New function. (shttp_fatal): Print error on 404 and 409 responses.
2016-01-04Minor fixesSergey Poznyakoff1
* src/ctl.c: Start textual descriptions with capital letters. * src/piesctl-cl.opt: Fix typos. * src/piesctl.c (shttp_process): Fix error handling. (shttp_fatal): Select exit code depending on the HTTP response code.
2016-01-03Minor changesSergey Poznyakoff1
* Version 1.2.92 * src/ctl.c (ctlio_finalize_reply): Don't close connection on errors. * src/pies.h (PIES_PRINTFLIKE): New macro. (logmsg, logmsg_printf): Mark as printflike.
2016-01-02Switch to new control interface.Sergey Poznyakoff1
Old control options (--status, --restart-components) rewritten using piesctl. SIGUSR1 and SIGUSR2 no longer handled. * lib/arraymember.c (array_index): New function. * lib/libpies.h: Likewise. * src/cmdline.opt: Fix copyright years. * src/piesctl-cl.opt: Likewise. * src/ctl.c (ctlio_do_command): Implement restart. (pies_control_url): New function. (eval_env): rename json to result. New member cond. Restore pcond_ functions. (json_to_pcond): New function. (res_programs): Conditional selection of programs to list. Implement restart. * src/pies.c (ctlfile, statfile): Remove. (pies_keywords): Mark control-file and stat-file as inactive. (default_sigv): Remove SIGUSR1 and SIGUSR2 (pies_check_status): Don't send SIGUSR2. (stop_components): Remove. (request_restart_components): Rewrite as a wrapper. Call piesctl to do the job. (list_components): New function. * src/pies.h (ACTION_COMPRELOAD) (ACTION_DUMPSTATS): Remove. All callers changed. (progman_dump_stats): Remove. * src/piesctl.c (shttp_request_send): Don't initialize conn->req; the caller is responsible for that. (parse_condition, json_to_string) (parse_condition_to_uri): New functions. (com_list): Read conditional expression from the command line. (com_restart): Implement. * src/progman.c (progman_dump_stats): Remove.
2016-01-02piesctl: Implement all basic commands, except "restart"Sergey Poznyakoff1
2015-12-31Command-line control interface.Sergey Poznyakoff1
* (DEFAULT_CONTROL_URL): New subst variable. * grecs: Upgrade. * ident/pam.c (overwrite_and_free): Free ptr. * lib/ Add new sources. * src/addrfmt.c: Move to lib/addrfmt.c * lib/grecsasrt.c: New file. * lib/grecsasrt.h: New file. * lib/mkfilename.c: New file. * lib/netrc.c: New file. * lib/pp.c: New file. * lib/split3.c: New file. * src/url.c: Move from lib/url.c (pies_url_free_user, pies_url_free_passwd): New finctions. * lib/libpies.h (strsplit3): New proto. (pies_url_create, pies_url_destroy) (pies_url_get_arg, pies_url_copy) (pies_url_free_user, pies_url_free_passwd) (netrc_scan) (pp_add_option, pp_command_line, mkfilename) (sockaddr_to_str, sockaddr_to_astr): New protos * src/ (bin_PROGRAMS): New program: piesctl (pies_SOURCES): Remove addrfmt.c and url.c. (noinst_HEADERS, BUILT_SOURCES): Add piesctl-cl.h * src/cmdline.opt: Use pp_* function family to build preprocessor command line. * src/ctl.c (http_header_hash): Use case-insensitive hashing. (ctlio_finalize_reply): Don't close connection after sending 401 response. (input): Remove ws and wsflags. All uses changed. (input_append): Use strsplit3 to parse the request line. * src/pies.c: Use pp_* function family to build preprocessor command line. Move assert_, mkfilename and _cb+_url functions into libpies. * src/pies.h (pies_sockaddr_storage): Move to libpies.h * src/piesctl.c: New file. * src/piesctl-cl.opt: New file.
2015-12-25ctl: use numeric type for PIDS and wakeup time values.Sergey Poznyakoff1
2015-12-25REST control protocol.Sergey Poznyakoff1
* (GRECS_SETUP): Add json * gnulib.modules: Add base64. * grecs: Upgrade. * src/ctl.c: Rewrite as REST.
2015-12-19Bugfixes in init modeSergey Poznyakoff1
* src/ctl.c (ctl_open): Add missing return. * src/pies.c (config_parse): Return if tree is null. (main) [INIT_EMU]: Print more info. Override default init_fifo. Don't use syslog and control socket if running as init process. * src/pies.h (init_fifo): New extern. * src/progman.c (open_redirector): Return -1 if running as init process. (prog_start): Always initialize redir[]. * src/sysvinit.c (init_fifo): New variable. Use it instead if the INIT_FIFO macro. (inittrans): Call create_fifo once, when transiting from boot to normal state.
2015-12-17FixesSergey Poznyakoff1
* src/ctl.c: Make "id" command accessible only to administrators (cmd_id): Print PID. (ctlio_do_command): Reword 510 text. * src/pies.c (config_file): Remove "next" (conf_head, conf_tail): Remove. Use grecs_list instead. All uses changed.
2015-12-17Implement user privilegesSergey Poznyakoff1
* src/pies.h (component): New members: list_acl and adm_acl. (control): Removed id_acl. New members: adm_acl and usr_acl. * src/pies.c (component_keywords): New keywords list-acl and admin-acl. Removed identity-acl. * ident/ident.c (pies_identity_user_name): New function. * ident/identity.h (pies_identity_user_name): New proto. * src/ctl.c (CTL_USER_STATE,CTL_ADMIN_STATE): New states. (cmdtab): Mark administrative commands as valid in CTL_ADMIN_STATE (ctlio_create): Assume CTL_ADMIN_STATE in the absense of identity providers. (auth_data): New struct. (cmd_auth): Select appropriate state depending on the user permissions. (list_matches): New function. (eval_env): Keep the list of selected progs. (count_prog): Removed. (selector): New function. (cmd_list): Rewrite to take into account access rights. (cmd_start,cmd_stop) (cmd_restart): Only allowed for users with administrative privileges.
2015-12-16Implement authentication on control socket.Sergey Poznyakoff1
* (SUBDIRS): Add src. * Check for crypt.h and PAM Build ident/Makefile * grecs: Update. * ident/ New file. * ident/ident.c: New file. * ident/ident.h: New file. * ident/identity.h: New file. * ident/pam.c: New file. * ident/provider.c: New file. * ident/system.c: New file. * lib/ Add arraymember.c * lib/arraymember.c: New file. * lib/libpies.h (is_array_member): New proto. * src/ (LDADD): Add libident.a and @PAM_LIBS@ * src/acl.c (acl_entry): Remove groups. Add new members: names and name_match. (pies_acl_create): Deep copy the locus. Set free_entry function for the list. (pies_acl_free): Free locus. (_parse_from): Set free_entry function for the list. (_parse_group): Parse the "user" construct. (parse_acl_line): Deep copy the locus. Allow for null value. (acl_keywords): Update docstrings. (_acl_check): Rewrite identity checks. * src/acl.h (acl_input)<user,groups>: Remove. <identity>: New member. (pies_acl_free): New proto. * src/ctl.c (identity): New global. (cmdtab): New command: auth (ctlio) <addr,addrlen>: New members. (ctlio_create): Start from authenticated state only if no identity_providers are configured. (cmd_auth): New function. (cmd_help): Print only commands that are available in the current state. (ctl_accept): Initialize io->addr and io->addrlen. * src/inetd-bi.c: Change call to check_acl * src/pies.c: Include identity.h (control_keywords): New statement "identity-acl" (pies_keywords): New statement "identity-provider" (config_init): Register identity mechanisms. (config_parse): New function. (config_help): Print help on identity-provider statements. (main): Use config_parse to parse grecs-style configurations. * src/pies.h: Include identity.h (check_acl): Change argument list. All callers changed. (control): Remove acl. Add conn_acl and id_acl instead. * src/progman.c (check_acl): Change argument list. Take identity as the 3rd argument.

Return to:

Send suggestions and report system problems to the System administrator.