chiark / gitweb /
core: fix %h, %s, %p handling in templates in user session
authorOleksii Shevchuk <alxchk@gmail.com>
Sat, 3 Nov 2012 19:51:59 +0000 (21:51 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 15 Nov 2012 14:59:50 +0000 (15:59 +0100)
src/core/unit-printf.c

index cbae45d9f75c2f2db756982acac52f7154ef4772..a8eb60a3d4264de1f6b464f6ea5db2bda68fa468 100644 (file)
@@ -127,11 +127,9 @@ static char *specifier_user_name(char specifier, void *data, void *userdata) {
         assert(u);
 
         c = unit_get_exec_context(u);
         assert(u);
 
         c = unit_get_exec_context(u);
-        if (!c)
-                return NULL;
 
         /* get USER env from our own env if set */
 
         /* get USER env from our own env if set */
-        if (!c->user)
+        if (!c || !c->user)
                 return getusername_malloc();
 
         /* fish username from passwd */
                 return getusername_malloc();
 
         /* fish username from passwd */
@@ -152,11 +150,9 @@ static char *specifier_user_home(char specifier, void *data, void *userdata) {
         assert(u);
 
         c = unit_get_exec_context(u);
         assert(u);
 
         c = unit_get_exec_context(u);
-        if (!c)
-                return NULL;
 
         /* return HOME if set, otherwise from passwd */
 
         /* return HOME if set, otherwise from passwd */
-        if (!c->user) {
+        if (!c || !c->user) {
                 char *h;
 
                 r = get_home_dir(&h);
                 char *h;
 
                 r = get_home_dir(&h);
@@ -183,11 +179,9 @@ static char *specifier_user_shell(char specifier, void *data, void *userdata) {
         assert(u);
 
         c = unit_get_exec_context(u);
         assert(u);
 
         c = unit_get_exec_context(u);
-        if (!c)
-                return NULL;
 
         /* return HOME if set, otherwise from passwd */
 
         /* return HOME if set, otherwise from passwd */
-        if (!c->user) {
+        if (!c || !c->user) {
                 char *sh;
 
                 r = get_shell(&sh);
                 char *sh;
 
                 r = get_shell(&sh);