summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-05-07 17:02:55 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-05-09 15:17:57 -0400
commit8515830341a49a0af875333a1893a8aa41ee1099 (patch)
tree32482978a8c6ca4d32e9d24f63ab5e9d9ff20866
parent893275df36c8c358d3c0b851ca255a6169dac138 (diff)
downloadsystemd-8515830341a49a0af875333a1893a8aa41ee1099.tar.gz
shared/install: do not print warning when a unit is already enabled
Executing 'systemctl enable' on the same unit twice would cause a warning about a missing [Install] section to be printed. To avoid this, count all symlinks that "would" be created, and return 1 no matter if we actually created a symlink or skipped creation because it already exists.
-rw-r--r--src/shared/install.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/shared/install.c b/src/shared/install.c
index 4229e59140..88867c456e 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -389,8 +389,6 @@ void unit_file_dump_changes(int r, const char *verb, const UnitFileChange *chang
log_error_errno(r, "Failed to %s: %m.", verb);
}
-
-
static int create_symlink(
const char *old_path,
const char *new_path,
@@ -406,7 +404,11 @@ static int create_symlink(
/* Actually create a symlink, and remember that we did. Is
* smart enough to check if there's already a valid symlink in
- * place. */
+ * place.
+ *
+ * Returns 1 if a symlink was created or already exists and points to
+ * the right place, or negative on error.
+ */
mkdir_parents_label(new_path, 0755);
@@ -431,7 +433,7 @@ static int create_symlink(
}
if (path_equal(dest, old_path))
- return 0;
+ return 1;
if (!force) {
unit_file_changes_add(changes, n_changes, -EEXIST, new_path, dest);