[systemd-devel] [PATCH v3] Refuse mount on symlink

Lennart Poettering lennart at poettering.net
Thu Aug 14 16:00:33 PDT 2014


On Fri, 15.08.14 01:43, Timofey Titovets (nefelim4ag at gmail.com) wrote:

> 
> +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;
> +}

Looks good, but the patch is line broken, I can't apply it like
that... Maybe attach the patch?

> diff --git a/src/core/mount.h b/src/core/mount.h
> index 2dcb663..5fc1fe1 100644
> --- a/src/core/mount.h
> +++ b/src/core/mount.h
> @@ -128,3 +128,5 @@ const char* mount_result_to_string(MountResult
> i) _const_;
>  MountResult mount_result_from_string(const char *s) _pure_;
> 
>  void warn_if_dir_nonempty(const char *unit, const char* where);
> +
> +int fail_if_symlink(const char *unit, const char* where);

No reason to export this, or am I missing something? Just make the
function static, and don't include it in the header file, unless some
other .c file is actually using it.

Otherwise looks good.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list