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

Ronny Chevalier chevalier.ronny at gmail.com
Mon Aug 18 11:33:07 PDT 2014


2014-08-18 18:34 GMT+02:00 Lennart Poettering <lennart at poettering.net>:
> 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?
Both make sense for me, there is no good thing to assume for this, but
I just thought that the same behaviour should be followed and document
about it maybe.

By the way, there is a couple of places, like this one, where we
should add a warning when we could not parse the boolean, I think.

>
> Lennart
>
> --
> Lennart Poettering, Red Hat


More information about the systemd-devel mailing list