summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/execute.c4
-rw-r--r--src/core/load-fragment.c2
2 files changed, 5 insertions, 1 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index 2cef70e668..e718c43df9 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -552,6 +552,10 @@ static int chown_terminal(int fd, uid_t uid) {
assert(fd >= 0);
+ /* Before we chown/chmod the TTY, let's ensure this is actually a tty */
+ if (isatty(fd) < 1)
+ return 0;
+
/* This might fail. What matters are the results. */
(void) fchown(fd, uid, -1);
(void) fchmod(fd, TTY_MODE);
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index b53301a147..2d8f6296c8 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -3743,7 +3743,7 @@ static int merge_by_names(Unit **u, Set *names, const char *id) {
/* If the symlink name we are looking at is unit template, then
we must search for instance of this template */
- if (unit_name_is_valid(k, UNIT_NAME_TEMPLATE)) {
+ if (unit_name_is_valid(k, UNIT_NAME_TEMPLATE) && (*u)->instance) {
_cleanup_free_ char *instance = NULL;
r = unit_name_replace_instance(k, (*u)->instance, &instance);