summaryrefslogtreecommitdiff
path: root/src/core/unit-printf.c
diff options
context:
space:
mode:
authorOleksii Shevchuk <alxchk@gmail.com>2012-11-03 21:51:59 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2012-11-15 15:59:50 +0100
commit774de5a97fe69da822fde77b88af8d970ab5d0c6 (patch)
treeb08220183e59f34713b1b198e6cd6f59b26e6fe9 /src/core/unit-printf.c
parentf09a7d25545b5e3a2dd3dfc1ff7ebc8560a3354c (diff)
core: fix %h, %s, %p handling in templates in user session
Diffstat (limited to 'src/core/unit-printf.c')
-rw-r--r--src/core/unit-printf.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c
index cbae45d9f7..a8eb60a3d4 100644
--- a/src/core/unit-printf.c
+++ b/src/core/unit-printf.c
@@ -127,11 +127,9 @@ static char *specifier_user_name(char specifier, void *data, void *userdata) {
assert(u);
c = unit_get_exec_context(u);
- if (!c)
- return NULL;
/* get USER env from our own env if set */
- if (!c->user)
+ if (!c || !c->user)
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);
- if (!c)
- return NULL;
/* return HOME if set, otherwise from passwd */
- if (!c->user) {
+ if (!c || !c->user) {
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);
- if (!c)
- return NULL;
/* return HOME if set, otherwise from passwd */
- if (!c->user) {
+ if (!c || !c->user) {
char *sh;
r = get_shell(&sh);