X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fload-fragment.c;h=6759255984288fe350101f0552bc46f2add75d2a;hp=580304417876d0af9ed3881cde6c2507b687ddd8;hb=bb11271068ff34434f5b8cefd0c2c0bae5ed7fd1;hpb=f8b69d1dfc307562a353f6aa923b7c2b915aaddb diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 580304417..675925598 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -4,6 +4,7 @@ This file is part of systemd. Copyright 2010 Lennart Poettering + Copyright 2012 Holger Hans Peter Freyther systemd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -438,6 +439,7 @@ int config_parse_exec( e += ltype; for (;;) { + int i; char *w; size_t l; char *state; @@ -452,18 +454,21 @@ int config_parse_exec( if (rvalue[0] == 0) break; - if (rvalue[0] == '-') { - ignore = true; - rvalue ++; - } + for (i = 0; i < 2; i++) { + if (rvalue[0] == '-' && !ignore) { + ignore = true; + rvalue ++; + } - if (rvalue[0] == '@') { - honour_argv0 = true; - rvalue ++; + if (rvalue[0] == '@' && !honour_argv0) { + honour_argv0 = true; + rvalue ++; + } } if (*rvalue != '/') { - log_error("[%s:%u] Invalid executable path in command line, ignoring: %s", filename, line, rvalue); + log_error("[%s:%u] Executable path is not absolute, ignoring: %s", + filename, line, rvalue); return 0; } @@ -483,6 +488,8 @@ int config_parse_exec( FOREACH_WORD_QUOTED(w, l, rvalue, state) { if (strncmp(w, ";", MAX(l, 1U)) == 0) break; + else if (strncmp(w, "\\;", MAX(l, 1U)) == 0) + w ++; if (honour_argv0 && w == rvalue) { assert(!path); @@ -683,6 +690,8 @@ int config_parse_exec_cpu_sched_policy( } c->cpu_sched_policy = x; + /* Moving to or from real-time policy? We need to adjust the priority */ + c->cpu_sched_priority = CLAMP(c->cpu_sched_priority, sched_get_priority_min(x), sched_get_priority_max(x)); c->cpu_sched_set = true; return 0; @@ -699,19 +708,28 @@ int config_parse_exec_cpu_sched_prio( void *userdata) { ExecContext *c = data; - int i; + int i, min, max; assert(filename); assert(lvalue); assert(rvalue); assert(data); - /* On Linux RR/FIFO have the same range */ - if (safe_atoi(rvalue, &i) < 0 || i < sched_get_priority_min(SCHED_RR) || i > sched_get_priority_max(SCHED_RR)) { + if (safe_atoi(rvalue, &i) < 0) { log_error("[%s:%u] Failed to parse CPU scheduling priority, ignoring: %s", filename, line, rvalue); return 0; } + + /* On Linux RR/FIFO range from 1 to 99 and OTHER/BATCH may only be 0 */ + min = sched_get_priority_min(c->cpu_sched_policy); + max = sched_get_priority_max(c->cpu_sched_policy); + + if (i < min || i > max) { + log_error("[%s:%u] CPU scheduling priority is out of range, ignoring: %s", filename, line, rvalue); + return 0; + } + c->cpu_sched_priority = i; c->cpu_sched_set = true;