]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/shared/install-printf.c
tree-wide: drop license boilerplate
[thirdparty/systemd.git] / src / shared / install-printf.c
index 596f7e46b6cb0838b703ec1bfb341c4ff6852d56..c2cbf348e2fff860425cd4806dc02e8a07fb5f65 100644 (file)
@@ -3,19 +3,6 @@
   This file is part of systemd.
 
   Copyright 2013 Zbigniew JÄ™drzejewski-Szmek
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
 #include <errno.h>
@@ -50,10 +37,8 @@ static int specifier_prefix_and_instance(char specifier, void *data, void *userd
                 if (!ans)
                         return -ENOMEM;
                 *ret = ans;
-        } else {
-                *ret = prefix;
-                prefix = NULL;
-        }
+        } else
+                *ret = TAKE_PTR(prefix);
 
         return 0;
 }
@@ -94,7 +79,7 @@ static int specifier_instance(char specifier, void *data, void *userdata, char *
                 return r;
 
         if (isempty(instance)) {
-                r = free_and_strdup(&instance, i->default_instance ?: "");
+                r = free_and_strdup(&instance, strempty(i->default_instance));
                 if (r < 0)
                         return r;
         }
@@ -103,34 +88,6 @@ static int specifier_instance(char specifier, void *data, void *userdata, char *
         return 0;
 }
 
-static int specifier_user_name(char specifier, void *data, void *userdata, char **ret) {
-        char *t;
-
-        /* If we are UID 0 (root), this will not result in NSS,
-         * otherwise it might. This is good, as we want to be able to
-         * run this in PID 1, where our user ID is 0, but where NSS
-         * lookups are not allowed.
-
-         * We don't user getusername_malloc() here, because we don't want to look
-         * at $USER, to remain consistent with specifer_user_id() below.
-         */
-
-        t = uid_to_name(getuid());
-        if (!t)
-                return -ENOMEM;
-
-        *ret = t;
-        return 0;
-}
-
-static int specifier_user_id(char specifier, void *data, void *userdata, char **ret) {
-
-        if (asprintf(ret, UID_FMT, getuid()) < 0)
-                return -ENOMEM;
-
-        return 0;
-}
-
 int install_full_printf(UnitFileInstallInfo *i, const char *format, char **ret) {
 
         /* This is similar to unit_full_printf() but does not support