X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fmount.c;h=ec90b0a6708184a7ffe3ccd63ecb48d177e77f3c;hp=39a9aaf2a0bf35e0ff333c9d0116a7512db6002c;hb=06b643e7f5a3b79005dd57497897ab7255fe3659;hpb=b24de9d21d30245b66d8d6b869c575b48ddb6068 diff --git a/src/core/mount.c b/src/core/mount.c index 39a9aaf2a..ec90b0a67 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -827,6 +827,23 @@ void warn_if_dir_nonempty(const char *unit, const char* where) { NULL); } +static int fail_if_symlink(const char *unit, const char* where) { + assert(where); + + if (is_symlink(where) > 0) { + log_struct_unit(LOG_WARNING, + unit, + "MESSAGE=%s: Mount on symlink %s not allowed.", + unit, where, + "WHERE=%s", where, + MESSAGE_ID(SD_MESSAGE_OVERMOUNTING), + NULL); + + return -ELOOP; + } + return 0; +} + static void mount_enter_unmounting(Mount *m) { int r; @@ -877,6 +894,10 @@ static void mount_enter_mounting(Mount *m) { if (p && mount_is_bind(p)) mkdir_p_label(p->what, m->directory_mode); + r = fail_if_symlink(m->meta.id, m->where); + if (r < 0) + goto fail; + if (m->from_fragment) r = exec_command_set( m->control_command,