core: allow to specify errno number in SystemCallErrorNumber=

This commit is contained in:
Yu Watanabe
2017-11-11 21:54:24 +09:00
parent b4891260b9
commit 3df90f24cc
5 changed files with 22 additions and 21 deletions
+2 -4
View File
@@ -1334,20 +1334,18 @@ int bus_exec_context_set_transient_property(
} else if (streq(name, "SystemCallErrorNumber")) {
int32_t n;
const char *str;
r = sd_bus_message_read(message, "i", &n);
if (r < 0)
return r;
str = errno_to_name(n);
if (!str)
if (n <= 0 || n > ERRNO_MAX)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid SystemCallErrorNumber");
if (mode != UNIT_CHECK) {
c->syscall_errno = n;
unit_write_drop_in_private_format(u, mode, name, "SystemCallErrorNumber=%s", str);
unit_write_drop_in_private_format(u, mode, name, "SystemCallErrorNumber=%d", n);
}
return 1;
+11 -4
View File
@@ -4129,10 +4129,17 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
prefix, s);
}
if (c->syscall_errno > 0)
fprintf(f,
"%sSystemCallErrorNumber: %s\n",
prefix, strna(errno_to_name(c->syscall_errno)));
if (c->syscall_errno > 0) {
const char *errno_name;
fprintf(f, "%sSystemCallErrorNumber: ", prefix);
errno_name = errno_to_name(c->syscall_errno);
if (errno_name)
fprintf(f, "%s\n", errno_name);
else
fprintf(f, "%d\n", c->syscall_errno);
}
if (c->apparmor_profile)
fprintf(f,
+2 -2
View File
@@ -2839,8 +2839,8 @@ int config_parse_syscall_errno(
return 0;
}
e = errno_from_name(rvalue);
if (e < 0) {
e = parse_errno(rvalue);
if (e <= 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse error number, ignoring: %s", rvalue);
return 0;
}