summaryrefslogtreecommitdiff
path: root/src/core/mount.c
diff options
context:
space:
mode:
authorTimofey Titovets <nefelim4ag@gmail.com>2014-08-15 02:05:47 +0300
committerLennart Poettering <lennart@poettering.net>2014-08-15 01:35:28 +0200
commit5261ba901845c084de5a8fd06500ed09bfb0bd80 (patch)
treeaf5f9a6d0606bd05fe0b1fe95a7e9354957f29b9 /src/core/mount.c
parent1bd27a45d04639190fc91ad2552b72ea759c0c27 (diff)
core: Refuse mount on symlink
Diffstat (limited to 'src/core/mount.c')
-rw-r--r--src/core/mount.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/core/mount.c b/src/core/mount.c
index 39a9aaf2a0..ec90b0a670 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,