summaryrefslogtreecommitdiff
path: root/src/test/test-unit-name.c
AgeCommit message (Collapse)Author
2016-04-12core: remove ManagerRunningAs enumLennart Poettering
Previously, we had two enums ManagerRunningAs and UnitFileScope, that were mostly identical and converted from one to the other all the time. The latter had one more value UNIT_FILE_GLOBAL however. Let's simplify things, and remove ManagerRunningAs and replace it by UnitFileScope everywhere, thus making the translation unnecessary. Introduce two new macros MANAGER_IS_SYSTEM() and MANAGER_IS_USER() to simplify checking if we are running in one or the user context.
2016-02-10tree-wide: remove Emacs lines from all filesDaniel Mack
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2016-01-27basic: don't append suffixes to unit name glob expressionsLennart Poettering
When the user specifies "foo*" as unit name glob expression, we shouldn't turn this into "foo*.service". Hence: only append a suffix if the specified string isn't a glob expression. Fixes: #2397
2016-01-27tests: don't abbreviate function names needlesslyLennart Poettering
THis is otherwise really hard to read...
2015-11-12core: simplify handling of %u, %U, %s and %h unit file specifiersLennart Poettering
Previously, the %u, %U, %s and %h specifiers would resolve to the user name, numeric user ID, shell and home directory of the user configured in the User= setting of a unit file, or the user of the manager instance if no User= setting was configured. That at least was the theory. In real-life this was not ever actually useful: - For the systemd --user instance it made no sense to ever set User=, since the instance runs in user context after all, and hence the privileges to change user IDs don't even exist. The four specifiers were actually not useful at all in this case. - For the systemd --system instance we did not allow any resolving that would require NSS. Hence, %s and %h were not supported, unless User=root was set, in which case they would be hardcoded to /bin/sh and /root, to avoid NSS. Then, %u would actually resolve to whatever was set with User=, but %U would only resolve to the numeric UID of that setting if the User= was specified in numeric form, or happened to be root (in which case 0 was hardcoded as mapping). Two of the specifiers are entirely useless in this case, one is realistically also useless, and one is pretty pointless. - Resolving of these settings would only happen if User= was actually set *before* the specifiers where resolved. This behaviour was undocumented and is really ugly, as specifiers should actually be considered something that applies to the whole file equally, independently of order... With this change, %u, %U, %s and %h are drastically simplified: they now always refer to the user that is running the service instance, and the user configured in the unit file is irrelevant. For the system instance of systemd this means they always resolve to "root", "0", "/bin/sh" and "/root", thus avoiding NSS. For the user instance, to the data for the specific user. The new behaviour is identical to the old behaviour in all --user cases and for all units that have no User= set (or set to "0" or "root").
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-10-24util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering
string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
2015-05-18util: split all hostname related calls into hostname-util.cLennart Poettering
2015-05-11core: rename SystemdRunningAs to ManagerRunningAsLennart Poettering
It's primarily just a property of the Manager object after all, and we try to refer to PID 1 as "manager" instead of "systemd", hence let's to stick to this here too.
2015-05-05core: be more strict when manipulating slices names and unescaping paths ↵Lennart Poettering
from unit names Let's better be safe then sorry.
2015-05-05core: rework unit name validation and manipulation logicLennart Poettering
A variety of changes: - Make sure all our calls distuingish OOM from other errors if OOM is not the only error possible. - Be much stricter when parsing escaped paths, do not accept trailing or leading escaped slashes. - Change unit validation to take a bit mask for allowing plain names, instance names or template names or an combination thereof. - Refuse manipulating invalid unit name
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.
2014-12-13test-unit-name: add more testsRonny Chevalier
Add more test cases for: - unit_name_is_instance - unit_name_to_instance Add tests for: - unit_name_template - unit_name_is_template
2014-12-11test-unit-name: add tests for %fRonny Chevalier
2014-11-20tests: fix minor memory leakLennart Poettering
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-07-20test-engine: fix access to unit load pathZbigniew Jędrzejewski-Szmek
Also add a bit of debugging output to help diagnose problems, add missing units, and simplify cppflags. Move test-engine to normal tests from manual tests, it should now work without destroying the system.
2014-06-30tests: add missing XDG_RUNTIME_DIR env variableRonny Chevalier
Otherwise the test fails because specifier_runtime() returns -ENOTSUP when XDG_RUNTIME_DIR is not set.
2014-06-24tests: add tests to test-unit-nameRonny Chevalier
add tests for: - unit_instance_is_valid - unit_prefix_is_valid - unit_name_change_suffix - unit_name_build - unit_name_is_instance - build_subslice - unit_name_to_instance - unit_name_escape
2014-02-19make gcc shut upLennart Poettering
If -flto is used then gcc will generate a lot more warnings than before, among them a number of use-without-initialization warnings. Most of them without are false positives, but let's make them go away, because it doesn't really matter.
2013-12-26Use enums to make it obvious what boolean params meanZbigniew Jędrzejewski-Szmek
Suggested-by: Russ Allbery <rra@debian.org>
2013-12-26systemctl: allow globbing in commands which take multiple unit namesZbigniew Jędrzejewski-Szmek
2013-12-18tests: fix buildLennart Poettering
2013-11-30core: allocate a kdbus bus for each systemd instance, if we canLennart Poettering
2013-11-20test: exit early if we would conflict with running user systemdLennart Poettering
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-18tests: skip tests when executed without privileges but which require themKay Sievers
2013-07-12test-path-util,test-sched-prio: uninitialize manager to appease valgrindZbigniew Jędrzejewski-Szmek
2013-07-10core: serialize/deserialize bus subscribersLennart Poettering
2013-04-18move _cleanup_ attribute in front of the typeHarald Hoyer
http://lists.freedesktop.org/archives/systemd-devel/2013-April/010510.html
2013-03-26tests: skip bus test if bus cannot be openedZbigniew Jędrzejewski-Szmek
To make the result more visible, special return value is used to tell automake that the test was skipped. While at it, use the same return value in other skipped tests.
2013-03-26Simplify the meaning of %sZbigniew Jędrzejewski-Szmek
The rules governing %s where just too complicated. First of all, looking at $SHELL is dangerous. For systemd --system, it usually wouldn't be set. But it could be set if the admin first started a debug shell, let's say /sbin/sash, and then launched systemd from it. This shouldn't influence how daemons are started later on, so is better ignored. Similar reasoning holds for session mode. Some shells set $SHELL, while other set it only when it wasn't set previously (e.g. zsh). This results in fragility that is better avoided by ignoring $SHELL totally. With $SHELL out of the way, simplify things by saying that %s==/bin/sh for root, and the configured shell otherwise. get_shell() is the only caller, so it can be inlined. Fixes one issue seen with 'make check'.
2013-02-06tests: skip tests if manager cannot be createdZbigniew Jędrzejewski-Szmek
When running without a user session, tests fail.
2013-02-06tests: run manager in session modeZbigniew Jędrzejewski-Szmek
False positives pop up otherwise. FAIL: test-unit-name (exit: 134) ================================ Failed to open /dev/tty0: Permission denied Failed to create root cgroup hierarchy: Permission denied Assertion 'manager_new(SYSTEMD_SYSTEM, &m) == 0' failed at src/test/test-unit-name.c:125, function test_unit_printf(). Aborting.
2013-01-29tests: add test for unit name printingZbigniew Jędrzejewski-Szmek
2013-01-29tests: compress unit name tests and add more assertsZbigniew Jędrzejewski-Szmek
2012-09-12test: extend unit-name test a bitLennart Poettering
2012-09-12unit-name: rework unit_name_replace_instance function()Lennart Poettering
https://bugzilla.redhat.com/show_bug.cgi?id=855863
2012-06-25cryptsetup: fix escaping when generating cryptsetup unitsLennart Poettering
2012-06-22systemctl: automatically turn paths and unescaped unit names into proper ↵Lennart Poettering
unit names This makes sure that systemctl status /home is implicitly translated to: systemctl status /home.mount Similar, /dev/foobar becomes dev-foobar.device. Also, all characters that cannot be part of a unit name are implicitly escaped.