From: Zbigniew Jędrzejewski-Szmek Date: Sat, 5 Jul 2025 11:26:07 +0000 (+0200) Subject: shared/bus-unit-util: rework error messages for NFTSet= X-Git-Tag: v258-rc1~150^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6f06afde598bb2154537f46b32f2dec48123291d;p=thirdparty%2Fsystemd.git shared/bus-unit-util: rework error messages for NFTSet= Let's be nice to the user and print the exact reason why we won't accept a setting. --- diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index ebfabcdf360..fde4f239bec 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -961,13 +961,21 @@ static int bus_append_nft_set(sd_bus_message *m, const char *field, const char * assert(table); assert(set); - source = nft_set_source_from_string(source_str); + source = r = nft_set_source_from_string(source_str); + if (r < 0) + return log_error_errno(r, "Failed to parse NFT set source '%s': %m", source_str); if (!IN_SET(source, NFT_SET_SOURCE_CGROUP, NFT_SET_SOURCE_USER, NFT_SET_SOURCE_GROUP)) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to parse %s.", field); + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Bad NFT set source value '%s'.", + nft_set_source_to_string(source)); + + nfproto = r = nfproto_from_string(nfproto_str); + if (r < 0) + return log_error_errno(r, "Failed to parse nft protocol '%s': %m", nfproto_str); - nfproto = nfproto_from_string(nfproto_str); - if (nfproto < 0 || !nft_identifier_valid(table) || !nft_identifier_valid(set)) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to parse %s.", field); + if (!nft_identifier_valid(table)) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Bad NFT identifier name '%s'.", table); + if (!nft_identifier_valid(set)) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Bad NFT identifier name '%s'.", set); r = sd_bus_message_append(m, "(iiss)", source, nfproto, table, set); if (r < 0)