mirror of
https://github.com/systemd/systemd.git
synced 2024-11-07 01:27:11 +03:00
namespace: introduce parse_protect_home_or_bool()
This commit is contained in:
parent
77019691cf
commit
5e1c61544c
@ -4365,7 +4365,7 @@ int config_parse_protect_home(
|
|||||||
void *userdata) {
|
void *userdata) {
|
||||||
|
|
||||||
ExecContext *c = data;
|
ExecContext *c = data;
|
||||||
int k;
|
ProtectHome h;
|
||||||
|
|
||||||
assert(filename);
|
assert(filename);
|
||||||
assert(lvalue);
|
assert(lvalue);
|
||||||
@ -4375,23 +4375,14 @@ int config_parse_protect_home(
|
|||||||
/* Our enum shall be a superset of booleans, hence first try
|
/* Our enum shall be a superset of booleans, hence first try
|
||||||
* to parse as boolean, and then as enum */
|
* to parse as boolean, and then as enum */
|
||||||
|
|
||||||
k = parse_boolean(rvalue);
|
h = parse_protect_home_or_bool(rvalue);
|
||||||
if (k > 0)
|
if (h < 0) {
|
||||||
c->protect_home = PROTECT_HOME_YES;
|
log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse protect home value, ignoring: %s", rvalue);
|
||||||
else if (k == 0)
|
return 0;
|
||||||
c->protect_home = PROTECT_HOME_NO;
|
|
||||||
else {
|
|
||||||
ProtectHome h;
|
|
||||||
|
|
||||||
h = protect_home_from_string(rvalue);
|
|
||||||
if (h < 0) {
|
|
||||||
log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse protect home value, ignoring: %s", rvalue);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
c->protect_home = h;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c->protect_home = h;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1450,6 +1450,18 @@ static const char *const protect_home_table[_PROTECT_HOME_MAX] = {
|
|||||||
|
|
||||||
DEFINE_STRING_TABLE_LOOKUP(protect_home, ProtectHome);
|
DEFINE_STRING_TABLE_LOOKUP(protect_home, ProtectHome);
|
||||||
|
|
||||||
|
ProtectHome parse_protect_home_or_bool(const char *s) {
|
||||||
|
int r;
|
||||||
|
|
||||||
|
r = parse_boolean(s);
|
||||||
|
if (r > 0)
|
||||||
|
return PROTECT_HOME_YES;
|
||||||
|
if (r == 0)
|
||||||
|
return PROTECT_HOME_NO;
|
||||||
|
|
||||||
|
return protect_home_from_string(s);
|
||||||
|
}
|
||||||
|
|
||||||
static const char *const protect_system_table[_PROTECT_SYSTEM_MAX] = {
|
static const char *const protect_system_table[_PROTECT_SYSTEM_MAX] = {
|
||||||
[PROTECT_SYSTEM_NO] = "no",
|
[PROTECT_SYSTEM_NO] = "no",
|
||||||
[PROTECT_SYSTEM_YES] = "yes",
|
[PROTECT_SYSTEM_YES] = "yes",
|
||||||
|
@ -101,6 +101,7 @@ int setup_netns(int netns_storage_socket[2]);
|
|||||||
|
|
||||||
const char* protect_home_to_string(ProtectHome p) _const_;
|
const char* protect_home_to_string(ProtectHome p) _const_;
|
||||||
ProtectHome protect_home_from_string(const char *s) _pure_;
|
ProtectHome protect_home_from_string(const char *s) _pure_;
|
||||||
|
ProtectHome parse_protect_home_or_bool(const char *s);
|
||||||
|
|
||||||
const char* protect_system_to_string(ProtectSystem p) _const_;
|
const char* protect_system_to_string(ProtectSystem p) _const_;
|
||||||
ProtectSystem protect_system_from_string(const char *s) _pure_;
|
ProtectSystem protect_system_from_string(const char *s) _pure_;
|
||||||
|
Loading…
Reference in New Issue
Block a user