diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-03-13 02:29:53 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-03-13 13:49:12 +0100 |
commit | cac8e820d6257c05c1c67c6ff9725a0f1af439b0 (patch) | |
tree | 99e93547a72891da4002b431b5502149f1015f7f | |
parent | networkctl.c : call 'assert_not_reached' where appropriate (diff) | |
download | systemd-cac8e820d6257c05c1c67c6ff9725a0f1af439b0.tar.xz systemd-cac8e820d6257c05c1c67c6ff9725a0f1af439b0.zip |
network/varlink: return StorageReadOnly error
Addresses https://github.com/systemd/systemd/pull/30021#discussion_r1521595855.
-rw-r--r-- | src/network/networkd-manager-varlink.c | 6 | ||||
-rw-r--r-- | src/shared/varlink-io.systemd.Network.c | 5 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/network/networkd-manager-varlink.c b/src/network/networkd-manager-varlink.c index f3b265fed5..c86505b039 100644 --- a/src/network/networkd-manager-varlink.c +++ b/src/network/networkd-manager-varlink.c @@ -188,8 +188,10 @@ static int vl_method_set_persistent_storage(Varlink *vlink, JsonVariant *paramet r = path_is_read_only_fs("/var/lib/systemd/network/"); if (r < 0) return log_warning_errno(r, "Failed to check if /var/lib/systemd/network/ is writable: %m"); - if (r > 0) - return log_warning_errno(SYNTHETIC_ERRNO(EROFS), "The directory /var/lib/systemd/network/ is read-only."); + if (r > 0) { + log_warning("The directory /var/lib/systemd/network/ is read-only."); + return varlink_error(vlink, "io.systemd.Network.StorageReadOnly", NULL); + } } r = varlink_verify_polkit_async( diff --git a/src/shared/varlink-io.systemd.Network.c b/src/shared/varlink-io.systemd.Network.c index c3be38b99a..394cc33ace 100644 --- a/src/shared/varlink-io.systemd.Network.c +++ b/src/shared/varlink-io.systemd.Network.c @@ -44,6 +44,8 @@ static VARLINK_DEFINE_METHOD( SetPersistentStorage, VARLINK_DEFINE_INPUT(Ready, VARLINK_BOOL, 0)); +static VARLINK_DEFINE_ERROR(StorageReadOnly); + VARLINK_DEFINE_INTERFACE( io_systemd_Network, "io.systemd.Network", @@ -52,4 +54,5 @@ VARLINK_DEFINE_INTERFACE( &vl_method_GetLLDPNeighbors, &vl_method_SetPersistentStorage, &vl_type_LLDPNeighbor, - &vl_type_LLDPNeighborsByInterface); + &vl_type_LLDPNeighborsByInterface, + &vl_error_StorageReadOnly); |