core: allow to specify errno number in SystemCallErrorNumber=
This commit is contained in:
@@ -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
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user