curl not working custom:executeForString() in RHEL9

curl not working custom:executeForString() in RHEL9

book

Article ID: KB0070093

calendar_today

Updated On:

Products Versions
TIBCO Hawk 6.x

Description

Invoke methods custom:executeForString(curl xxx) from HawkConsole, get error:

Method invocation failure
Method Invocation Timed Out. Exceeded maximum response time (10)

Put the curl command into a shell script custom:executeForString(sendRequest.sh).

Get the error

Curl Error: 127

Issue/Introduction

curl not working custom:executeForString() in RHEL9

Environment

Red Hat Enterprise Linux 9 and Equivalent Linux Distributions

Resolution

In Red Hat Enterprise Linux 9, the default permissions are more stringent compared to RHEL 7. This can cause certain applications and commands that worked seamlessly on RHEL 7 to fail or encounter permission issues on RHEL 9.
To resolve this issue, you need to adjust the permissions on RHEL 9 to allow the necessary capabilities. Below are two solutions to address this problem:
Solution 1: Modify Permissions Directly on curl
  1. Open a terminal from the RHEL 9 server where the hawkagent is running from.
  2. Execute the following command to grant the necessary capabilities to the curl binary: 
sudo setcap cap_net_bind_service,cap_net_admin+ep /usr/bin/curl
 
If you are not able to grant the permission to original binary file, you can try this:
Solution 2: Create a Copy of curl and Modify Permissions
  1. Open a terminal from the RHEL 9 server where the hawkagent is running from.
  2. sudo cp /usr/bin/curl /usr/local/bin/curl_hawk
  3. sudo setcap cap_net_bind_service,cap_net_admin+ep /usr/local/bin/curl_hawk
  4. Use it in rulebases or in script:  custom:executeForString(curl_hawk xxx).
To revert the changes:
sudo setcap -r /usr/bin/curl 
OR
sudo setcap -r /usr/local/bin/curl_hawk