diff --git a/bubblewrap.c b/bubblewrap.c index 8322ea03..800c8303 100644 --- a/bubblewrap.c +++ b/bubblewrap.c @@ -1474,7 +1474,20 @@ setup_newroot (bool unshare_pid, case SETUP_MAKE_SYMLINK: assert (op->source != NULL); /* guaranteed by the constructor */ if (symlink (op->source, dest) != 0) + { + if (errno == EEXIST) + { + char existing[PATH_MAX] = ""; + readlink (dest, existing, sizeof (existing)); + if (strcmp(existing, op->source) == 0) + { + break; + } + die_with_error ("Can't make symlink at %s (existing symlink points to %s)", + op->dest, existing); + } die_with_error ("Can't make symlink at %s", op->dest); + } break; case SETUP_SET_HOSTNAME: