diff --git a/download b/download index 06b90739241eb66b53977cfd12b4530a8ac67b55..640e630238d5d45f69357681abeb078c7dd68f68 100644 --- a/download +++ b/download @@ -1 +1 @@ -037bd4150d8e6385dc7d0b45bc6d1087 rig-1.0.tar.gz +779cb93122628cb8c8daf528382b6131 rig-1.1.tar.gz diff --git a/rig-fix-rig-list.patch b/rig-fix-rig-list.patch new file mode 100644 index 0000000000000000000000000000000000000000..eecd961a85eeaf1b130beb5da14decf8ce23698f --- /dev/null +++ b/rig-fix-rig-list.patch @@ -0,0 +1,96 @@ +From dedd8733d6cac622903a58cf7a94503cdbd13d88 Mon Sep 17 00:00:00 2001 +From: Jake Hunsaker +Date: Tue, 24 May 2022 12:06:46 -0400 +Subject: [PATCH] [BaseRig] Fix fatal error when querying rig list during + pre_action() + +If a rig used the sosreport action, and specified `--initial-sos`, *and* +queried `rig list` immediately after the rig was deployed, there was a +race condition where the status query would have failed and terminated +the rig during `pre_action()` execution. + +Fix this, by first not detaching until all `pre_action`s are completed, +and second better handle failed `status` queries better generically. + +Signed-off-by: Jake Hunsaker +--- + rigging/__init__.py | 19 +++++++++++++++---- + rigging/rigs/__init__.py | 6 +++--- + 2 files changed, 18 insertions(+), 7 deletions(-) + +diff --git a/rigging/__init__.py b/rigging/__init__.py +index 245d2d1..04ad08e 100644 +--- a/rigging/__init__.py ++++ b/rigging/__init__.py +@@ -234,6 +234,7 @@ class RigConnection(): + """ + + def __init__(self, socket_name): ++ self.name = socket_name + self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + _address = "/var/run/rig/%s" % socket_name + try: +@@ -278,10 +279,20 @@ class RigConnection(): + Returns + dict of rig's status information + """ +- ret = json.loads(self._rig_communicate('status').decode()) +- if ret['success']: +- return ast.literal_eval(ret['result']) +- raise Exception ++ try: ++ ret = json.loads(self._rig_communicate('status').decode()) ++ if ret['success']: ++ return ast.literal_eval(ret['result']) ++ except Exception as err: ++ print("Error retreiving status for %s: %s" % (self.name, err)) ++ return { ++ 'id': self.name, ++ 'pid': '', ++ 'rig_type': '', ++ 'watch': 'Error retrieving status', ++ 'trigger': '', ++ 'status': 'Unknown' ++ } + + def info(self): + """ +diff --git a/rigging/rigs/__init__.py b/rigging/rigs/__init__.py +index 1d2f2df..f14f312 100644 +--- a/rigging/rigs/__init__.py ++++ b/rigging/rigs/__init__.py +@@ -77,6 +77,7 @@ class BaseRig(): + self.resource_name = self.__class__.__name__.lower() + self.parser_usage = self.parser_usage % {'name': self.resource_name} + self.pool = None ++ self.archive_name = None + self.parser = parser + self.restart_count = 0 + subparser = self.parser.add_subparsers() +@@ -484,7 +485,6 @@ class BaseRig(): + conn.sendall(self._fmt_return(command=req['command'], + output='No such attribute', + success=False)) +- continue + + def _register_actions(self): + """ +@@ -536,13 +536,13 @@ class BaseRig(): + Main entry point for rigs. + """ + try: ++ self.setup() ++ self._register_actions() + # detach from console + if not self.args['foreground']: + print(self.id) + self._detach() + self.detached = True +- self.setup() +- self._register_actions() + if self.detached: + for action in self._actions: + self._actions[action].detached = True +-- +2.34.3 + diff --git a/rig-full-random-temp.patch b/rig-full-random-temp.patch new file mode 100644 index 0000000000000000000000000000000000000000..a9d6c47416c798b9ac8350a662327b23fcd7daae --- /dev/null +++ b/rig-full-random-temp.patch @@ -0,0 +1,59 @@ +From 90c5505d82b288bbc0b2e8b01e85b78d18a0bd18 Mon Sep 17 00:00:00 2001 +From: Jake Hunsaker +Date: Thu, 9 Jun 2022 14:26:02 -0400 +Subject: [PATCH] [rig] Use `tempfile` module for temp directory creation + +Previously, a change was made to temp directory creation in an effort to +make it more secure. While that was largely handled, it left us with an +unhandled error in an edge case configuration. Rather than putting a +band-aid over that again, re-write the temp directory creation process +to leverage the `tempfile` module, so that we can safely and completely +ignore the id/name of a rig, and leave the use of that for the +communication socket. + +Signed-off-by: Jake Hunsaker +--- + rigging/rigs/__init__.py | 13 +++++++------ + 1 file changed, 7 insertions(+), 6 deletions(-) + +diff --git a/rigging/rigs/__init__.py b/rigging/rigs/__init__.py +index f14f312..29bb8b4 100644 +--- a/rigging/rigs/__init__.py ++++ b/rigging/rigs/__init__.py +@@ -18,6 +18,7 @@ import string + import socket + import sys + import tarfile ++import tempfile + import time + + from argparse import Action +@@ -110,7 +111,7 @@ class BaseRig(): + self.log_debug("Initializing %s rig %s" % + (self.resource_name, self.id)) + self._sock, self._sock_address = self._create_rig_socket() +- self._tmp_dir = self._create_temp_dir() ++ self._create_temp_dir() + self.files = [] + + def set_rig_id(self): +@@ -196,11 +197,11 @@ class BaseRig(): + Create a temp directory for rig to use for saving created files too + """ + try: +- _dir = "%s.%s/" % (RIG_TMP_DIR_PREFIX, self.id) +- os.makedirs(_dir) +- return _dir +- except OSError: +- raise CannotConfigureRigError('failed to create temp directory') ++ self._tmp_dir = tempfile.mkdtemp(prefix='rig.', dir='/var/tmp') ++ except Exception as err: ++ raise CannotConfigureRigError( ++ "failed to create temp directory: %s" % err ++ ) + + def _load_args(self): + """ +-- +2.35.3 + diff --git a/rig.spec b/rig.spec index 635134cd36d56581d4713dc5366103f552b6ae08..13a9ddc8c0381f37233b9a5b1cdc1496266ea0ed 100644 --- a/rig.spec +++ b/rig.spec @@ -1,22 +1,19 @@ -%define anolis_release .0.1 Name: rig Summary: Monitor a system for events and trigger specific actions -Version: 1.0 -Release: 3%{anolis_release}%{?dist} +Version: 1.1 +Release: 6%{?dist} Url: https://github.com/TurboTurtle/rig Source0: %{url}/archive/%{name}-%{version}.tar.gz License: GPLv2 BuildArch: noarch -Requires: python3dist(systemd-python) -Requires: python3dist(psutil) - BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3dist(systemd-python) BuildRequires: python3dist(psutil) -Provides: /usr/bin/rig +Patch1: rig-fix-rig-list.patch +Patch2: rig-full-random-temp.patch %description Rig is a utility designed to watch or monitor specific system resources (e.g. @@ -24,16 +21,10 @@ log files, journals, system activity, etc...) and then take specific action when the trigger condition is met. Its primary aim is to assist in troubleshooting and data collection for randomly occurring events. -%package doc -Summary: Documents for %{name} -BuildArch: noarch -Requires: %{name} = %{version}-%{release} - -%description doc -Doc pages for %{name}. - %prep %setup -q +%patch1 -p1 +%patch2 -p1 %build %py3_build @@ -51,18 +42,28 @@ install -p -m644 man/en/rig.1 ${RPM_BUILD_ROOT}%{_mandir}/man1/ %{python3_sitelib}/rigging/ %license LICENSE - -%files doc %doc README.md %changelog -* Sat Jul 16 2022 Xiaoping Liu - 1.0-3.0.1 -- Add doc sub package +* Tue Jun 14 2022 Jake Hunsaker - 1.1-6 +- Backport change to temp dir creation to ignore rig ID + +* Thu Jun 02 2022 Jake Hunsaker - 1.1-4 +- Backport fix for rig list race condition + +* Fri May 04 2022 Jake Hunsaker - 1.1-2 +- Rebase to version 1.1 + Related: RHBZ#2077096 + +* Tue Aug 10 2021 Mohan Boddu - 1.0-4 +- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags + Related: rhbz#1991688 +* Fri Apr 16 2021 Mohan Boddu - 1.0-3 +- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937 -* Mon Oct 04 2021 Jake Hunsaker - 1.0-3 -- Rebuilt for RHEL 8.6.0 -- RHBZ#1888705 +* Wed Jan 27 2021 Fedora Release Engineering - 1.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild * Tue Jul 28 2020 Jake Hunsaker - 1.0-1 - Version 1.0 release