1
0
mirror of https://github.com/systemd/systemd synced 2026-02-25 16:54:44 +01:00

Compare commits

..

No commits in common. "3c47dc76bef2dd64e2f32c7a864ce089156c72c6" and "e48b6fca76ae1105e6305b3f3c1c15c4c42639ef" have entirely different histories.

26 changed files with 167 additions and 253 deletions

7
NEWS
View File

@ -172,10 +172,9 @@ CHANGES WITH 260 in spe:
RouteMetric=, and UseGateway= settings. This allows systemd-networkd
to establish a cellular modem connection to a broadband network.
* systemd-networkd gained a pair of varlink methods
io.systemd.Network.Link.Up()/Down(). networkctl up/down now utilizes
the new varlink interfaces in place of direct RTNL message for better
interaction with networkd.
* systemd-networkd gained a pair of varlink methods LinkUp()/LinkDown().
networkctl up/down now utilizes the new varlink interfaces in place
of direct RTNL message for better interaction with networkd.
Changes in systemd-boot and the stub:

3
TODO
View File

@ -121,9 +121,6 @@ Deprecations and removals:
Features:
* sd-lldp: pick up 802.3 maximum frame size/mtu, to be able to detect jumbo
frame capable networks
* networkd: maintain a file in /run/ that can be symlinked into /run/issue.d/
that always shows the current primary IP address

View File

@ -168,13 +168,11 @@
<option>MaxUse=</option> makes
sure that old core dumps are removed as soon as the total disk
space taken up by core dumps grows beyond this limit (defaults
to 10% of the total disk size, capped at 4GiB, minimum 1MiB).
<option>KeepFree=</option> controls how much disk space to keep
free at least (defaults to 15% of the total disk size, limited
to a maximum of 4GiB). Note that the disk space used
to 10% of the total disk size). <option>KeepFree=</option>
controls how much disk space to keep free at least (defaults
to 15% of the total disk size). Note that the disk space used
by core dumps might temporarily exceed these limits while
core dumps are processed. <option>MaxUse=</option> takes precedence.
Note that old core dumps are also
core dumps are processed. Note that old core dumps are also
removed based on time via
<citerefentry><refentrytitle>systemd-tmpfiles</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
Set either value to 0 to turn off size-based cleanup.</para>

View File

@ -499,20 +499,6 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
do not document that. -->
</listitem>
</varlistentry>
<varlistentry>
<term><command>enqueue-marked-jobs</command></term>
<listitem><para>Enqueue start/stop/restart/reload jobs for all units that have the respective
<literal>needs-*</literal> markers set. When a unit marked for reload does not support reload,
restart will be queued. Those properties can be set using <command>set-property Markers=…</command>.</para>
<para>Unless <option>--no-block</option> is used, <command>systemctl</command> will wait for the
queued jobs to finish.</para>
<xi:include href="version-info.xml" xpointer="v260"/></listitem>
</varlistentry>
<varlistentry>
<term><command>reload-or-restart <replaceable>PATTERN</replaceable></command></term>
@ -520,8 +506,8 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
<para>Reload one or more units if they support it. If not, stop and then start them instead. If the units
are not running yet, they will be started.</para>
<para>When used in combination with <option>--marked</option>, it is a deprecated alias of
<command>enqueue-marked-jobs</command>.</para>
<para>This has a slightly differing functionality when used in combination with <option>--marked</option>,
see below.</para>
</listitem>
</varlistentry>
<varlistentry>
@ -2866,6 +2852,20 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
<xi:include href="version-info.xml" xpointer="v248"/></listitem>
</varlistentry>
<varlistentry>
<term><option>--marked</option></term>
<listitem><para>Only allowed with <command>reload-or-restart</command>, <command>start</command>, or
<command>stop</command>. Enqueues jobs for all units that are marked. When a unit marked for reload
does not support reload, restart will be queued. Those properties can be set using
<command>set-property Markers=…</command>.</para>
<para>Unless <option>--no-block</option> is used, <command>systemctl</command> will wait for the
queued jobs to finish.</para>
<xi:include href="version-info.xml" xpointer="v248"/></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-only</option></term>

