void *userdata) {
ExecContext *c = data;
- int k;
+ ProtectSystem s;
assert(filename);
assert(lvalue);
/* Our enum shall be a superset of booleans, hence first try
* to parse as boolean, and then as enum */
- k = parse_boolean(rvalue);
- if (k > 0)
- c->protect_system = PROTECT_SYSTEM_YES;
- else if (k == 0)
- c->protect_system = PROTECT_SYSTEM_NO;
- else {
- ProtectSystem s;
-
- s = protect_system_from_string(rvalue);
- if (s < 0) {
- log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse protect system value, ignoring: %s", rvalue);
- return 0;
- }
-
- c->protect_system = s;
+ s = parse_protect_system_or_bool(rvalue);
+ if (s < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse protect system value, ignoring: %s", rvalue);
+ return 0;
}
+ c->protect_system = s;
+
return 0;
}
DEFINE_STRING_TABLE_LOOKUP(protect_system, ProtectSystem);
+ProtectSystem parse_protect_system_or_bool(const char *s) {
+ int r;
+
+ r = parse_boolean(s);
+ if (r > 0)
+ return PROTECT_SYSTEM_YES;
+ if (r == 0)
+ return PROTECT_SYSTEM_NO;
+
+ return protect_system_from_string(s);
+}
+
static const char* const namespace_type_table[] = {
[NAMESPACE_MOUNT] = "mnt",
[NAMESPACE_CGROUP] = "cgroup",
const char* protect_system_to_string(ProtectSystem p) _const_;
ProtectSystem protect_system_from_string(const char *s) _pure_;
+ProtectSystem parse_protect_system_or_bool(const char *s);
void bind_mount_free_many(BindMount *b, unsigned n);
int bind_mount_add(BindMount **b, unsigned *n, const BindMount *item);