summaryrefslogtreecommitdiff
path: root/src/test/test-unit-file.c
AgeCommit message (Collapse)Author
2015-06-17load-fragment: reset the list on an ExecStart= containing only whitespaceFilipe Brandenburger
This is consistent with how an empty string works in an ExecStart= statement. We should not differentiate between an empty string and whitespace only (since they look the same.) Update the test case with whitespace only to reflect that the list is reset. Tested that `test-unit-file` passes and other test cases are not affected. Installed the patched systemd binaries on a machine, booted it, looked for out of the usual behavior but did not find any.
2015-06-17load-fragment: use unquote_first_word in config_parse_execFilipe Brandenburger
Convert config_parse_exec() from using FOREACH_WORD_QUOTED into a loop of unquote_first_word. Loop through the arguments only once (the FOREACH_WORD_QUOTED implementation did it twice, once to count them and another time to process and store them.) Use newly introduced flag UNQUOTE_UNESCAPE_RELAX to preserve unrecognized escape sequences such as regexps matches such as "\w", "\d", etc. (Valid escape sequences such as "\s" or "\b" still need an extra backslash if literals are desired for regexps.) Differences in behavior: - Handle ; (command separator) in special, so that only ; on its own is valid for that purpose, an quoted semicolon ";" or ';' will now behave as a literal semicolon. This is probably what was initially intended. - Handle \; (to introduce a literal semicolon) in special, so that only \; is turned into a semicolon but not \\; or "\\;" or "\;" which are kept as a literal \; in the output. This is probably what was initially intended. Known issues: - Using an empty string (for example, ExecStartPre=<empty>) will empty the list and remove the existing commands, but using whitespace only (for example, ExecStartPre=<spaces>) will not. This is a pre-existing issue and will be dealt with in a follow up commit. Tested: - Unit tests passing. Also `make distcheck` still works as expected. - Installed it on a local machine and booted with it, checked console output, systemctl and journalctl output, did not notice any issues running the patched systemd binaries. Relevant bug: https://bugs.freedesktop.org/show_bug.cgi?id=90794
2015-06-17tests: additional cases in test-unit-fileFilipe Brandenburger
These tests will be useful to check the cases regarding quoted and escaped semicolon when we switch to using unquote_first_word. Additionally, convert some of the tests that have semicolons so that the argument after the semicolon looks like a path (starts with /) so that we can see the change of behavior when making config_parse_exec more strict about what it accepts as a command separator.
2015-06-03test-unit-file.c: fixup the test for commit 3b51f8ddd5Harald Hoyer
2015-06-01test-unit-file: add test for improperly escaped exec stringDaniel Mack
Add a regression test for the recent breakage of handling improperly escaped exec strings in unit files. Code contributed by Martin Pitt: https://bugs.freedesktop.org/show_bug.cgi?id=90794
2015-05-18util: split all hostname related calls into hostname-util.cLennart Poettering
2015-05-15core: Fix assertion with empty Exec*= pathsMartin Pitt
An Exec*= line with whitespace after modifiers, like ExecStart=- /bin/true is considered to have an empty command path. This is as specified, but causes systemd to crash with Assertion 'skip < l' failed at ../src/core/load-fragment.c:607, function config_parse_exec(). Aborting. Aborted (core dumped) Fix this by logging an error instead and ignoring the invalid line. Add corresponding test cases. Also add a test case for a completely empty value which resets the command list. https://launchpad.net/bugs/1454173
2015-05-11install: when exporting prefix InstallInfo to become UnitFileInstallInfoLennart Poettering
All other types exported from install.h should be namespaces like this, hence namespace InstallInfo the same way. Also, remove external forward definition of UnitFileScope type.
2015-04-23util: Fix assertion in split() on missing 'Martin Pitt
When parsing a unit with a trailing slash after an escaped line break, like ExecStart=/bin/echo 'foo \ bar' the split() function (through config_parse()) asserted and crashed pid 1: Assertion 'current[*l + 1] == quotechars[0]' failed at ../src/shared/util.c:583, function split(). Aborting. Fix this by returning an error in this case ("trailing garbage"). Add corresponding test case. Also fix the missing "unit" argument of config_parse_exec() in the comment. https://launchpad.net/bugs/1447243
2015-02-23remove unused includesThomas Hindoe Paaboel Andersen
This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
2015-01-11core/load-fragment: avoid allocating 0 bytes when given an invalid commandZbigniew Jędrzejewski-Szmek
With a command line like "@/something" we would allocate an array with 0 elements. Avoid that, and add a test too.
2015-01-11test-unit-file: don't access out-of-bounds memoryZbigniew Jędrzejewski-Szmek
Fixes an error introduced by me when the test was added.
2014-12-18load-fragment: allow quoting in command name and document allowed escapesZbigniew Jędrzejewski-Szmek
The handling of the command name and other arguments is unified. This simplifies things and should make them more predictable for users. Incidentally, this makes ExecStart handling match the .desktop file specification, apart for the requirment for an absolute path. https://bugs.freedesktop.org/show_bug.cgi?id=86171
2014-12-18test-unit-file: add test for semicolon escapingZbigniew Jędrzejewski-Szmek
https://bugs.freedesktop.org/show_bug.cgi?id=87393
2014-11-23test: support empty environment variables in unit filesIago López Galeiras
Also update TODO, empty environment variables in Environment= and EnvironmentFile= options work.
2014-10-04test: only use assert_seThomas Hindoe Paaboel Andersen
The asserts used in the tests should never be allowed to be optimized away
2014-09-15hashmap: introduce hash_ops to make struct Hashmap smallerMichal Schmidt
It is redundant to store 'hash' and 'compare' function pointers in struct Hashmap separately. The functions always comprise a pair. Store a single pointer to struct hash_ops instead. systemd keeps hundreds of hashmaps, so this saves a little bit of memory.
2014-07-03machinectl: show /etc/os-release information of container in status outputLennart Poettering
2014-05-25test-unit-file: skip if unit_file_get_list returns permission deniedCristian Rodríguez
2014-02-20macro: add nice macro for disabling -Wnonnull temporarilyLennart Poettering
2014-01-28always use the same code for creating temporary filesLennart Poettering
Let's unify our code here, and also always specifiy O_CLOEXEC.
2013-11-25conf-parser: distinguish between multiple sections with the same nameTom Gundersen
Pass on the line on which a section was decleared to the parsers, so they can distinguish between multiple sections (if they chose to). Currently no parsers take advantage of this, but a follow-up patch will do that to distinguish [Address] Address=192.168.0.1/24 Label=one [Address] Address=192.168.0.2/24 Label=two from [Address] Address=192.168.0.1/24 Label=one Address=192.168.0.2/24 Label=two
2013-09-17specifier: rework specifier calls to return proper error messageLennart Poettering
Previously the specifier calls could only indicate OOM by returning NULL. With this change they will return negative errno-style error codes like everything else.
2013-08-22test: Make testing work on systems without or old systemdHolger Hans Peter Freyther
* Introduce a macro to conditionally execute tests. This avoids skipping the entire test if some parts require systemd * Skip the journal tests when no /etc/machine-id is present * Change test-catalog to load the catalog from the source directory of systemd. * /proc/PID/comm got introduced in v2.6.33 but travis is still using v2.6.32. * Enable make check and make distcheck on the travis build * Use -D"CATALOG_DIR=STR($(abs_top_srcdir)/catalog)" as a STRINGIY would result in the path '/home/ich/source/linux' to be expanded to '/home/ich/source/1' as linux is defined to 1.
2013-07-30test-unit-file: return error without dumping core on permission errorChristian Hesse
2013-04-18move _cleanup_ attribute in front of the typeHarald Hoyer
http://lists.freedesktop.org/archives/systemd-devel/2013-April/010510.html
2013-04-17Report about syntax errors with metadataZbigniew Jędrzejewski-Szmek
The information about the unit for which files are being parsed is passed all the way down. This way messages land in the journal with proper UNIT=... or USER_UNIT=... attribution. 'systemctl status' and 'journalctl -u' not displaying those messages has been a source of confusion for users, since the journal entry for a misspelt setting was often logged quite a bit earlier than the failure to start a unit. Based-on-a-patch-by: Oleksii Shevchuk <alxchk@gmail.com>
2013-04-17core: log a few more things under UNIT=...Zbigniew Jędrzejewski-Szmek
2013-04-13fileio: in envfiles, do not skip lines following empty linesZbigniew Jędrzejewski-Szmek
https://bugs.freedesktop.org/show_bug.cgi?id=63477
2013-04-03shared: rework env file readerLennart Poettering
Implement this with a proper state machine, so that newlines and escaped chars can appear in string assignments. This should bring the parser much closer to shell.
2013-03-09Fix typos of /etc/systemd/systemdZbigniew Jędrzejewski-Szmek
<Lekensteyn> The 198 announcement mentions "/etc/systemd/systemd/foobar.service.d/*.conf", is that a typo? I only have a /etc/systemd/system/. Is there a manpage describing this new feature?
2013-02-14honor SELinux labels, when creating and writing config filesHarald Hoyer
Also split out some fileio functions to fileio.c and provide a SELinux aware pendant in fileio-label.c see https://bugzilla.redhat.com/show_bug.cgi?id=881577
2013-02-13tests: add test for continuation lines with commentsZbigniew Jędrzejewski-Szmek
2013-01-29tests: add test for install_full_printf()Zbigniew Jędrzejewski-Szmek
2013-01-18util: modernization and test for load_env_fileZbigniew Jędrzejewski-Szmek
2012-11-15core: lift restriction on order of - and @ in ExecStartZbigniew Jędrzejewski-Szmek
2012-11-15core: interpret \; token in ExecStart as escaped ;Oleksii Shevchuk
Some commands (like 'find') take a semicolon as separate arg. With current parser implementation there is no way to pass one. Patch adds token \;
2012-11-15tests: add tests for config_parse_execZbigniew Jędrzejewski-Szmek
2012-09-16install: treat non-existent directory as emptyZbigniew Jędrzejewski-Szmek
When looking for symlinks, it doesn't make sense to error-out if the directory is missing. The user might delete an empty directory. This check caused test-unit-file to fail when run before installation.
2012-09-11when determining unit file list, include invalid unit names in an "invalid" ↵Lennart Poettering
state