View File

@ -18,5 +18,3 @@ Property=ID_NET_AUTO_LINK_LOCAL_ONLY=1
LinkLocalAddressing=yes
IPv6AcceptRA=no
MulticastDNS=yes
LLDP=yes
EmitLLDP=yes

View File

@ -134,7 +134,7 @@ _systemctl () {
--help -h --no-ask-password --no-block --legend=no --no-pager --no-reload --no-wall --now
--quiet -q --system --user --version --runtime --recursive -r --firmware-setup
--show-types --plain --failed --value --fail --dry-run --wait --no-warn --with-dependencies
--show-transaction -T --mkdir --read-only'
--show-transaction -T --mkdir --marked --read-only'
[ARG]='--host -H --kill-whom --property -p -P --signal -s --type -t --state --job-mode --root
--preset-mode -n --lines -o --output -M --machine --message --timestamp --check-inhibitors --what
--image --boot-loader-menu --boot-loader-entry --reboot-argument --drop-in'
@ -233,8 +233,7 @@ _systemctl () {
suspend-then-hibernate kexec soft-reboot list-jobs list-sockets
list-timers list-units list-unit-files poweroff
reboot rescue show-environment suspend get-default
is-system-running preset-all list-automounts list-paths
enqueue-marked-jobs'
is-system-running preset-all list-automounts list-paths'
[FILE]='link switch-root'
[TARGETS]='set-default'
[MACHINES]='list-machines'

View File

@ -310,6 +310,7 @@ static int help(int argc, char *argv[], void *userdata) {
" --debugger=DEBUGGER Use the given debugger\n"
" -A --debugger-arguments=ARGS\n"
" Pass the given arguments to the debugger\n"
"\nSee the %2$s for details.\n",
program_invocation_short_name,
link,

View File

@ -3,7 +3,6 @@
#include "sd-json.h"
#include "bitfield.h"
#include "bus-polkit.h"
#include "cgroup.h"
#include "condition.h"
#include "dbus-job.h"
@ -668,19 +667,6 @@ int vl_method_set_unit_properties(sd_varlink *link, sd_json_variant *parameters,
if (r < 0)
return r;
r = mac_selinux_unit_access_check_varlink(unit, link, "start");
if (r < 0)
return sd_varlink_error(link, SD_VARLINK_ERROR_PERMISSION_DENIED, NULL);
r = varlink_verify_polkit_async(
link,
manager->system_bus,
"org.freedesktop.systemd1.manage-units",
/* details= */ NULL,
&manager->polkit_registry);
if (r <= 0)
return r;
if (p.markers_found)
unit->markers = unit_normalize_markers((unit->markers & ~p.markers_mask), p.markers);

View File

@ -997,7 +997,7 @@ static int oci_pull_save_nspawn_settings(OciPull *i) {
return log_oom();
_cleanup_free_ char *j = path_join(i->image_root, fn);
if (!j)
if (!fn)
return log_oom();
_cleanup_fclose_ FILE *f = NULL;
@ -1085,7 +1085,7 @@ static int oci_pull_save_oci_config(OciPull *i) {
return log_oom();
_cleanup_free_ char *j = path_join(i->image_root, fn);
if (!j)
if (!fn)
return log_oom();
_cleanup_close_ int fd = -EBADF;
@ -1116,7 +1116,7 @@ static int oci_pull_save_mstack(OciPull *i) {
return log_oom();
_cleanup_free_ char *j = path_join(i->image_root, dn);
if (!j)
if (!dn)
return log_oom();
log_notice("Creating '%s'", j);

View File

@ -3,7 +3,6 @@
#include <fcntl.h>
#include <unistd.h>
#include "sd-daemon.h"
#include "sd-event.h"
#include "capability-util.h"
@ -467,10 +466,6 @@ TEST(sd_device_enumerator_filter_subsystem) {
return;
}
/* The rest of this test depends on a full booted system with a working udev and so on */
if (!sd_booted())
return (void) log_tests_skipped("Test requires fully booted system with udev/etc, skipping to avoid hanging forever.");
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
ASSERT_OK(sd_event_default(&event));
ASSERT_OK(sd_event_add_inotify(event, NULL, "/run/udev" , IN_DELETE, on_inotify, NULL));

View File

@ -331,6 +331,7 @@ static int process_timeout(sd_netlink *nl) {
static int process_reply(sd_netlink *nl, sd_netlink_message *m) {
struct reply_callback *c;
sd_netlink_slot *slot;
uint32_t serial;
uint16_t type;
int r;
@ -353,8 +354,7 @@ static int process_reply(sd_netlink *nl, sd_netlink_message *m) {
if (type == NLMSG_DONE)
m = NULL;
_cleanup_(sd_netlink_slot_unrefp) sd_netlink_slot *slot =
sd_netlink_slot_ref(container_of(c, sd_netlink_slot, reply_callback));
slot = container_of(c, sd_netlink_slot, reply_callback);
r = c->callback(nl, m, slot->userdata);
if (r < 0)

View File

@ -280,7 +280,7 @@ _public_ int sd_varlink_connect_exec(sd_varlink **ret, const char *_command, cha
}
execvp(command, argv);
log_debug_errno(errno, "Failed to invoke process '%s': %m", command);
log_debug_errno(r, "Failed to invoke process '%s': %m", command);
_exit(EXIT_FAILURE);
}
@ -4055,11 +4055,9 @@ _public_ int sd_varlink_server_shutdown(sd_varlink_server *s) {
static void varlink_server_test_exit_on_idle(sd_varlink_server *s) {
assert(s);
if (s->exit_on_idle && s->event && s->n_connections == 0) {
varlink_server_log(s, "Exit-on-idle triggered.");
if (s->exit_on_idle && s->event && s->n_connections == 0)
(void) sd_event_exit(s->event, 0);
}
}
_public_ int sd_varlink_server_set_exit_on_idle(sd_varlink_server *s, int b) {
assert_return(s, -EINVAL);

View File

@ -59,7 +59,6 @@ systemd_networkd_extract_sources = files(
'networkd-ipv6ll.c',
'networkd-json.c',
'networkd-link-bus.c',
'networkd-link-varlink.c',
'networkd-link.c',
'networkd-lldp-rx.c',
'networkd-lldp-tx.c',

View File

@ -67,7 +67,7 @@ int link_up_down(int argc, char *argv[], void *userdata) {
ORDERED_SET_FOREACH(p, indexes)
RET_GATHER(ret, varlink_callbo_and_log(
vl,
up ? "io.systemd.Network.Link.Up" : "io.systemd.Network.Link.Down",
up ? "io.systemd.Network.LinkUp" : "io.systemd.Network.LinkDown",
/* reply= */ NULL,
SD_JSON_BUILD_PAIR_INTEGER("InterfaceIndex", PTR_TO_INT(p)),
SD_JSON_BUILD_PAIR_BOOLEAN("allowInteractiveAuthentication", arg_ask_password)));

View File

@ -1,102 +0,0 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sd-varlink.h"
#include "bus-polkit.h"
#include "json-util.h"
#include "networkd-link.h"
#include "networkd-link-varlink.h"
#include "networkd-manager.h"
#include "networkd-setlink.h"
int dispatch_link(sd_varlink *vlink, sd_json_variant *parameters, Manager *manager, DispatchLinkFlag flags, Link **ret) {
struct {
int ifindex;
const char *ifname;
} info = {};
Link *link = NULL;
int r;
static const sd_json_dispatch_field dispatch_table[] = {
{ "InterfaceIndex", _SD_JSON_VARIANT_TYPE_INVALID, json_dispatch_ifindex, voffsetof(info, ifindex), SD_JSON_RELAX },
{ "InterfaceName", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, voffsetof(info, ifname), 0 },
{}
}, dispatch_polkit_table[] = {
{ "InterfaceIndex", _SD_JSON_VARIANT_TYPE_INVALID, json_dispatch_ifindex, voffsetof(info, ifindex), SD_JSON_RELAX },
{ "InterfaceName", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, voffsetof(info, ifname), 0 },
VARLINK_DISPATCH_POLKIT_FIELD,
{}
};
assert(vlink);
assert(manager);
assert(ret);
r = sd_varlink_dispatch(
vlink,
parameters,
FLAGS_SET(flags, DISPATCH_LINK_POLKIT) ? dispatch_polkit_table : dispatch_table,
&info);
if (r != 0)
return r;
if (info.ifindex < 0)
return sd_varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("InterfaceIndex"));
if (info.ifindex > 0 && link_get_by_index(manager, info.ifindex, &link) < 0)
return sd_varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("InterfaceIndex"));
if (info.ifname) {
Link *link_by_name;
if (link_get_by_name(manager, info.ifname, &link_by_name) < 0)
return sd_varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("InterfaceName"));
if (link && link_by_name != link)
/* If both arguments are specified, then these must be consistent. */
return sd_varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("InterfaceName"));
link = link_by_name;
}
if (!link && FLAGS_SET(flags, DISPATCH_LINK_MANDATORY))
return sd_varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("InterfaceIndex"));
/* If the DISPATCH_LINK_MANDATORY flag is not set, this function may return NULL. */
*ret = link;
return 0;
}
static int vl_method_link_up_or_down(sd_varlink *vlink, sd_json_variant *parameters, Manager *manager, bool up) {
Link *link;
int r;
assert(vlink);
assert(manager);
r = dispatch_link(vlink, parameters, manager, DISPATCH_LINK_POLKIT | DISPATCH_LINK_MANDATORY, &link);
if (r != 0)
return r;
r = varlink_verify_polkit_async(
vlink,
manager->bus,
"org.freedesktop.network1.manage-links",
/* details= */ NULL,
&manager->polkit_registry);
if (r <= 0)
return r;
if (!up)
/* Stop all network engines while interface is still up to allow proper cleanup,
* e.g. sending IPv6 shutdown RA messages before the interface is brought down. */
(void) link_stop_engines(link, /* may_keep_dynamic = */ false);
return link_up_or_down_now_by_varlink(link, up, vlink);
}
int vl_method_link_up(sd_varlink *vlink, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
return vl_method_link_up_or_down(vlink, parameters, userdata, /* up= */ true);
}
int vl_method_link_down(sd_varlink *vlink, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
return vl_method_link_up_or_down(vlink, parameters, userdata, /* up= */ false);
}

View File

@ -1,14 +0,0 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "networkd-forward.h"
typedef enum DispatchLinkFlag {
DISPATCH_LINK_POLKIT = 1 << 0,
DISPATCH_LINK_MANDATORY = 1 << 1,
} DispatchLinkFlag;
int dispatch_link(sd_varlink *vlink, sd_json_variant *parameters, Manager *manager, DispatchLinkFlag flags, Link **ret);
int vl_method_link_up(sd_varlink *vlink, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata);
int vl_method_link_down(sd_varlink *vlink, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata);

View File

@ -14,12 +14,11 @@
#include "networkd-dhcp-server.h"
#include "networkd-json.h"
#include "networkd-link.h"
#include "networkd-link-varlink.h"
#include "networkd-manager.h"
#include "networkd-manager-varlink.h"
#include "networkd-setlink.h"
#include "stat-util.h"
#include "varlink-io.systemd.Network.h"
#include "varlink-io.systemd.Network.Link.h"
#include "varlink-io.systemd.service.h"
#include "varlink-util.h"
@ -94,6 +93,55 @@ static int vl_method_get_namespace_id(sd_varlink *link, sd_json_variant *paramet
SD_JSON_BUILD_PAIR_CONDITION(nsid != UINT32_MAX, "NamespaceNSID", SD_JSON_BUILD_UNSIGNED(nsid)));
}
static int dispatch_interface(sd_varlink *vlink, sd_json_variant *parameters, Manager *manager, bool polkit, Link **ret) {
struct {
int ifindex;
const char *ifname;
} info = {};
Link *link = NULL;
int r;
static const sd_json_dispatch_field dispatch_table[] = {
{ "InterfaceIndex", _SD_JSON_VARIANT_TYPE_INVALID, json_dispatch_ifindex, voffsetof(info, ifindex), SD_JSON_RELAX },
{ "InterfaceName", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, voffsetof(info, ifname), 0 },
{}
}, dispatch_polkit_table[] = {
{ "InterfaceIndex", _SD_JSON_VARIANT_TYPE_INVALID, json_dispatch_ifindex, voffsetof(info, ifindex), SD_JSON_RELAX },
{ "InterfaceName", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, voffsetof(info, ifname), 0 },
VARLINK_DISPATCH_POLKIT_FIELD,
{}
};
assert(vlink);
assert(manager);
assert(ret);
r = sd_varlink_dispatch(vlink, parameters, polkit ? dispatch_polkit_table : dispatch_table, &info);
if (r != 0)
return r;
if (info.ifindex < 0)
return sd_varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("InterfaceIndex"));
if (info.ifindex > 0 && link_get_by_index(manager, info.ifindex, &link) < 0)
return sd_varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("InterfaceIndex"));
if (info.ifname) {
Link *link_by_name;
if (link_get_by_name(manager, info.ifname, &link_by_name) < 0)
return sd_varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("InterfaceName"));
if (link && link_by_name != link)
/* If both arguments are specified, then these must be consistent. */
return sd_varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("InterfaceName"));
link = link_by_name;
}
/* If neither InterfaceIndex nor InterfaceName specified, this function returns NULL. */
*ret = link;
return 0;
}
static int link_append_lldp_neighbors(Link *link, sd_json_variant *v, sd_json_variant **array) {
assert(link);
assert(array);
@ -115,7 +163,7 @@ static int vl_method_get_lldp_neighbors(sd_varlink *vlink, sd_json_variant *para
assert(vlink);
assert(manager);
r = dispatch_link(vlink, parameters, manager, /* flags= */ 0, &link);
r = dispatch_interface(vlink, parameters, manager, /* polkit= */ false, &link);
if (r != 0)
return r;
@ -236,6 +284,46 @@ static int vl_method_set_persistent_storage(sd_varlink *vlink, sd_json_variant *
return sd_varlink_reply(vlink, NULL);
}
static int vl_method_link_up_or_down(sd_varlink *vlink, sd_json_variant *parameters, Manager *manager, bool up) {
Link *link;
int r;
assert(vlink);
assert(manager);
r = dispatch_interface(vlink, parameters, manager, /* polkit= */ true, &link);
if (r != 0)
return r;
/* Require a specific link to be specified. */
if (!link)
return sd_varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("InterfaceIndex"));
r = varlink_verify_polkit_async(
vlink,
manager->bus,
"org.freedesktop.network1.manage-links",
/* details= */ NULL,
&manager->polkit_registry);
if (r <= 0)
return r;
if (!up)
/* Stop all network engines while interface is still up to allow proper cleanup,
* e.g. sending IPv6 shutdown RA messages before the interface is brought down. */
(void) link_stop_engines(link, /* may_keep_dynamic = */ false);
return link_up_or_down_now_by_varlink(link, up, vlink);
}
static int vl_method_link_up(sd_varlink *vlink, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
return vl_method_link_up_or_down(vlink, parameters, userdata, /* up= */ true);
}
static int vl_method_link_down(sd_varlink *vlink, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
return vl_method_link_up_or_down(vlink, parameters, userdata, /* up= */ false);
}
int manager_varlink_init(Manager *m, int fd) {
_cleanup_(sd_varlink_server_unrefp) sd_varlink_server *s = NULL;
_unused_ _cleanup_close_ int fd_close = fd; /* take possession */
@ -259,7 +347,6 @@ int manager_varlink_init(Manager *m, int fd) {
r = sd_varlink_server_add_interface_many(
s,
&vl_interface_io_systemd_Network,
&vl_interface_io_systemd_Network_Link,
&vl_interface_io_systemd_service);
if (r < 0)
return log_error_errno(r, "Failed to add Network interface to varlink server: %m");
@ -271,8 +358,8 @@ int manager_varlink_init(Manager *m, int fd) {
"io.systemd.Network.GetNamespaceId", vl_method_get_namespace_id,
"io.systemd.Network.GetLLDPNeighbors", vl_method_get_lldp_neighbors,
"io.systemd.Network.SetPersistentStorage", vl_method_set_persistent_storage,
"io.systemd.Network.Link.Up", vl_method_link_up,
"io.systemd.Network.Link.Down", vl_method_link_down,
"io.systemd.Network.LinkUp", vl_method_link_up,
"io.systemd.Network.LinkDown", vl_method_link_down,
"io.systemd.service.Ping", varlink_method_ping,
"io.systemd.service.SetLogLevel", varlink_method_set_log_level,
"io.systemd.service.GetEnvironment", varlink_method_get_environment);

View File

@ -216,7 +216,6 @@ shared_sources = files(
'varlink-io.systemd.MuteConsole.c',
'varlink-io.systemd.NamespaceResource.c',
'varlink-io.systemd.Network.c',
'varlink-io.systemd.Network.Link.c',
'varlink-io.systemd.PCRExtend.c',
'varlink-io.systemd.PCRLock.c',
'varlink-io.systemd.Repart.c',

View File

@ -1,28 +0,0 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "bus-polkit.h"
#include "varlink-io.systemd.Network.Link.h"
#define VARLINK_NETWORK_INTERFACE_INPUTS \
SD_VARLINK_FIELD_COMMENT("Index of the interface. If specified together with InterfaceName, both must reference the same link."), \
SD_VARLINK_DEFINE_INPUT(InterfaceIndex, SD_VARLINK_INT, SD_VARLINK_NULLABLE), \
SD_VARLINK_FIELD_COMMENT("Name of the interface. If specified together with InterfaceIndex, both must reference the same link."), \
SD_VARLINK_DEFINE_INPUT(InterfaceName, SD_VARLINK_STRING, SD_VARLINK_NULLABLE)
static SD_VARLINK_DEFINE_METHOD(
Up,
VARLINK_NETWORK_INTERFACE_INPUTS,
VARLINK_DEFINE_POLKIT_INPUT);
static SD_VARLINK_DEFINE_METHOD(
Down,
VARLINK_NETWORK_INTERFACE_INPUTS,
VARLINK_DEFINE_POLKIT_INPUT);
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_Network_Link,
"io.systemd.Network.Link",
SD_VARLINK_SYMBOL_COMMENT("Bring the specified link up."),
&vl_method_Up,
SD_VARLINK_SYMBOL_COMMENT("Bring the specified link down."),
&vl_method_Down);

View File

@ -1,6 +0,0 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "sd-varlink-idl.h"
extern const sd_varlink_interface vl_interface_io_systemd_Network_Link;

View File

@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "bus-polkit.h"
#include "varlink-io.systemd.Network.h"
/* Helper macro to define address fields with both binary and string representation */
@ -593,6 +594,22 @@ static SD_VARLINK_DEFINE_METHOD(
SD_VARLINK_FIELD_COMMENT("Whether persistent storage is ready and writable"),
SD_VARLINK_DEFINE_INPUT(Ready, SD_VARLINK_BOOL, 0));
static SD_VARLINK_DEFINE_METHOD(
LinkUp,
SD_VARLINK_FIELD_COMMENT("Index of the interface. If specified together with InterfaceName, both must reference the same link."),
SD_VARLINK_DEFINE_INPUT(InterfaceIndex, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Name of the interface. If specified together with InterfaceIndex, both must reference the same link."),
SD_VARLINK_DEFINE_INPUT(InterfaceName, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
VARLINK_DEFINE_POLKIT_INPUT);
static SD_VARLINK_DEFINE_METHOD(
LinkDown,
SD_VARLINK_FIELD_COMMENT("Index of the interface. If specified together with InterfaceName, both must reference the same link."),
SD_VARLINK_DEFINE_INPUT(InterfaceIndex, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Name of the interface. If specified together with InterfaceIndex, both must reference the same link."),
SD_VARLINK_DEFINE_INPUT(InterfaceName, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
VARLINK_DEFINE_POLKIT_INPUT);
static SD_VARLINK_DEFINE_ERROR(StorageReadOnly);
SD_VARLINK_DEFINE_INTERFACE(
@ -603,6 +620,10 @@ SD_VARLINK_DEFINE_INTERFACE(
&vl_method_GetNamespaceId,
&vl_method_GetLLDPNeighbors,
&vl_method_SetPersistentStorage,
SD_VARLINK_SYMBOL_COMMENT("Bring the specified link up."),
&vl_method_LinkUp,
SD_VARLINK_SYMBOL_COMMENT("Bring the specified link down."),
&vl_method_LinkDown,
&vl_type_Address,
&vl_type_DHCPLease,
&vl_type_DHCPServer,

View File

@ -2,7 +2,6 @@
#include <unistd.h>
#include "bus-polkit.h"
#include "env-util.h"
#include "json-util.h"
#include "log.h"
@ -12,9 +11,7 @@
static SD_VARLINK_DEFINE_METHOD(Ping);
static SD_VARLINK_DEFINE_METHOD(
Reload,
VARLINK_DEFINE_POLKIT_INPUT);
static SD_VARLINK_DEFINE_METHOD(Reload);
static SD_VARLINK_DEFINE_METHOD(
SetLogLevel,

View File

@ -59,13 +59,12 @@ static int systemctl_main(int argc, char *argv[]) {
{ "list-machines", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_list_machines },
{ "clear-jobs", VERB_ANY, 1, VERB_ONLINE_ONLY, verb_trivial_method },
{ "cancel", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_cancel },
{ "start", 2, VERB_ANY, VERB_ONLINE_ONLY, verb_start },
{ "stop", 2, VERB_ANY, VERB_ONLINE_ONLY, verb_start },
{ "start", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_start },
{ "stop", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_start },
{ "condstop", 2, VERB_ANY, VERB_ONLINE_ONLY, verb_start }, /* For compatibility with ALTLinux */
{ "reload", 2, VERB_ANY, VERB_ONLINE_ONLY, verb_start },
{ "restart", 2, VERB_ANY, VERB_ONLINE_ONLY, verb_start },
{ "try-restart", 2, VERB_ANY, VERB_ONLINE_ONLY, verb_start },
{ "enqueue-marked-jobs", 1, 1, VERB_ONLINE_ONLY, verb_start },
{ "reload-or-restart", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_start },
{ "reload-or-try-restart", 2, VERB_ANY, VERB_ONLINE_ONLY, verb_start }, /* For compatibility with old systemctl <= 228 */
{ "try-reload-or-restart", 2, VERB_ANY, VERB_ONLINE_ONLY, verb_start },

View File

@ -295,7 +295,6 @@ int verb_start(int argc, char *argv[], void *userdata) {
const char *method, *job_type, *mode, *one_name, *suffix = NULL;
_cleanup_free_ char **stopped_units = NULL; /* Do not use _cleanup_strv_free_ */
_cleanup_strv_free_ char **names = NULL;
bool is_enqueue_marked_jobs = false;
int r, ret = EXIT_SUCCESS;
sd_bus *bus;
@ -332,23 +331,13 @@ int verb_start(int argc, char *argv[], void *userdata) {
job_type = "start";
mode = "isolate";
suffix = ".target";
} else if (streq(argv[0], "enqueue-marked-jobs") || arg_marked) {
is_enqueue_marked_jobs = true;
method = job_type = mode = NULL;
if (arg_show_transaction)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"--show-transaction is not supported for enqueue-marked-jobs.");
if (arg_marked)
log_warning("--marked is deprecated. Please use systemctl enqueue-marked-jobs instead.");
} else {
} else if (!arg_marked) {
/* A command in style of "systemctl start <unit1> <unit2> …", "systemctl stop <unit1> <unit2> …" and so on */
method = verb_to_method(argv[0]);
job_type = verb_to_job_type(argv[0]);
mode = arg_job_mode();
}
} else
method = job_type = mode = NULL;
one_name = NULL;
}
@ -368,7 +357,7 @@ int verb_start(int argc, char *argv[], void *userdata) {
names = strv_new(one_name);
if (!names)
return log_oom();
} else if (!is_enqueue_marked_jobs) {
} else if (!arg_marked) {
bool expanded;
r = expand_unit_names(bus, strv_skip(argv, 1), suffix, &names, &expanded);
@ -398,7 +387,7 @@ int verb_start(int argc, char *argv[], void *userdata) {
}
_cleanup_(fork_notify_terminate) PidRef journal_pid = PIDREF_NULL;
if (is_enqueue_marked_jobs)
if (arg_marked)
ret = enqueue_marked_jobs(bus, w);
else {
if (arg_verbose)

View File

@ -143,7 +143,6 @@ static int systemctl_help(void) {
" reload UNIT... Reload one or more units\n"
" restart UNIT... Start or restart one or more units\n"
" try-restart UNIT... Restart one or more units if active\n"
" enqueue-marked-jobs Enqueue all marked unit jobs\n"
" reload-or-restart UNIT... Reload one or more units if possible,\n"
" otherwise start or restart\n"
" try-reload-or-restart UNIT... If active, reload one or more units,\n"
@ -1070,19 +1069,24 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"--wait may not be combined with --no-block.");
bool do_reload_or_restart = streq_ptr(argv[optind], "reload-or-restart");
if (arg_marked) {
if (!do_reload_or_restart)
if (!STRPTR_IN_SET(argv[optind], "reload-or-restart", "start", "stop"))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"--marked may only be used with 'reload-or-restart'.");
"--marked may only be used with 'reload-or-restart', 'start', or 'stop'.");
if (optind + 1 < argc)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"No additional arguments allowed with 'reload-or-restart --marked'.");
"No additional arguments allowed with '%s --marked'.", strna(argv[optind]));
if (arg_wait)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"--marked --wait is not supported.");
if (arg_show_transaction)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"--marked --show-transaction is not supported.");
} else if (do_reload_or_restart) {
} else if (STRPTR_IN_SET(argv[optind], "reload-or-restart", "start", "stop")) {
if (optind + 1 >= argc)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"List of units to restart/reload is required.");
"List of units to %s is required.", strna(argv[optind]));
}
if (arg_image && arg_root)

View File

@ -34,7 +34,6 @@
#include "varlink-io.systemd.MuteConsole.h"
#include "varlink-io.systemd.NamespaceResource.h"
#include "varlink-io.systemd.Network.h"
#include "varlink-io.systemd.Network.Link.h"
#include "varlink-io.systemd.PCRExtend.h"
#include "varlink-io.systemd.PCRLock.h"
#include "varlink-io.systemd.Repart.h"
@ -200,7 +199,6 @@ TEST(parse_format) {
&vl_interface_io_systemd_MuteConsole,
&vl_interface_io_systemd_NamespaceResource,
&vl_interface_io_systemd_Network,
&vl_interface_io_systemd_Network_Link,
&vl_interface_io_systemd_PCRExtend,
&vl_interface_io_systemd_PCRLock,
&vl_interface_io_systemd_Repart,