summaryrefslogtreecommitdiff
path: root/src/core/unit-printf.c
Commit message (Collapse)AuthorAgeFilesLines
* core: add unit specifier for configuration directory rootYu Watanabe2018-06-211-0/+2
| | | | Follow-up for 14068e17f32a06e6a1f8f72416018bc653b8ea2d.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* core: introduce specifiers for /tmp and /var/tmpLennart Poettering2018-05-291-0/+5
| | | | | | | | | | | This corresponds nicely with the specifiers we already pass for /var/lib, /var/cache, /run and so on. This is particular useful to update the test-path service files to operate without guessable files, thus allowing multiple parallel test-path invocations to pass without issues (the idea is to set $TMPDIR early on in the test to some private directory, and then only use the new %T or %V specifier to refer to it).
* Add %j/%J unit specifiersZbigniew Jędrzejewski-Szmek2018-04-241-25/+58
| | | | | | | | | Those are quite similar to %i/%I, but refer to the last dash-separated component of the name prefix. The new functionality of dash-dropins could largely supersede the template functionality, so it would be tempting to overload %i/%I. But that would not be backwards compatible. So let's add the two new letters instead.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* specifier: unify specifier implementations for user-related specifiersLennart Poettering2017-11-291-40/+0
| | | | | | The code in install-printf.c and unit-printf.c for these is pretty much the same and very generic. Let's move this all over to the generic specifier.c, and share the implementations.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* core: add support for expanding state/cache/log directory root in unit filesLennart Poettering2017-10-261-4/+12
| | | | | | | | | | | | | | | | | | | | | | | This augments %t which already resolves to the runtime directory root, and should be useful for units that want to pass any of these paths in command line arguments. Example: ExecStart=/usr/bin/mydaemon --datadir=%S/mydaemon Why not expose a specifier resolving directly to the configured state/runtime/cache/log dir? Three reasons: 1. Specifiers should be independent of configuration of the unit itself, and StateDirectory= and friends are unit configuration. See 03fc9c723cfc59467a7fccc305f34273f8564b25 and related work. 2. We permit multiple StateDirectory= values per unit, and it hence wouldn't be clear which one is passed. 3. We already have %t for the runtime directory root, and we should continue with the same scheme.
* core: add {State,Cache,Log,Configuration}Directory= (#6384)Yu Watanabe2017-07-181-5/+1
| | | | | | | | This introduces {State,Cache,Log,Configuration}Directory= those are similar to RuntimeDirectory=. They create the directories under /var/lib, /var/cache/, /var/log, or /etc, respectively, with the mode specified in {State,Cache,Log,Configuration}DirectoryMode=. This also fixes #6391.
* core: add a note clarifying that we should be careful when adding new specifiersLennart Poettering2016-12-071-0/+4
|
* core: deprecate %c, %r, %R specifiersLennart Poettering2016-12-071-3/+13
| | | | | | | | | | | | %c and %r rely on settings made in the unit files themselves and hence resolve to different values depending on whether they are used before or after Slice=. Let's simply deprecate them and drop them from the documentation, as that's not really possible to fix. Moreover they are actually redundant, as the same information may always be queried from /proc/self/cgroup and /proc/1/cgroup. (Accurately speaking, %R is actually not broken like this as it is constant. However, let's remove all cgroup-related specifiers at once, as it is also redundant, and doesn't really make much sense alone.)
* core: resolve more specifiers in unit_name_printf()Lennart Poettering2016-12-071-18/+29
| | | | | | | | | | | | unit_name_printf() is usually what we use when the resulting string shall qualify as unit name, and it hence avoids resolving specifiers that almost certainly won't result in valid unit names. Add a couple of more specifiers that unit_full_printf() resolves also to the list unit_name_printf() resolves, as they are likely to be useful in valid unit names too. (Note that there might be cases where this doesn't hold, but we should still permit this, as more often than not they are safe, and if people want to use them that way, they should be able to.)
* Rename formats-util.h to format-util.hZbigniew Jędrzejewski-Szmek2016-11-071-1/+1
| | | | | | We don't have plural in the name of any other -util files and this inconsistency trips me up every time I try to type this file name from memory. "formats-util" is even hard to pronounce.
* core: reuse manager_get_runtime_prefix() at more placesLennart Poettering2016-04-121-8/+3
|
* core: remove ManagerRunningAs enumLennart Poettering2016-04-121-1/+1
| | | | | | | | | | | 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.
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* core: simplify handling of %u, %U, %s and %h unit file specifiersLennart Poettering2015-11-121-143/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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").
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split out user/group/uid/gid calls into user-util.[ch]Lennart Poettering2015-10-261-1/+2
|
* Merge pull request #1654 from poettering/util-libTom Gundersen2015-10-251-4/+5
|\ | | | | Various changes to src/basic/
| * util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | core: various small fixes to unit-printfEvgeny Vereshchagin2015-10-241-5/+4
|/ | | | | | * check memory allocation errors in specifier_cgroup_slice * %I doesn't fail for non-instantiated units (%i doesn't fail too) * EOPNOTSUPP for consistency
* core: rename SystemdRunningAs to ManagerRunningAsLennart Poettering2015-05-111-4/+4
| | | | | | 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.
* core: rework unit name validation and manipulation logicLennart Poettering2015-05-051-42/+13
| | | | | | | | | | | | | | | 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
* core: simplify %r and %R logic a bitLennart Poettering2015-04-301-15/+24
| | | | | Do not calculate the cgroup path manually, just use normal unit fields and calls for that.
* shared: add formats-util.hRonny Chevalier2015-04-101-0/+1
|
* tree-wide: there is no ENOTSUP on linuxDavid Herrmann2015-03-131-7/+7
| | | | Replace ENOTSUP by EOPNOTSUPP as this is what linux actually uses.
* remove unused includesThomas Hindoe Paaboel Andersen2015-02-231-3/+0
| | | | | | 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.
* core: when the user hits Ctrl-Alt-Del more than 7x per 2s, reboot immediatelyLennart Poettering2015-01-281-1/+1
| | | | | This should be useful for cases where clean rebooting doesn't work, and the user wants to hurry up the reboot.
* Always check asprintf return codeKarel Zak2014-07-261-4/+4
| | | | | | | There is a small number of the places in sources where we don't check asprintf() return code and assume that after error the function returns NULL pointer via the first argument. That's wrong, after error the content of pointer is undefined.
* Remove unnecessary casts in printfsZbigniew Jędrzejewski-Szmek2014-05-151-2/+2
| | | | No functional change expected :)
* doc: corrections to words and formsJan Engelhardt2014-05-071-1/+1
| | | | | This patch exchange words which are inappropriate for a situation, deletes duplicated words, and adds particles where needed.
* core: refuse doing %h, %s, %U specifier resolving in PID 1Lennart Poettering2013-12-161-69/+119
| | | | | | These specifiers require NSS lookups to work, and we really shouldn't do them from PID 1 hence. With this change they are now only supported for user systemd instance, or when the configured user for a unit is root.
* specifier: rework specifier calls to return proper error messageLennart Poettering2013-09-171-67/+133
| | | | | | 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.
* core: add %v specifierZbigniew Jędrzejewski-Szmek2013-07-191-1/+3
|
* logind: add infrastructure to keep track of machines, and move to slicesLennart Poettering2013-06-201-13/+15
| | | | | | | | | | | | | | | | | | | | - This changes all logind cgroup objects to use slice objects rather than fixed croup locations. - logind can now collect minimal information about running VMs/containers. As fixed cgroup locations can no longer be used we need an entity that keeps track of machine cgroups in whatever slice they might be located. Since logind already keeps track of users, sessions and seats this is a trivial addition. - nspawn will now register with logind and pass various bits of metadata along. A new option "--slice=" has been added to place the container in a specific slice. - loginctl gained commands to list, introspect and terminate machines. - user.slice and machine.slice will now be pulled in by logind.service, since only logind.service requires this slice.
* move _cleanup_ attribute in front of the typeHarald Hoyer2013-04-181-1/+1
| | | | http://lists.freedesktop.org/archives/systemd-devel/2013-April/010510.html
* Simplify the meaning of %sZbigniew Jędrzejewski-Szmek2013-03-261-12/+21
| | | | | | | | | | | | | | | | | | | 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'.
* install: allow specifiers in WantedBy/RequiredBy/AliasZbigniew Jędrzejewski-Szmek2013-01-291-2/+2
| | | | | | | | | | | | | | | | | This allows one templated unit to refer to another templated unit at installation time. Examples: > grep WantedBy ~/.config/systemd/user/mpop@.timer WantedBy=services@%i.target > srv disable mpop@iit.timer rm '/home/alxchk/.config/systemd/user/services@iit.target.wants/mpop@iit.timer' > srv enable mpop@iit.timer ln -s '/home/alxchk/.config/systemd/user/mpop@.timer' '/home/alxchk/.config/systemd/user/services@iit.target.wants/mpop@iit.timer' Based-on-patch-by: Oleksii Shevchuk <alxchk@gmail.com>
* core: fix %U when no User= usedZbigniew Jędrzejewski-Szmek2013-01-291-4/+7
| | | | | When the username was not explicitly specified, both %U and %u would print the username. Make %U always print UID.
* Move generic specifier functions to sharedZbigniew Jędrzejewski-Szmek2013-01-291-36/+0
| | | | No functional change. This makes it possible to use them in install.c.
* unit: add %U for uids in unitsDaniel Wallace2012-12-191-2/+15
|
* core: fix %h, %s, %p handling in templates in user sessionOleksii Shevchuk2012-11-151-9/+3
|
* core: move ManagerRunningAs to sharedZbigniew Jędrzejewski-Szmek2012-09-181-1/+1
| | | | | | | Note: I did s/MANAGER/SYSTEMD/ everywhere, even though it makes the patch quite verbose. Nevertheless, keeping MANAGER prefix in some places, and SYSTEMD prefix in others would just lead to confusion down the road. Better to rip off the band-aid now.
* unit-printf: add specifiers for the host name, machine id, boot idLennart Poettering2012-09-181-0/+49
|
* unit-printf: before resolving exec context specifiers check whether the ↵Lennart Poettering2012-09-181-9/+24
| | | | object actually has an exec context
* unit: split unit_printf() and friends into its own .c fileLennart Poettering2012-09-181-0/+282