aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFiles
2019-06-02New configuration statement for manipulating the environment.Sergey Poznyakoff4
The "env" statement is now a compound statement. It can contain four substatements: "clear" to clear the environment, "keep" to retain certain variable while clearing it, "set" to set a variable, and "unset" to unset a variable or variables. Both "keep" and "unset" can take globbing pattern as their argument, in which case they affect all variable matching that pattern. The value part in the "set" statement is subject to variable expansion, e.g. set "MANPATH=$MANPATH${MANPATH:+:}/usr/local/man" The support for the old one-line syntax of "env" is retained for backward compatibility. This commit also fixes redirection to a file: new data are appended to the file, instead of overwriting it. * lib/Makefile.am: Add new files. * lib/envop.c: New file. * lib/envop.h: New file. * lib/wildmatch.c: New file. * src/comp.c (component_free): Update. * src/pies.c (argv_free): New function. (parse_legacy_env): New function. (_cb_env): Remove. (cb_env_section_parser): New function. (cb_env_keywords): New keywords for the "env" block statement: clear, keep, set, unset. (component_keywords): New compount statement: env. Old usage retained for backward compatibility. * src/pies.h: Include "envop.h" (component)<env>: Remove. <envop>: New field. * src/prog.h (prog)<env>: New field. * src/progman.c (redirect_to_file): Position to the end of file. (DEBUG_ENVIRON): Remove macro. (debug_environ): New function. (environ_setup): Remove. (prog_sockenv): Use environ_set to modify local copy of environment. (prog_start_prologue): Use environ_create + envop_exec to create and modify the environment. (prog_execute): Set environment to prog-local copy. * tests/.gitignore: Build envtest * tests/Makefile.am: Add new tests. * tests/testsuite.at: Add environment tests. * tests/envop.at: New file. * tests/envtest.c: New file. * tests/env.at: New file. * tests/redirect.at: Check first two lines of the output file.
2019-05-23Update copyright yearsSergey Poznyakoff15
2019-05-20Upgrade grecsSergey Poznyakoff1
2017-01-02Happy GNU YearSergey Poznyakoff15
2016-03-24BugfixSergey Poznyakoff1
* lib/split3.c: Return correct error code.
2016-02-24Minor stylistic changeSergey 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-01-31Update POTFILES.inSergey Poznyakoff1
2016-01-21Cleanup: redo configuration file handling and dependency tracking.Sergey Poznyakoff3
Implement clean configuration reload on SIGHUP. Use SIGUSR1 to restart the program (previously initiated by SIGHUP). * src/Makefile.am (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/Makefile.am: Add safe_strcmp.c * lib/libpies.h (safe_strcmp): New proto.
2016-01-08Enable control socket when run as init process.Sergey Poznyakoff2
* configure.ac (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/Makefile.am (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-08BugfixSergey Poznyakoff1
* lib/addrfmt.c (S_UN_NAME): Fix comparison. (sockaddr_to_str): Improve wording.
2016-01-02Switch to new control interface.Sergey Poznyakoff2
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.
2015-12-31Command-line control interface.Sergey Poznyakoff10
* configure.ac (DEFAULT_CONTROL_URL): New subst variable. * grecs: Upgrade. * ident/pam.c (overwrite_and_free): Free ptr. * lib/Makefile.am: 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/Makefile.am (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-16Minor fixes.Sergey Poznyakoff1
* grecs: Upgrade. * lib/parsetime.c: Fix senseless compiler warnings. * src/acl.c: Fix docstrings. * src/meta1gram.y (yyerror): Change argument * src/meta1lex.l: Add flex options * src/pies.h (meta1error): Change signature. * src/progman.c (prog_lookup_by_socket): Remove. * src/sysvinit.c (sysvinit_stop_filter): Remove.
2015-12-16Implement authentication on control socket.Sergey Poznyakoff3
* Makefile.am (SUBDIRS): Add src. * configure.ac: Check for crypt.h and PAM Build ident/Makefile * grecs: Update. * ident/Makefile.am: 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/Makefile.am: Add arraymember.c * lib/arraymember.c: New file. * lib/libpies.h (is_array_member): New proto. * src/Makefile.am (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.
2014-12-27Minor fixes.Sergey Poznyakoff1
* lib/proctitle.c (mf_proctitle_format): Check return from vasprintf instead of checking the return pointer. * src/inetd-bi.c: Check return values from write where reasonable. * src/progman.c (redirect_to_file): Check return from chown. (close_fds): Fix coredump (upper boundary was wrong). (open_redirector, progman_dump_stats): Check return values. * src/sysvinit.c (sysvinit_setenv): Remove unused variable. * src/userprivs.c (str_eq, str_dispose): Remove unused functions. * src/utmp.c: Check return values.
2013-01-06Update copyright years.Sergey Poznyakoff5
2013-01-04Initial support for running as init process.Sergey Poznyakoff1
* grecs: Upgrade. * lib/Makefile.am: Use AM_CPPFLAGS instead of INCLUDES. * src/Makefile.am: Likewise. * src/acl.c: Update grecs_keyword definitions. * src/inetd.c (inetd_conf_file): Bugfix. The ws structure could be free'd prior to initialization. * src/pies.c: Update grecs_keyword definitions. (init_process,initdefault,dfl_level): New globals. (modetab) <once>: New keyword. (component_keywords)<runlevels,initdefault>: New keywords. (main): Initial support for init(8) mode. * src/pies.h (pies_comp_mode) <pies_comp_exec_once>: New constant. (component)<runlevels>: New member. (init_process,console_device,initdefault): New externs. * src/progman.c (prog_status)<status_finished>: New status. (prog)<runlevels>: New member. (progman_running_p): New function. (prog_start): Special handling for init process mode. (progman_start): Likewise. Take into account runlevels. (progman_dump_stats): New flag 'f' for status_finished.
2011-10-23Switch to the latest Grecs.Sergey Poznyakoff1
* Makefile.am (ChangeLog): Use git2chg.awk to build it. * NEWS: Update. * bootstrap.conf (gnulib_modules): Grecs does not depend on gnulib any more. * configure.ac: Version 1.2.90. Define GRECS_HOST_PROJECT_INCLUDES, remove grecs Makefiles from AC_CONFIG_FILES: it is now done by GRECS_SETUP itself. * gnulib.modules (gitlog-to-changelog,argp): Remove. (configmake): New module. * grecs: Update to a52ab6c6. * lib/libpies.h: Remove redefinitions of _() and N_(). * src/Makefile.am: Update for the recent grecs. * src/acl.c: Rewrite using Grecs support for lists and symtabs. * src/acl.h: Likewise. * src/diag.c: Likewise. * src/inetd.c: Likewise. * src/meta1gram.y: Likewise. * src/meta1lex.h: Likewise. * src/meta1lex.l: Likewise. * src/pies.c: Likewise. * src/pies.h: Likewise. * src/progman.c: Likewise. * src/userprivs.c: Likewise.
2010-01-02Update copyright years.Sergey Poznyakoff5
Happy GNU Year!
2009-10-26Pies dubbed a GNU package. Update all files accordingly.Sergey Poznyakoff5
2009-10-12Fix make distcheck and check-docs.Sergey Poznyakoff3
* doc/Makefile.am: Fix `check-*' goals. * doc/pies.texi: Update and rearrange material. Document new configuration. * lib/Makefile.am (libpies_a_SOURCES): Remove nls.c * src/Makefile.am (EXTRA_DIST): Remove pies.rc, add pp-setup. (INCLUDES): Add $(top_builddir)/gnu * src/pies.c: Minor changes. * src/progman.c: Minor changes. * README-hacking: New file.
2009-10-12Do not require Mailutils. Provide missing functions.Sergey Poznyakoff8
* Makefile.am (ACLOCAL_AMFLAGS): Add grecs/am * bootstrap.conf: Skip po. Initialize submodule. * configure.ac: Mailutils no longer needed. (AC_CONFIG_FILES): Add new subdirs. * gnulib.modules: Add more modules. Arrange entries alphabetically. * lib/Makefile.am: Rename library to libpies. * lib/libpies.h (mf_privs) (switch_to_privs, get_user_groups) (mf_priv_setup, mf_epriv_setup): Move to src/pies.h (config_array_to_argv, config_array_to_string) (config_cb_timeout): Remove. (tokendef): New struct. (strtotok_len, strtotok_len_ci) (strtotok, strtotok_ci, toktostr): New prototypes. * lib/nls.c: Remove call to mu_init_nls. * src/acl.c: New file. * src/addrfmt.c: New file. * src/diag.c: New file. * src/meta.c: New file. * src/url.c: New file. * src/userprivs.c: New file. * src/acl.h: New file. * src/pp-setup: New file. * src/Makefile.am (pies_SOURCES): Add acl.c, addrfmt.c, diag.c, meta.c, url.c, userprivs.c. (noinst_HEADERS): Add acl.h. (inc_DATA): Add pp-setup. * src/limits.c, src/meta1gram.y, src/meta1lex.h, src/meta1lex.l, src/pies.c, src/pies.h, src/progman.c, src/socket.c, src/userprivs.c: Remove calls to functions from Mailutils.
2009-09-15Branch off from the Mailfromd project into a separate repository.Sergey Poznyakoff8

Return to:

Send suggestions and report system problems to the System administrator.