[systemd-devel] [PATCH] condition-util: do not validate condition if paramater is garbage

Lennart Poettering lennart at poettering.net
Mon Aug 18 09:34:24 PDT 2014


On Sat, 16.08.14 14:24, Ronny Chevalier (chevalier.ronny at gmail.com) wrote:

> To follow the same behavior that src/core/condition.c do
> ---
>  src/shared/condition-util.c    | 2 +-
>  src/test/test-condition-util.c | 4 ++++
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/shared/condition-util.c b/src/shared/condition-util.c
> index ff4a8ec..f21786f 100644
> --- a/src/shared/condition-util.c
> +++ b/src/shared/condition-util.c
> @@ -213,7 +213,7 @@ bool condition_test_ac_power(Condition *c) {
>  
>          r = parse_boolean(c->parameter);
>          if (r < 0)
> -                return !c->negate;
> +                return c->negate;

Idon't agree that this would be a good idea. I am pretty sure that if we
cannot make sense of the ac power condition we should return positive by
default, not negative.

That's a bit different form the other conditions, but this is simply
because if don't know let's say a virtualization it's probably a good
idea to assume that we are not running on it. However, if we can't make
sense of an AC state, we should probably assume that we have AC power
and hence say "true"...

Does that make sense?

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list