return sd_bus_message_append(reply, "i", LOG_FAC(c->syslog_priority));
}
-static int property_get_input_fdname(
+static int property_get_stdio_fdname(
sd_bus *bus,
const char *path,
const char *interface,
sd_bus_error *error) {
ExecContext *c = userdata;
- const char *name;
+ int fileno;
assert(bus);
assert(c);
assert(property);
assert(reply);
- name = exec_context_fdname(c, STDIN_FILENO);
-
- return sd_bus_message_append(reply, "s", name);
-}
-
-static int property_get_output_fdname(
- sd_bus *bus,
- const char *path,
- const char *interface,
- const char *property,
- sd_bus_message *reply,
- void *userdata,
- sd_bus_error *error) {
-
- ExecContext *c = userdata;
- const char *name = NULL;
-
- assert(bus);
- assert(c);
- assert(property);
- assert(reply);
-
- if (c->std_output == EXEC_OUTPUT_NAMED_FD && streq(property, "StandardOutputFileDescriptorName"))
- name = exec_context_fdname(c, STDOUT_FILENO);
- else if (c->std_error == EXEC_OUTPUT_NAMED_FD && streq(property, "StandardErrorFileDescriptorName"))
- name = exec_context_fdname(c, STDERR_FILENO);
+ if (streq(property, "StandardInputFileDescriptorName"))
+ fileno = STDIN_FILENO;
+ else if (streq(property, "StandardOutputFileDescriptorName"))
+ fileno = STDOUT_FILENO;
+ else {
+ assert(streq(property, "StandardErrorFileDescriptorName"));
+ fileno = STDERR_FILENO;
+ }
- return sd_bus_message_append(reply, "s", name);
+ return sd_bus_message_append(reply, "s", exec_context_fdname(c, fileno));
}
static int property_get_input_data(
SD_BUS_PROPERTY("CPUSchedulingResetOnFork", "b", bus_property_get_bool, offsetof(ExecContext, cpu_sched_reset_on_fork), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("NonBlocking", "b", bus_property_get_bool, offsetof(ExecContext, non_blocking), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("StandardInput", "s", property_get_exec_input, offsetof(ExecContext, std_input), SD_BUS_VTABLE_PROPERTY_CONST),
- SD_BUS_PROPERTY("StandardInputFileDescriptorName", "s", property_get_input_fdname, 0, SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("StandardInputFileDescriptorName", "s", property_get_stdio_fdname, 0, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("StandardInputData", "ay", property_get_input_data, 0, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("StandardOutput", "s", bus_property_get_exec_output, offsetof(ExecContext, std_output), SD_BUS_VTABLE_PROPERTY_CONST),
- SD_BUS_PROPERTY("StandardOutputFileDescriptorName", "s", property_get_output_fdname, 0, SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("StandardOutputFileDescriptorName", "s", property_get_stdio_fdname, 0, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("StandardError", "s", bus_property_get_exec_output, offsetof(ExecContext, std_error), SD_BUS_VTABLE_PROPERTY_CONST),
- SD_BUS_PROPERTY("StandardErrorFileDescriptorName", "s", property_get_output_fdname, 0, SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("StandardErrorFileDescriptorName", "s", property_get_stdio_fdname, 0, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("TTYPath", "s", NULL, offsetof(ExecContext, tty_path), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("TTYReset", "b", bus_property_get_bool, offsetof(ExecContext, tty_reset), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("TTYVHangup", "b", bus_property_get_bool, offsetof(ExecContext, tty_vhangup), SD_BUS_VTABLE_PROPERTY_CONST),
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid file descriptor name");
if (mode != UNIT_CHECK) {
+
if (streq(name, "StandardInputFileDescriptorName")) {
c->std_input = EXEC_INPUT_NAMED_FD;
r = free_and_strdup(&c->stdio_fdname[STDIN_FILENO], s);
if (r < 0)
return r;
+
unit_write_drop_in_private_format(u, mode, name, "StandardInput=fd:%s", s);
+
} else if (streq(name, "StandardOutputFileDescriptorName")) {
c->std_output = EXEC_OUTPUT_NAMED_FD;
r = free_and_strdup(&c->stdio_fdname[STDOUT_FILENO], s);
if (r < 0)
return r;
+
unit_write_drop_in_private_format(u, mode, name, "StandardOutput=fd:%s", s);
+
} else if (streq(name, "StandardErrorFileDescriptorName")) {
c->std_error = EXEC_OUTPUT_NAMED_FD;
r = free_and_strdup(&c->stdio_fdname[STDERR_FILENO], s);
if (r < 0)
return r;
+
unit_write_drop_in_private_format(u, mode, name, "StandardError=fd:%s", s);
}
}