Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
openSUSE:Leap:15.6:Update
pacemaker
pacemaker#3379-0001-Low-tools-Fix-argument-vali...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File pacemaker#3379-0001-Low-tools-Fix-argument-validation-for-crm_attribute-.patch of Package pacemaker
From 88d94635bc1d1387863d7454ec99c6de70abf439 Mon Sep 17 00:00:00 2001 From: Chris Lumens <clumens@redhat.com> Date: Thu, 29 Feb 2024 15:50:04 -0500 Subject: [PATCH] Low: tools: Fix argument validation for crm_attribute update. Previously (perhaps as far back as when crm_attribute was introduced) we haven't done any validation on whether an attribute name was given along with the -v option specifying the new attribute value. Instead we just asserted. Instead, check that a name or pattern was given and if not, display an error message. The other two asserts can go, as well. options.type will always be set by the call to set_type(), and options.attr_value will be set if -v was given on the command line. Fixes T765 --- tools/crm_attribute.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) Index: pacemaker-2.1.7+20231219.0f7f88312/tools/crm_attribute.c =================================================================== --- pacemaker-2.1.7+20231219.0f7f88312.orig/tools/crm_attribute.c +++ pacemaker-2.1.7+20231219.0f7f88312/tools/crm_attribute.c @@ -218,7 +218,7 @@ static GOptionEntry selecting_entries[] static GOptionEntry command_entries[] = { { "delete", 'D', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, delete_cb, - "Delete the attribute/option", + "Delete the attribute/option (with -n or -P)", NULL }, @@ -229,7 +229,7 @@ static GOptionEntry command_entries[] = }, { "update", 'v', 0, G_OPTION_ARG_CALLBACK, update_cb, - "Update the value of the attribute/option", + "Update the value of the attribute/option (with -n or -P)", "VALUE" }, @@ -461,10 +461,6 @@ command_update(pcmk__output_t *out, cib_ xmlNode *result = NULL; bool use_pattern = options.attr_pattern != NULL; - CRM_LOG_ASSERT(options.type != NULL); - CRM_LOG_ASSERT(options.attr_name != NULL); - CRM_LOG_ASSERT(options.attr_value != NULL); - /* See the comment in command_query regarding xpath and regular expressions. */ if (use_pattern) { struct update_data_s ud = { out, cib, is_remote_node }; @@ -639,6 +635,14 @@ delete_used_correctly(void) return options.command != 'D' || options.attr_name != NULL || options.attr_pattern != NULL; } +static bool +update_used_correctly(void) +{ + return (options.command != 'u') + || (options.attr_name != NULL) + || (options.attr_pattern != NULL); +} + static GOptionContext * build_arg_context(pcmk__common_args_t *args, GOptionGroup **group) { GOptionContext *context = NULL; @@ -815,6 +819,13 @@ main(int argc, char **argv) goto done; } + if (!update_used_correctly()) { + exit_code = CRM_EX_USAGE; + g_set_error(&error, PCMK__EXITC_ERROR, exit_code, + "Error: must specify attribute name or pattern to update"); + goto done; + } + if (options.attr_pattern) { if (options.attr_name) { exit_code = CRM_EX_USAGE;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor