summaryrefslogtreecommitdiffstats
path: root/src/shared/conf-parser.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* conf-parser: introduce config_parse_in_addr_prefix()Yu Watanabe2024-10-111-0/+1
| | | | It is not used currently, but will be used later.
* conf-parser: introduce config_parse_in_addr_data()Yu Watanabe2024-09-181-0/+1
|
* conf-parser: introduce config_parse_uint32_invert_flag()Yu Watanabe2024-09-061-0/+1
| | | | | It is similar to config_parse_uint32_flag(), but drops the specified flag when true.
* conf-parser: introduce config section parser wrapperYu Watanabe2024-09-061-0/+19
| | | | It will be used later.
* conf-parser: use log_syntax_parse_error() and friends moreYu Watanabe2024-09-011-11/+11
| | | | | | This also makes all conf parsers defined in conf-parser.c return 1 on success, 0 on non-critical error. Also, use free_and_strdup_warn() where applicable.
* conf-parser: several cleanups for DEFINE_CONFIG_PARSE_ENUMV() macroYu Watanabe2024-09-011-18/+16
| | | | | | | | | - use GREEDY_REALLOC() and FOREACH_ARRAY(), - do not set an array with only terminating 'invalid' value. Note, this macro is only used by parsing NamePolicy= and AlternativeNamesPolicy= in .link files. and udevd correctly handles both an empty array and an array with only 'invalid'. Hence, this does not change any behavior.
* tree-wide: drop msg argument for DEFINE_CONFIG_PARSE() macro and friendsYu Watanabe2024-09-011-36/+22
| | | | | This makes the macros use log_syntax_parse_error(), hopefully which provides more informative log message in general, and reduces binary size.
* conf-parser: move config_parse_ip_protocol() from network/netdev/fou-tunnel.cYu Watanabe2024-08-241-0/+1
| | | | | The function is generic enough. Currently it is used at only one place. But it will be used at another place.
* conf-parser: introduce config_parse_uint32_flag()Yu Watanabe2024-08-241-0/+1
| | | | This is not used currently, but will be used later.
* conf-parser: return 1 on successYu Watanabe2024-08-241-6/+7
| | | | | | Typically, conf parsers will ignore most errors during parsing strings and return 0. Let's return 1 on success. Otherwise it is hard to reused these function in another conf parser.
* conf-parser: introduce log_section_full_errno() and friendsYu Watanabe2024-08-231-0/+37
|
* logind: implement maintenance timeLudwig Nussel2024-06-201-0/+1
| | | | | | | | | | | | | | | | | | | | | Update frameworks that work automatically in the background occasionally need to schedule reboots. Systemd-logind already provides a nice mechanism to schedule shutdowns, send notfications and block logins short before the time. Systemd has a framework for calendar events, so we may conveniently use logind to define a maintenance time for reboots. The existing ScheduleShutdown DBus method in logind expects a usec_t with an absolute time. Passing USEC_INFINITY as magic value now tells logind to take the time from the configured maintenance time if set. "shutdown -r" leverages that and uses the maintenance time automatically if configured. The one minute default is still used if nothing was specified. Similarly the new 'auto' setting for the --when parameter of systemctl uses the maintenance time if configured or a one minute timer like the shutdown command.
* conf-parser: move config_parse_timezone() to conf-parser.[ch]Yu Watanabe2024-04-191-0/+1
| | | | | Even though it is currently only used by networkd, the parser itself is quite generic. Let's move it to the shared library.
* various: use new config loader instead of config_parse_config_file()Zbigniew Jędrzejewski-Szmek2024-03-071-8/+19
| | | | | | | | | | | | | | | | | | | | | | | | | This means the main config file is loaded also from /run and /usr. We should load the main config file from all the places where we load drop-ins. I realize I had a giant blind spot: I always assumed that we load config files from /etc, /run, /usr/local/lib, /usr/lib. But it turns out that we only used those paths for drop-ins. For the main config file, we only looked in /etc. The docs actually partially described this behaviour, i.e. most SYNOPSIS sections and some parts of the text, but not others. This is strange, because 6495361c7d5e8bf640841d1292ef6cfe1ea244cf was completely bogus with the behaviour before this patch. We had a huge discussion before it was merged, and clearly nobody noticed this. Similarly, in the previous version of the current pull request, we had a long discussion about the appropriate order of directories, and apparently nobody noticed that there was no order, because only looked in one directory. So the blind spot seems to have been shared. Also, systemd-analyze cat-config behaved incorrectly, i.e. its behaviour matches the new behaviour. Possibly, in the future it'll make it easier to add support for --root.
* shared/conf-parser: add function which implements the standard config file setZbigniew Jędrzejewski-Szmek2024-03-071-0/+11
| | | | | Also allow config_parse_many() to be called for config files without sections. The test uses such a file.
* shared/conf-parser: use chase() in config_parse_many_files()Zbigniew Jędrzejewski-Szmek2024-03-071-1/+1
| | | | | | | | | | | | | | | The function was partially implementing chroot lookups. It would be given file names that were prefixed with the chroot, so it would mostly work. But if any of those files were symlinks, fopen() would do the wrong thing. Also we don't need locking. So give 'root' as the argument and use chase_and_fopen_unlocked() to get proper chroot-aware lookups. The only place where config_parse_many() is called with root is is repart.c. So this is a follow-up for e594a3b154bd06c535a934a1cc7231b1ef76df73 and 34f2fd5096cdb26ef57998740b1b876332d968fc.
* shared/conf-parser: collapse pkgdir and conf_file args into oneZbigniew Jędrzejewski-Szmek2024-03-071-13/+2
| | | | | | | | | | This essentially reverts 5656cdfeeabc16b5489f5ec7a0a36025a2ec1f23. I find it much easier to understand what is going on when the path-relative-to-the-search-path is passed in full, instead of being constructed from two parts, with one of the parts being implicit in some places. Also, we call 'systemd-analyze cat-config <path>' with <path> with the same meaning, so this makes the internal and external APIs more consistent.
* Merge pull request #30867 from dtardon/udev-conf-dropinsYu Watanabe2024-01-111-1/+12
|\ | | | | Allow dropins for udev.conf
| * conf-parser: generalize config_parse_config_file()David Tardon2024-01-111-1/+12
| |
* | conf-parser: expose config_section_{hash,compare}_func()Yu Watanabe2024-01-031-0/+4
|/ | | | They will be used in later commits.
* conf-parser: fix argument type of ConfigPerfItemLookupYu Watanabe2023-11-121-1/+1
| | | | Prompted by #29972.
* network: use a common helper to parse bounded rangesZbigniew Jędrzejewski-Szmek2023-09-221-0/+94
| | | | | | | | | | | | | | | | | | | This compresses repetetive code and makes it easier to add new options in networkd. The formatting of error messages becomes uniform. The error message always specifies the rvalue literally, instead of using a "descriptive name". This makes the message much easier to handle for the user. I opted to add just one parser, and wrap it with inline functions to proxy the type. This is less verbose than copying functions for each type separately, and the compiler should be able to get rid of the inline wrapper almost entirely. asserts are reordered to use the same order as the parameter list. This makes the code easier to read. No functional change intended, apart from the difference in error message formatting.
* conf-parser: introduce ordered_hashmap_by_section_find_unused_line()Yu Watanabe2023-09-081-2/+14
|
* conf-parser: check overflow in hashmap_find_free_section_line()Yu Watanabe2023-09-081-1/+4
| | | | | Also, this also renames the function, and makes it optionally takes a filename.
* conf-parser: modernize config_section_new()Yu Watanabe2023-09-081-1/+1
| | | | | - add assertions, - rename argument to store result.
* conf-parser: Add root argument to config_parse_many()Daan De Meyer2023-05-121-0/+1
|
* conf: replace config_parse_many_nulstr() with config_parse_config_file()Franck Bui2023-03-131-5/+3
| | | | | | | | | | | | | | | | | All daemons use a similar scheme to read their main config files and theirs drop-ins. The main config files are always stored in /etc/systemd directory and it's easy enough to construct the name of the drop-in directories based on the name of the main config file. Hence the new helper does that internally, which allows to reduce and simplify the args passed previously to config_parse_many_nulstr(). Besides the overall code simplification it results: 16 files changed, 87 insertions(+), 159 deletions(-) it allows to identify clearly the locations in the code where configuration files are parsed.
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-131-4/+2
|
* core/load-fragment: move config_parse_sec_fix_0 to src/sharedMichal Sekletar2022-08-231-0/+1
|
* config-parser: Add list of drop-in files as return argument of config_parse_manyRichard Phibel2022-08-121-1/+2
| | | | This will be used to save the list of drop-in files for each partition
* udev: save stats of all udev rules fileYu Watanabe2022-07-231-0/+1
| | | | | The mtime of directory is not updated when an existing rule file is changed. Hence, paths_check_timestamp() is not reliable.
* conf-parser: add a boolean flag for config_get_stats_by_path() to control if ↵Yu Watanabe2022-07-231-0/+1
| | | | | | drop-in configs are checked Preparation for later commits.
* udev: check stats of .link files and their drop-in filesYu Watanabe2022-05-031-0/+9
| | | | Fixes #23128.
* conf-parser: introduce config_parse_dns_name() and config_parse_hostname()Yu Watanabe2022-03-101-0/+2
| | | | This makes nspawn refuse hostnames which are invalid DNS domain names.
* conf-parser: introduce CONFIG_PARSE_STRING_ASCII flagYu Watanabe2022-03-101-0/+3
| | | | | When the flag is set, the string which contains non-ascii characters will be refused.
* conf-parser: merge config_parse_string() and config_parse_safe_string()Yu Watanabe2022-03-101-1/+4
| | | | | This also makes unsafe strings escaped when logged. Otherwise, journalctl may not show the log message unless '--all' is specified.
* conf-parser: add specific parser for PID valuesLennart Poettering2022-02-091-0/+1
|
* conf-parser: update config_item_*_lookup() to follow modern coding styleLennart Poettering2022-02-091-5/+5
| | | | | Let's rename the return parameters ret_xyz, and always initialize them if we return >= 0, as per our current coding style.
* conf-parse: add generic config_parse_safe_string() helperLennart Poettering2022-02-091-0/+1
| | | | | | | | This helper is just like config_parse_string() but does some superficial checks for control characters and quotes. In most cases we currently use config_parse_string() we probably want to use config_parse_safe_string() for safety reasons.
* network: rename NetworkConfigSection -> ConfigSectionYu Watanabe2022-01-191-0/+37
| | | | And move it and relevant functions to conf-parser.[ch].
* systemd-coredump: allow setting external core size to infinityThomas Blume2021-11-191-0/+1
| | | | Make it compatible to the ulimit setting: unlimited
* conf-parser: introduce config_parse_hw_addr() and config_parse_hw_addrs()Yu Watanabe2021-11-091-0/+2
|
* conf-parser: rename config_parse_hwaddr() -> config_parse_ether_addr()Yu Watanabe2021-11-091-2/+2
|
* conf-parse: make config_parse_many() optionally save 'struct stat' for each fileYu Watanabe2021-10-271-3/+5
| | | | Fixes #21113.
* conf-parser: introduce config_parse_in_addr_non_null()Yu Watanabe2021-05-181-0/+1
|
* core: fix mtime calculation of dropin filesZbigniew Jędrzejewski-Szmek2021-03-041-1/+1
| | | | | | | | | | | | | | | | | Nominally, the bug was in unit_load_dropin(), which just took the last mtime instead of calculating the maximum. But instead of adding code to wrap the loop, this patch goes in the other direction. All (correct) callers of config_parse() followed a very similar pattern to calculate the maximum mtime. So let's simplify things by making config_parse() assume that mtime is initialized and update it to the maximum. This makes all the callers that care about mtime simpler and also fixes the issue in unit_load_dropin(). config_parse_many_nulstr() and config_parse_many() are different, because it makes sense to call them just once, and current ret_mtime behaviour make sense. Fixes #17730, https://bugzilla.redhat.com/show_bug.cgi?id=1933137.
* shared/conf-parser: allow more than one location of the main config fileZbigniew Jędrzejewski-Szmek2021-02-211-1/+1
| | | | No functional change as long as only one path is passed.
* conf-parser: use return codes in xxx_from_string()Yu Watanabe2021-02-111-7/+10
| | | | Follow-up for #11484.
* oom: rework *MemoryPressureLimit= properties to have 1/10000 precisionAnita Zhang2021-02-031-0/+1
| | | | | | | Requested in https://github.com/systemd/systemd/pull/15206#discussion_r505506657, preserve the full granularity for memory pressure limits (permyriad) instead of capping out at percent.
* Merge pull request #17478 from yuwata/split-network-internalYu Watanabe2020-11-271-0/+2
|\ | | | | libsystemd-network: split network-internal.c