public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: Michael Tremer <michael.tremer@ipfire.org>
To: development@lists.ipfire.org
Subject: Re: [PATCH] update-ids-ruleset: Always drop the lock file if it has been created during runtime.
Date: Thu, 03 Mar 2022 10:53:41 +0000	[thread overview]
Message-ID: <966F6E4B-C0ED-4236-B85A-E527837B0562@ipfire.org> (raw)
In-Reply-To: <20220303044943.3678-1-stefan.schantl@ipfire.org>

[-- Attachment #1: Type: text/plain, Size: 2056 bytes --]

This looks good :)

Reviewed-by: Michael Tremer <michael.tremer(a)ipfire.org>

> On 3 Mar 2022, at 04:49, Stefan Schantl <stefan.schantl(a)ipfire.org> wrote:
> 
> In some situations or if an error happened, the lock file could be
> keep on the system. In such a case the IDS page would be locked forever
> until user interaction or reboot of the system.
> 
> Now the script checks if it has created such a lock and release it when
> the script exists.
> 
> Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>
> ---
> src/scripts/update-ids-ruleset | 19 ++++++++++++++++---
> 1 file changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/src/scripts/update-ids-ruleset b/src/scripts/update-ids-ruleset
> index 10a270907..c2970d20b 100644
> --- a/src/scripts/update-ids-ruleset
> +++ b/src/scripts/update-ids-ruleset
> @@ -26,6 +26,9 @@ require '/var/ipfire/general-functions.pl';
> require "${General::swroot}/ids-functions.pl";
> require "${General::swroot}/lang.pl";
> 
> +# Variable to store if the process has written a lockfile.
> +my $locked;
> +
> # Hash to store the configured providers.
> my %providers = ();
> 
> @@ -77,6 +80,9 @@ if(&IDS::checkdiskspace()) {
> # Lock the IDS page.
> &IDS::lock_ids_page();
> 
> +# The script has requested a lock, so set locket to "1".
> +$locked = "1";
> +
> # Grab the configured providers.
> &General::readhasharray("$IDS::providers_settings_file", \%providers);
> 
> @@ -114,13 +120,20 @@ foreach my $id (keys %providers) {
> # Set correct ownership for the rulesdir and files.
> &IDS::set_ownership("$IDS::rulespath");
> 
> -# Unlock the IDS page.
> -&IDS::unlock_ids_page();
> -
> # Check if the IDS is running.
> if(&IDS::ids_is_running()) {
> 	# Call suricatactrl to perform a reload.
> 	&IDS::call_suricatactrl("reload");
> }
> 
> +# Custom END declaration to release a IDS page lock
> +# when the script has created one.
> +END {
> +	# Check if a lock has been requested.
> +	if ($locked) {
> +		# Unlock the IDS page.
> +		&IDS::unlock_ids_page();
> +	}
> +}
> +
> 1;
> -- 
> 2.30.2
> 


  reply	other threads:[~2022-03-03 10:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03  4:49 Stefan Schantl
2022-03-03 10:53 ` Michael Tremer [this message]
2022-03-03 13:14 ` Peter Müller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=966F6E4B-C0ED-4236-B85A-E527837B0562@ipfire.org \
    --to=michael.tremer@ipfire.org \
    --cc=development@lists.ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox