7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek This file is part of systemd.
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek Copyright 2013 Zbigniew Jędrzejewski-Szmek
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek systemd is free software; you can redistribute it and/or modify it
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek under the terms of the GNU Lesser General Public License as published by
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek the Free Software Foundation; either version 2.1 of the License, or
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek (at your option) any later version.
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek systemd is distributed in the hope that it will be useful, but
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek WITHOUT ANY WARRANTY; without even the implied warranty of
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek Lesser General Public License for more details.
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek You should have received a copy of the GNU Lesser General Public License
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek along with systemd; If not, see <http://www.gnu.org/licenses/>.
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poetteringstatic int specifier_prefix_and_instance(char specifier, void *data, void *userdata, char **ret) {
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poettering return unit_name_to_prefix_and_instance(i->name, ret);
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poetteringstatic int specifier_prefix(char specifier, void *data, void *userdata, char **ret) {
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poettering return unit_name_to_prefix(i->name, ret);
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poetteringstatic int specifier_instance(char specifier, void *data, void *userdata, char **ret) {
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek r = unit_name_to_instance(i->name, &instance);
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poetteringstatic int specifier_user_name(char specifier, void *data, void *userdata, char **ret) {
79413b673b45adc98dfeaec882bbdda2343cb2f9Lennart Poettering /* If we are UID 0 (root), this will not result in NSS,
79413b673b45adc98dfeaec882bbdda2343cb2f9Lennart Poettering * otherwise it might. This is good, as we want to be able to
79413b673b45adc98dfeaec882bbdda2343cb2f9Lennart Poettering * run this in PID 1, where our user ID is 0, but where NSS
79413b673b45adc98dfeaec882bbdda2343cb2f9Lennart Poettering * lookups are not allowed. */
79413b673b45adc98dfeaec882bbdda2343cb2f9Lennart Poetteringstatic int specifier_user_id(char specifier, void *data, void *userdata, char **ret) {
79413b673b45adc98dfeaec882bbdda2343cb2f9Lennart Poettering if (asprintf(ret, UID_FMT, getuid()) < 0)
cab6235f748e365198a7939f23c87ab3b8f59b2eLennart Poetteringint install_full_printf(UnitFileInstallInfo *i, const char *format, char **ret) {
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek /* This is similar to unit_full_printf() but does not support
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek * anything path-related.
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek * %n: the full id of the unit (foo@bar.waldo)
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek * %N: the id of the unit without the suffix (foo@bar)
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek * %p: the prefix (foo)
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek * %i: the instance (bar)
79413b673b45adc98dfeaec882bbdda2343cb2f9Lennart Poettering * %U the UID of the running user
79413b673b45adc98dfeaec882bbdda2343cb2f9Lennart Poettering * %u the username of running user
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek * %m the machine ID of the running system
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek * %H the host name of the running system
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek * %b the boot ID of the running system
6aaa8c2f783cd1b3ac27c5ce40625d032e7e3d71Zbigniew Jędrzejewski-Szmek * %v `uname -r` of the running system
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek { 'n', specifier_string, i->name },
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek { 'N', specifier_prefix_and_instance, NULL },
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek { 'p', specifier_prefix, NULL },
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek { 'i', specifier_instance, NULL },
3f0b2f0f452e94444e4fb7b62030ea05738bb1b6Zbigniew Jędrzejewski-Szmek { 'u', specifier_user_name, NULL },
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek { 'm', specifier_machine_id, NULL },
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek { 'H', specifier_host_name, NULL },
7584d236eac91f9b7128b1eb08bddf18be2bce9fZbigniew Jędrzejewski-Szmek { 'b', specifier_boot_id, NULL },
6aaa8c2f783cd1b3ac27c5ce40625d032e7e3d71Zbigniew Jędrzejewski-Szmek { 'v', specifier_kernel_release, NULL },