On Tue, 07.10.14 13:35, Jan Synacek (jsyna...@redhat.com) wrote:

> ---
>  src/shared/install.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/src/shared/install.c b/src/shared/install.c
> index fa064c2..945bb27 100644
> --- a/src/shared/install.c
> +++ b/src/shared/install.c
> @@ -1516,6 +1516,19 @@ int unit_file_enable(
>                  return r;
>  
>          STRV_FOREACH(i, files) {
> +                UnitFileState state;
> +
> +                state = unit_file_get_state(scope, root_dir, *i);
> +                if (state < 0) {
> +                        log_error("Failed to get unit file state for %s: 
> %s", *i, strerror(-state));
> +                        return state;
> +                }
> +
> +                if (state == UNIT_FILE_MASKED || state == 
> UNIT_FILE_MASKED_RUNTIME) {
> +                        log_error("Failed to enable unit: Unit %s is 
> masked", *i);
> +                        return -ENOTSUP;
> +                }
> +

Looks mostly OK. However, we should probably use a more useful error
here. Maybe EADDRNOTAVAIL or so. Even better though would be to
actually change the call to take an sd_bus_error argument and then
return a proper error message that can be passed back to the bus
clients with a real explanation.

Logging about this with log_error() is probably not a good idea.

Also, the same logic should be added to unit_file_link() and
unit_file_preset() I figure.

Lennart

-- 
Lennart Poettering, Red Hat
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to