static bool arg_remain_after_exit = false;
static const char *arg_unit = NULL;
static const char *arg_description = NULL;
static const char *arg_slice = NULL;
static bool arg_send_sighup = false;
static bool arg_remain_after_exit = false;
static const char *arg_unit = NULL;
static const char *arg_description = NULL;
static const char *arg_slice = NULL;
static bool arg_send_sighup = false;
" -h --help Show this help\n"
" --version Show package version\n"
" --user Run as user unit\n"
" -h --help Show this help\n"
" --version Show package version\n"
" --user Run as user unit\n"
" --scope Run this as scope rather than service\n"
" --unit=UNIT Run under the specified unit name\n"
" --description=TEXT Description for unit\n"
" --scope Run this as scope rather than service\n"
" --unit=UNIT Run under the specified unit name\n"
" --description=TEXT Description for unit\n"
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, ARG_VERSION },
{ "user", no_argument, NULL, ARG_USER },
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, ARG_VERSION },
{ "user", no_argument, NULL, ARG_USER },
{ "scope", no_argument, NULL, ARG_SCOPE },
{ "unit", required_argument, NULL, ARG_UNIT },
{ "description", required_argument, NULL, ARG_DESCRIPTION },
{ "slice", required_argument, NULL, ARG_SLICE },
{ "remain-after-exit", no_argument, NULL, 'r' },
{ "send-sighup", no_argument, NULL, ARG_SEND_SIGHUP },
{ "scope", no_argument, NULL, ARG_SCOPE },
{ "unit", required_argument, NULL, ARG_UNIT },
{ "description", required_argument, NULL, ARG_DESCRIPTION },
{ "slice", required_argument, NULL, ARG_SLICE },
{ "remain-after-exit", no_argument, NULL, 'r' },
{ "send-sighup", no_argument, NULL, ARG_SEND_SIGHUP },
+ { "host", required_argument, NULL, 'H' },
+ { "machine", required_argument, NULL, 'M' },
+ {},
- while ((c = getopt_long(argc, argv, "+hr", options, NULL)) >= 0) {
+ while ((c = getopt_long(argc, argv, "+hrH:M:", options, NULL)) >= 0) {
+ if (arg_user && arg_transport != BUS_TRANSPORT_LOCAL) {
+ log_error("Execution in user context is not supported on non-local systems.");
+ return -EINVAL;
+ }
+
+ if (arg_scope && arg_transport != BUS_TRANSPORT_LOCAL) {
+ log_error("Scope execution is not supported on non-local systems.");
+ return -EINVAL;
+ }
+
r = find_binary(argv[optind], &command);
if (r < 0) {
log_error("Failed to find executable %s: %s", argv[optind], strerror(-r));
r = find_binary(argv[optind], &command);
if (r < 0) {
log_error("Failed to find executable %s: %s", argv[optind], strerror(-r));
- if (arg_user)
- r = sd_bus_open_user(&bus);
- else
- r = sd_bus_open_system(&bus);
+ r = bus_open_transport(arg_transport, arg_host, arg_user, &bus);
if (r < 0) {
log_error("Failed start transient unit: %s", error.message ? error.message : strerror(-r));
sd_bus_error_free(&error);
if (r < 0) {
log_error("Failed start transient unit: %s", error.message ? error.message : strerror(-r));
sd_bus_error_free(&error);