Skip to content

Commit

Permalink
Adjusted cf-support for exotic UNIX platforms
Browse files Browse the repository at this point in the history
head -c 8 doesn't work on hpux 11.23 that we test on currently

dd count=1 bs=8 should work on all UNIX systems

tr on solaris needs LC_CTYPE=C as it can't handle binary data.
Silence not found sysctl command where it is not present.

Ticket: ENT-9786
Changelog: title
  • Loading branch information
craigcomstock committed Dec 9, 2024
1 parent 871e87e commit be724b2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions misc/cf-support
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ make_temp_dir()
else
# shellcheck disable=SC2021
# ^^ legacy/POSIX requires square brackets
_tmp="/tmp/`tr -dc "[A-Z][a-z][0-9]" </dev/urandom | head -c 8`"
_tmp="/tmp/`LC_CTYPE=C tr -dc "[A-Z][a-z][0-9]" </dev/urandom | dd count=1 bs=8 2>/dev/null`"
mkdir "$_tmp"
echo "$_tmp"
fi
Expand Down Expand Up @@ -150,7 +150,11 @@ mkdir -p "$tmpdir"

echo "Analyzing CFEngine core dumps"
_core_log="$tmpdir"/core-dump.log
_sysctl_kernel_core_pattern="$(sysctl -n kernel.core_pattern)"
if command -v sysctl >/dev/null; then
_sysctl_kernel_core_pattern="$(sysctl -n kernel.core_pattern)"
else
_sysctl_kernel_core_pattern=""
fi
if expr "$_sysctl_kernel_core_pattern" : ".*/systemd-coredump.*" > /dev/null 2>&1; then
echo "Found systemd-coredump used in sysctl kernel.core_pattern \"$_sysctl_kernel_core_pattern\""
echo "Using coredumpctl to analyze CFEngine core dumps"
Expand Down

0 comments on commit be724b2

Please sign in to comment.