chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Introduce _cleanup_fdset_free_
[elogind.git]
/
src
/
shared
/
conf-parser.c
diff --git
a/src/shared/conf-parser.c
b/src/shared/conf-parser.c
index 3d14c58d1386718b49fe2ebc8de2d99571452fe3..6085d33391baeb2d4f51e3e017813eabbef57575 100644
(file)
--- a/
src/shared/conf-parser.c
+++ b/
src/shared/conf-parser.c
@@
-70,7
+70,7
@@
int log_syntax_internal(const char *unit, int level,
"ERRNO=%d", error > 0 ? error : EINVAL,
"MESSAGE=[%s:%u] %s", config_file, config_line, msg,
NULL);
"ERRNO=%d", error > 0 ? error : EINVAL,
"MESSAGE=[%s:%u] %s", config_file, config_line, msg,
NULL);
- log_info("logged here: '%s': %d", msg, r);
+
return r;
}
return r;
}
@@
-199,6
+199,7
@@
static int parse_line(const char* unit,
ConfigItemLookup lookup,
void *table,
bool relaxed,
ConfigItemLookup lookup,
void *table,
bool relaxed,
+ bool allow_include,
char **section,
char *l,
void *userdata) {
char **section,
char *l,
void *userdata) {
@@
-219,13
+220,19
@@
static int parse_line(const char* unit,
return 0;
if (startswith(l, ".include ")) {
return 0;
if (startswith(l, ".include ")) {
- _cleanup_free_ char *fn;
+ _cleanup_free_ char *fn = NULL;
+
+ if (!allow_include) {
+ log_syntax(unit, LOG_ERR, filename, line, EBADMSG,
+ ".include not allowed here. Ignoring.");
+ return 0;
+ }
fn = file_in_same_dir(filename, strstrip(l+9));
if (!fn)
return -ENOMEM;
fn = file_in_same_dir(filename, strstrip(l+9));
if (!fn)
return -ENOMEM;
- return config_parse(unit, fn, NULL, sections, lookup, table, relaxed, userdata);
+ return config_parse(unit, fn, NULL, sections, lookup, table, relaxed,
false,
userdata);
}
if (*l == '[') {
}
if (*l == '[') {
@@
-299,11
+306,12
@@
int config_parse(const char *unit,
ConfigItemLookup lookup,
void *table,
bool relaxed,
ConfigItemLookup lookup,
void *table,
bool relaxed,
+ bool allow_include,
void *userdata) {
void *userdata) {
- unsigned line = 0;
_cleanup_free_ char *section = NULL, *continuation = NULL;
_cleanup_fclose_ FILE *ours = NULL;
_cleanup_free_ char *section = NULL, *continuation = NULL;
_cleanup_fclose_ FILE *ours = NULL;
+ unsigned line = 0;
int r;
assert(filename);
int r;
assert(filename);
@@
-370,6
+378,7
@@
int config_parse(const char *unit,
lookup,
table,
relaxed,
lookup,
table,
relaxed,
+ allow_include,
§ion,
p,
userdata);
§ion,
p,
userdata);
@@
-590,6
+599,7
@@
int config_parse_path(const char *unit,
char **s = data;
char *n;
char **s = data;
char *n;
+ int offset;
assert(filename);
assert(lvalue);
assert(filename);
assert(lvalue);
@@
-602,7
+612,9
@@
int config_parse_path(const char *unit,
return 0;
}
return 0;
}
- if (!path_is_absolute(rvalue)) {
+ offset = rvalue[0] == '-' && (streq(lvalue, "InaccessibleDirectories") ||
+ streq(lvalue, "ReadOnlyDirectories"));
+ if (!path_is_absolute(rvalue + offset)) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Not an absolute path, ignoring: %s", rvalue);
return 0;
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Not an absolute path, ignoring: %s", rvalue);
return 0;
@@
-704,6
+716,7
@@
int config_parse_path_strv(const char *unit,
FOREACH_WORD_QUOTED(w, l, rvalue, state) {
_cleanup_free_ char *n;
FOREACH_WORD_QUOTED(w, l, rvalue, state) {
_cleanup_free_ char *n;
+ int offset;
n = strndup(w, l);
if (!n)
n = strndup(w, l);
if (!n)
@@
-715,7
+728,9
@@
int config_parse_path_strv(const char *unit,
continue;
}
continue;
}
- if (!path_is_absolute(n)) {
+ offset = n[0] == '-' && (streq(lvalue, "InaccessibleDirectories") ||
+ streq(lvalue, "ReadOnlyDirectories"));
+ if (!path_is_absolute(n + offset)) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Not an absolute path, ignoring: %s", rvalue);
continue;
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Not an absolute path, ignoring: %s", rvalue);
continue;