public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: Matthias Fischer <matthias.fischer@ipfire.org>
To: development@lists.ipfire.org
Subject: Re: New IDS won't unlink "/tmp/ids_page_locked"
Date: Wed, 16 Mar 2022 17:19:13 +0100	[thread overview]
Message-ID: <9089558d-1204-44ef-7a8e-7743170e9892@ipfire.org> (raw)
In-Reply-To: <a09fa225-0587-6619-b360-73a91c508a82@ipfire.org>

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

Hi,

I wanted to report that after updating 'update-ids-ruleset' the problems
are gone:

- GUI doesn't hang anymore.
- After the daily rules update, '/tmp' doesn't contain any leftovers.
- Reloading the rules did work and was logged properly.

Just in case someone wanted to know... ;-)

Best,
Matthias

On 14.03.2022 19:01, Matthias Fischer wrote:
> Hi,
> 
> after updating the old '/usr/local/bin/update-ids-ruleset' to one from
> Core164, I manually started "Force ruleset update" through IDS GUI for
> one of my lists.
> 
> Result:
> GUI changes to "Downloading and unpacking new ruleset. Please wait until
> all operations have completed successfully...". Then it stays there
> forever until I reload it - which works after some time.
> 
> But in '/var/tmp' there are remains of a 'ids_tmp'-directory, containing
> a 'conf' and a 'rules' directory. These seem to contain the updated,
> unpacked config- and rule-files(?). For me it looks as if in
> '/var/lib/suricata' there are still the *old* rule files.
> 
> 'var/lib/suricata' and '/tmp/ids_tmp/rules' contain identically named
> *.rules-files, but the rules-files in '/var/lib/suricata' start with
> "drop tcp ..." and the ones in '/var/ids_tmp/rules' with "alert tcp ...".
> 
> And 'suricata' isn't restarted, either. No update entries in the logs.
> 
> Besides that, the GUI shows the updated date and time stamps from the
> downloaded archives in '/var/tmp'. At first look, everything seems ok,
> but it isn't. Weird...
> 
> On 14.03.2022 18:04, Matthias Fischer wrote:
>> On 14.03.2022 06:08, Stefan Schantl wrote:
>>> Hello Mathias,
>> 
>> Hi Stefan,
>> 
>>> thanks for reporting your issue here.
>> 
>> No problem - I should have taken a closer look: 'update-ids-ruleset'
>> seems to be missing in the Core update for Core164, I was still using
>> the old version from Core163. ;-)
>> 
>> See:
>> https://git.ipfire.org/?p=ipfire-2.x.git;a=tree;f=config/rootfiles/core/164/filelists;h=c81a06294cd3527b9b68d1352d487bf1c8f95c9e;hb=refs/heads/core164
>> 
>>> The IDS page locking issue should be fixed and shipped with the final
>>> C164 release.
>>> 
>>> See:
>>> https://git.ipfire.org/?p=ipfire-2.x.git;a=commit;h=85b1d83b2a6fe2beb8169f3e810e915c4ad54036
>>> 
>>> Please report if you are affected again by this issue.
>> 
>> I'll test and report.
>> 
>> Best,
>> Matthias
>> 
>>> You safely can drop those folder and files from "/tmp".
>>> 
>>> Best regards,
>>> 
>>> -Stefan
>>>> Hi,
>>>> 
>>>> ..I'd like to have *two* problems with the IDS/IPS... ;-)
>>>> 
>>>> 
>>>> 1. After upgrading to Core164 yesterday I took a look at the IDS GUI
>>>> today and found it locked with a spinning wheel at "Ruleset update in
>>>> progress. Please wait until all operations have completed
>>>> successfully..."
>>>> 
>>>> Despite this message IPS seemed to work.
>>>> 
>>>> So I searched and found that the file "/tmp/ids_page_locked" still
>>>> existed. After deleting this file manually the web GUI opened,
>>>> everything seems normal.
>>>> 
>>>> Three activated rulesets were running, see attachment "01".
>>>> 
>>>> But the Web GUI stopped because of lines 234ff in 'ids.cgi':
>>>> 
>>>> ...
>>>> # Check if the page is locked, in this case, the ids_page_lock_file
>>>> exists.
>>>> if (-e $IDS::ids_page_lock_file) {
>>>>         # Lock the webpage and print notice about autoupgrade of the
>>>> ruleset
>>>>         # is in progess.
>>>>         &working_notice("$Lang::tr{'ids ruleset autoupdate in
>>>> progress'}");
>>>> 
>>>>         # Loop and check if the file still exists.
>>>>         while(-e $IDS::ids_page_lock_file) {
>>>>                 # Sleep for a second and re-check.
>>>>                 sleep 1;
>>>>         }
>>>> ...
>>>> 
>>>> I searched again and found that there are two subroutines in
>>>> '/var/ipfire/ids-functions.pl', lines 1920ff, which are responsible
>>>> for
>>>> locking and unlocking this file:
>>>> 
>>>> ...
>>>> ## Function to write the lock file for locking the WUI, while
>>>> ## the autoupdate script runs.
>>>> #
>>>> sub lock_ids_page() {
>>>>         # Call subfunction to create the file.
>>>>         &create_empty_file($ids_page_lock_file);
>>>> }
>>>> 
>>>> #
>>>> ## Function to release the lock of the WUI, again.
>>>> #
>>>> sub unlock_ids_page() {
>>>>         # Delete lock file.
>>>>         unlink($ids_page_lock_file);
>>>> }
>>>> ...
>>>> 
>>>> Somehow lines 103ff in "/usr/local/bin/update-ids-ruleset" didn't
>>>> work/weren't executed(?):
>>>> 
>>>> ...
>>>> # 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);
>>>> 
>>>> # Loop through the array of available providers.
>>>> foreach my $id (keys %providers) {
>>>>    # Assign some nice variabled.
>>>>    my $provider = $providers{$id}[0];
>>>>    my $autoupdate_status = $providers{$id}[3];
>>>> 
>>>>    # Skip the provider if autoupdate is not enabled.
>>>>    next unless($autoupdate_status eq "enabled");
>>>> 
>>>>    # Call the download function and gather the new ruleset for the
>>>> current processed provider.
>>>>    if(&IDS::downloadruleset($provider)) {
>>>>       # Store error message for displaying in the WUI.
>>>>       &IDS::_store_error_message("$provider: $Lang::tr{'could not
>>>> download latest updates'}");
>>>> 
>>>>       # Unlock the IDS page.
>>>>       &IDS::unlock_ids_page();
>>>> 
>>>>       # Exit.
>>>>       exit 0;
>>>>    }
>>>> ...
>>>> 
>>>> Manual updates - yesterday - were ok, but the automatic updates
>>>> tonight
>>>> didn't unlink the lock file: IDS GUI stopped at the next call today.
>>>> 
>>>> ##########
>>>> 
>>>> 2. There still exist a directory '/tmp/isd_tmp' containing 'conf'
>>>> ('config' and 'map' files from emerging-threats) and a 'rules'-dir
>>>> containing all '*.rules'-files. Leftovers!? Can I safely delete these
>>>> dirs?
>>>> 
>>>> And: can anyone confirm these two problems - or reproduce?
>>>> 
>>>> Best,
>>>> Matthias
>>> 
>>> 
>> 
> 


      reply	other threads:[~2022-03-16 16:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <c80f78aa-2d87-c9c8-72a3-a5efa25f6975@ipfire.org>
2022-03-14  5:08 ` Stefan Schantl
2022-03-14 17:04   ` Matthias Fischer
2022-03-14 18:01     ` Matthias Fischer
2022-03-16 16:19       ` Matthias Fischer [this message]

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=9089558d-1204-44ef-7a8e-7743170e9892@ipfire.org \
    --to=matthias.fischer@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