- if (!streq(i->argument, x)) {
- log_error("%s is not the right symlink.", i->path);
- return -EEXIST;
+ r = readlink_malloc(i->path, &x);
+ if (r < 0 || !streq(i->argument, x)) {
+
+ if (i->force) {
+ mac_selinux_create_file_prepare(i->path, S_IFLNK);
+ r = symlink_atomic(i->argument, i->path);
+ mac_selinux_create_file_clear();
+
+ if (r < 0) {
+ log_error("symlink(%s, %s) failed: %s", i->argument, i->path, strerror(-r));
+ return r;
+ }
+ } else {
+ log_debug("%s is not a symlink or does not point to the correct path.", i->path);
+ return 0;
+ }
+ }