2 ############################################################################
4 # This file is part of the IPFire Firewall. #
6 # IPFire is free software; you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation; either version 2 of the License, or #
9 # (at your option) any later version. #
11 # IPFire is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
16 # You should have received a copy of the GNU General Public License #
17 # along with IPFire; if not, write to the Free Software #
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
20 # Copyright (C) 2018-2019 IPFire Team <info@ipfire.org> #
22 ############################################################################
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/network-functions.pl";
30 require "${General::swroot}/suricata/ruleset-sources";
32 # Location where all config and settings files are stored.
33 our $settingsdir = "${General::swroot}/suricata";
35 # File where the main file for providers ruleset inclusion exists.
36 our $suricata_used_providers_file = "$settingsdir/suricata-used-providers.yaml";
38 # File for static ruleset inclusions.
39 our $suricata_static_rulefiles_file = "$settingsdir/suricata-static-included-rulefiles.yaml";
41 # File where the addresses of the homenet are stored.
42 our $homenet_file = "$settingsdir/suricata-homenet.yaml";
44 # File where the addresses of the used DNS servers are stored.
45 our $dns_servers_file = "$settingsdir/suricata-dns-servers.yaml";
47 # File where the HTTP ports definition is stored.
48 our $http_ports_file = "$settingsdir/suricata-http-ports.yaml";
50 # File which contains includes for provider specific rule modifications.
51 our $oinkmaster_provider_includes_file = "$settingsdir/oinkmaster-provider-includes.conf";
53 # File which contains wheater the rules should be changed.
54 our $modify_sids_file = "$settingsdir/oinkmaster-modify-sids.conf";
56 # File which stores the configured IPS settings.
57 our $ids_settings_file = "$settingsdir/settings";
59 # File which stores the used and configured ruleset providers.
60 our $providers_settings_file = "$settingsdir/providers-settings";
62 # File which stores the configured settings for whitelisted addresses.
63 our $ignored_file = "$settingsdir/ignored";
65 # Location where the downloaded rulesets are stored.
66 our $dl_rules_path = "/var/tmp";
68 # File to store any errors, which also will be read and displayed by the wui.
69 our $storederrorfile = "/tmp/ids_storederror";
71 # File to lock the WUI, while the autoupdate script runs.
72 our $ids_page_lock_file = "/tmp/ids_page_locked";
74 # Location where the rulefiles are stored.
75 our $rulespath = "/var/lib/suricata";
77 # Location where the addition config files are stored.
78 our $configspath = "/usr/share/suricata";
80 # Location of the classification file.
81 our $classification_file = "$configspath/classification.config";
83 # Location of the sid to msg mappings file.
84 our $sid_msg_file = "$rulespath/sid-msg.map";
86 # Location to store local rules. This file will not be touched.
87 our $local_rules_file = "$rulespath/local.rules";
89 # File which contains the rules to whitelist addresses on suricata.
90 our $whitelist_file = "$rulespath/whitelist.rules";
92 # File which contains a list of all supported ruleset sources.
93 # (Sourcefire, Emergingthreads, etc..)
94 our $rulesetsourcesfile = "$settingsdir/ruleset-sources";
96 # The pidfile of the IDS.
97 our $idspidfile = "/var/run/suricata.pid";
99 # Location of suricatactrl.
100 my $suricatactrl = "/usr/local/bin/suricatactrl";
102 # Prefix for each downloaded ruleset.
103 my $dl_rulesfile_prefix = "idsrules";
105 # Temporary directory where the rulesets will be extracted.
106 my $tmp_directory = "/tmp/ids_tmp";
108 # Temporary directory where the extracted rules files will be stored.
109 my $tmp_rules_directory = "$tmp_directory/rules";
111 # Temporary directory where the extracted additional config files will be stored.
112 my $tmp_conf_directory = "$tmp_directory/conf";
114 # Array with allowed commands of suricatactrl.
115 my @suricatactrl_cmds = ( 'start', 'stop', 'restart', 'reload', 'fix-rules-dir', 'cron' );
117 # Array with supported cron intervals.
118 my @cron_intervals = ('off', 'daily', 'weekly' );
120 # Array which contains the HTTP ports, which statically will be declared as HTTP_PORTS in the
122 my @http_ports = ('80', '81');
124 # Array which contains a list of rulefiles which always will be included if they exist.
125 my @static_included_rulefiles = ('local.rules', 'whitelist.rules' );
127 # Hash which allows to convert the download type (dl_type) to a file suffix.
128 my %dl_type_to_suffix = (
129 "archive" => ".tar.gz",
134 ## Function to check and create all IDS related files, if the does not exist.
136 sub check_and_create_filelayout
() {
137 # Check if the files exist and if not, create them.
138 unless (-f
"$oinkmaster_provider_includes_file") { &create_empty_file
($oinkmaster_provider_includes_file); }
139 unless (-f
"$modify_sids_file") { &create_empty_file
($modify_sids_file); }
140 unless (-f
"$suricata_used_providers_file") { &create_empty_file
($suricata_used_providers_file); }
141 unless (-f
"$ids_settings_file") { &create_empty_file
($ids_settings_file); }
142 unless (-f
"$providers_settings_file") { &create_empty_file
($providers_settings_file); }
143 unless (-f
"$ignored_file") { &create_empty_file
($ignored_file); }
144 unless (-f
"$whitelist_file" ) { &create_empty_file
($whitelist_file); }
148 ## Function to get a list of all available ruleset providers.
150 ## They will be returned as a sorted array.
152 sub get_ruleset_providers
() {
155 # Loop through the hash of providers.
156 foreach my $provider ( keys %IDS::Ruleset
::Providers
) {
157 # Add the provider to the array.
158 push(@providers, $provider);
161 # Sort and return the array.
162 return sort(@providers);
166 ## Function to get a list of all enabled ruleset providers.
168 ## They will be returned as an array.
170 sub get_enabled_providers
() {
171 my %used_providers = ();
173 # Array to store the enabled providers.
174 my @enabled_providers = ();
176 # Read-in the providers config file.
177 &General
::readhasharray
("$providers_settings_file", \
%used_providers);
179 # Loop through the hash of used_providers.
180 foreach my $id (keys %used_providers) {
181 # Skip disabled providers.
182 next unless ($used_providers{$id}[3] eq "enabled");
184 # Grab the provider handle.
185 my $provider = "$used_providers{$id}[0]";
187 # Add the provider to the array of enabled providers.
188 push(@enabled_providers, $provider);
192 return @enabled_providers;
196 ## Function for checking if at least 300MB of free disk space are available
197 ## on the "/var" partition.
199 sub checkdiskspace
() {
200 # Call diskfree to gather the free disk space of /var.
201 my @df = &General
::system_output
("/bin/df", "-B", "M", "/var");
203 # Loop through the output.
204 foreach my $line (@df) {
205 # Ignore header line.
206 next if $line =~ m/^Filesystem/;
208 # Search for a line with the device information.
209 if ($line =~ m/dev/ ) {
210 # Split the line into single pieces.
211 my @values = split(' ', $line);
212 my ($filesystem, $blocks, $used, $available, $used_perenctage, $mounted_on) = @values;
214 # Check if the available disk space is more than 300MB.
215 if ($available < 300) {
216 # Log error to syslog.
217 &_log_to_syslog
("Not enough free disk space on /var. Only $available MB from 300 MB available.");
219 # Exit function and return "1" - False.
225 # Everything okay, return nothing.
230 ## This function is responsible for downloading the configured IDS rulesets or if no one is specified
231 ## all configured rulesets will be downloaded.
233 ## * At first it gathers all configured ruleset providers, initialize the downloader and sets an
234 ## upstream proxy if configured.
235 ## * After that, the given ruleset or in case all rulesets should be downloaded, it will determine wether it
236 ## is enabled or not.
237 ## * The next step will be to generate the final download url, by obtaining the URL for the desired
238 ## ruleset, add the settings for the upstream proxy.
239 ## * Finally the function will grab all the rules files or tarballs from the servers.
241 sub downloadruleset
($) {
244 # If no provider is given default to "all".
247 # Hash to store the providers and access id's, for which rules should be downloaded.
248 my %sheduled_providers = ();
250 # Get used provider settings.
251 my %used_providers = ();
252 &General
::readhasharray
("$providers_settings_file", \
%used_providers);
254 # Check if a ruleset has been configured.
255 unless(%used_providers) {
256 # Log that no ruleset has been configured and abort.
257 &_log_to_syslog
("No ruleset provider has been configured.");
263 # Read proxysettings.
264 my %proxysettings=();
265 &General
::readhash
("${General::swroot}/proxy/settings", \
%proxysettings);
267 # Load required perl module to handle the download.
270 # Init the download module.
271 my $downloader = LWP
::UserAgent
->new;
273 # Set timeout to 10 seconds.
274 $downloader->timeout(10);
276 # Check if an upstream proxy is configured.
277 if ($proxysettings{'UPSTREAM_PROXY'}) {
280 $proxy_url = "http://";
282 # Check if the proxy requires authentication.
283 if (($proxysettings{'UPSTREAM_USER'}) && ($proxysettings{'UPSTREAM_PASSWORD'})) {
284 $proxy_url .= "$proxysettings{'UPSTREAM_USER'}\:$proxysettings{'UPSTREAM_PASSWORD'}\@";
287 # Add proxy server address and port.
288 $proxy_url .= $proxysettings{'UPSTREAM_PROXY'};
290 # Setup proxy settings.
291 $downloader->proxy(['http', 'https'], $proxy_url);
294 # Loop through the hash of configured providers.
295 foreach my $id ( keys %used_providers ) {
296 # Skip providers which are not enabled.
297 next if ($used_providers{$id}[3] ne "enabled");
299 # Obtain the provider handle.
300 my $provider_handle = $used_providers{$id}[0];
302 # Handle update off all providers.
303 if (($provider eq "all") || ($provider_handle eq "$provider")) {
304 # Add provider handle and it's id to the hash of sheduled providers.
305 $sheduled_providers{$provider_handle} = $id;
309 # Loop through the hash of sheduled providers.
310 foreach my $provider ( keys %sheduled_providers) {
311 # Grab the download url for the provider.
312 my $url = $IDS::Ruleset
::Providers
{$provider}{'dl_url'};
314 # Check if the provider requires a subscription.
315 if ($IDS::Ruleset
::Providers
{$provider}{'requires_subscription'} eq "True") {
316 # Grab the previously stored access id for the provider from hash.
317 my $id = $sheduled_providers{$provider};
319 # Grab the subscription code.
320 my $subscription_code = $used_providers{$id}[1];
322 # Add the subscription code to the download url.
323 $url =~ s/\<subscription_code\>/$subscription_code/g;
327 # Abort if no url could be determined for the provider.
329 # Log error and abort.
330 &_log_to_syslog
("Unable to gather a download URL for the selected ruleset provider.");
334 # Variable to store the filesize of the remote object.
337 # The sourcfire (snort rules) does not allow to send "HEAD" requests, so skip this check
338 # for this webserver.
340 # Check if the ruleset source contains "snort.org".
341 unless ($url =~ /\.snort\.org/) {
342 # Pass the requrested url to the downloader.
343 my $request = HTTP
::Request
->new(HEAD
=> $url);
345 # Accept the html header.
346 $request->header('Accept' => 'text/html');
348 # Perform the request and fetch the html header.
349 my $response = $downloader->request($request);
351 # Check if there was any error.
352 unless ($response->is_success) {
354 my $error = $response->status_line();
357 &_log_to_syslog
("Unable to download the ruleset. \($error\)");
359 # Return "1" - false.
363 # Assign the fetched header object.
364 my $header = $response->headers();
366 # Grab the remote file size from the object and store it in the
368 $remote_filesize = $header->content_length;
371 # Load perl module to deal with temporary files.
374 # Generate temporary file name, located in "/var/tmp" and with a suffix of ".tmp".
375 my $tmp = File
::Temp
->new( SUFFIX
=> ".tmp", DIR
=> "/var/tmp/", UNLINK
=> 0 );
376 my $tmpfile = $tmp->filename();
378 # Pass the requested url to the downloader.
379 my $request = HTTP
::Request
->new(GET
=> $url);
381 # Perform the request and save the output into the tmpfile.
382 my $response = $downloader->request($request, $tmpfile);
384 # Check if there was any error.
385 unless ($response->is_success) {
387 my $error = $response->content;
390 &_log_to_syslog
("Unable to download the ruleset. \($error\)");
392 # Return "1" - false.
396 # Load perl stat module.
399 # Perform stat on the tmpfile.
400 my $stat = stat($tmpfile);
402 # Grab the local filesize of the downloaded tarball.
403 my $local_filesize = $stat->size;
405 # Check if both file sizes match.
406 if (($remote_filesize) && ($remote_filesize ne $local_filesize)) {
408 &_log_to_syslog
("Unable to completely download the ruleset. ");
409 &_log_to_syslog
("Only got $local_filesize Bytes instead of $remote_filesize Bytes. ");
411 # Delete temporary file.
414 # Return "1" - false.
418 # Genarate and assign file name and path to store the downloaded rules file.
419 my $dl_rulesfile = &_get_dl_rulesfile
($provider);
421 # Check if a file name could be obtained.
422 unless ($dl_rulesfile) {
424 &_log_to_syslog
("Unable to store the downloaded rules file. ");
426 # Delete downloaded temporary file.
429 # Return "1" - false.
432 # Load file copy module, which contains the move() function.
435 # Overwrite the may existing rulefile or tarball with the downloaded one.
436 move
("$tmpfile", "$dl_rulesfile");
438 # Delete temporary file.
441 # Set correct ownership for the tarball.
442 set_ownership
("$dl_rulesfile");
445 # If we got here, everything worked fine. Return nothing.
450 ## Function to extract a given ruleset.
452 ## In case the ruleset provider offers a plain file, it simply will
455 sub extractruleset
($) {
458 # Load perl module to deal with archives.
461 # Load perl module to deal with files and path.
464 # Load perl module for file copying.
467 # Get full path and downloaded rulesfile for the given provider.
468 my $tarball = &_get_dl_rulesfile
($provider);
470 # Check if the file exists.
471 unless (-f
$tarball) {
472 &_log_to_syslog
("Could not find ruleset file: $tarball");
478 # Check if the temporary directories exist, otherwise create them.
479 mkdir("$tmp_directory") unless (-d
"$tmp_directory");
480 mkdir("$tmp_rules_directory") unless (-d
"$tmp_rules_directory");
481 mkdir("$tmp_conf_directory") unless (-d
"$tmp_conf_directory");
483 # Omit the type (dl_type) of the stored ruleset.
484 my $type = $IDS::Ruleset
::Providers
{$provider}{'dl_type'};
486 # Handle the different ruleset types.
487 if ($type eq "plain") {
488 # Generate destination filename an full path.
489 my $destination = "$tmp_rules_directory/$provider\-ruleset.rules";
491 # Copy the file into the temporary rules directory.
492 copy
($tarball, $destination);
494 } elsif ( $type eq "archive") {
495 # Initialize the tar module.
496 my $tar = Archive
::Tar
->new($tarball);
498 # Get the filelist inside the tarball.
499 my @packed_files = $tar->list_files;
501 # Loop through the filelist.
502 foreach my $packed_file (@packed_files) {
505 # Splitt the packed file into chunks.
506 my $file = fileparse
($packed_file);
508 # Handle msg-id.map file.
509 if ("$file" eq "sid-msg.map") {
510 # Set extract destination to temporary config_dir.
511 $destination = "$tmp_conf_directory/$provider\-sid-msg.map";
513 # Handle classification.conf
514 } elsif ("$file" eq "classification.config") {
515 # Set extract destination to temporary config_dir.
516 $destination = "$tmp_conf_directory/$provider\-classification.config";
518 # Handle rules files.
519 } elsif ($file =~ m/\.rules$/) {
522 # Splitt the filename into chunks.
523 my @filename = split("-", $file);
526 @filename = reverse(@filename);
528 # Get the amount of elements in the array.
529 my $elements = @filename;
531 # Remove last element of the hash.
532 # It contains the vendor name, which will be replaced.
533 if ($elements >= 3) {
534 # Remove last element from hash.
538 # Check if the last element of the filename does not
539 # contain the providers name.
540 if ($filename[-1] ne "$provider") {
541 # Add provider name as last element.
542 push(@filename, $provider);
545 # Reverse the array back.
546 @filename = reverse(@filename);
548 # Generate the name for the rulesfile.
549 $rulesfilename = join("-", @filename);
551 # Set extract destination to temporaray rules_dir.
552 $destination = "$tmp_rules_directory/$rulesfilename";
554 # Skip all other files.
558 # Extract the file to the temporary directory.
559 $tar->extract_file("$packed_file", "$destination");
565 ## A wrapper function to call the oinkmaster script, setup the rules structues and
566 ## call the functions to merge the additional config files. (classification, sid-msg, etc.).
569 # Check if the files in rulesdir have the correct permissions.
570 &_check_rulesdir_permissions
();
572 # Cleanup the rules directory before filling it with the new rulests.
573 &_cleanup_rulesdir
();
575 # Get all enabled providers.
576 my @enabled_providers = &get_enabled_providers
();
578 # Loop through the array of enabled providers.
579 foreach my $provider (@enabled_providers) {
580 # Call the extractruleset function.
581 &extractruleset
($provider);
584 # Load perl module to talk to the kernel syslog.
585 use Sys
::Syslog
qw(:DEFAULT setlogsock);
587 # Establish the connection to the syslog service.
588 openlog
('oinkmaster', 'cons,pid', 'user');
590 # Call oinkmaster to generate ruleset.
591 open(OINKMASTER
, "/usr/local/bin/oinkmaster.pl -s -u dir://$tmp_rules_directory -C $settingsdir/oinkmaster.conf -o $rulespath 2>&1 |") or die "Could not execute oinkmaster $!\n";
593 # Log output of oinkmaster to syslog.
594 while(<OINKMASTER
>) {
595 # The syslog function works best with an array based input,
596 # so generate one before passing the message details to syslog.
597 my @syslog = ("INFO", "$_");
599 # Send the log message.
603 # Close the pipe to oinkmaster process.
606 # Close the log handle.
609 # Call function to merge the classification files.
610 &merge_classifications
(@enabled_providers);
612 # Call function to merge the sid to message mapping files.
613 &merge_sid_msg
(@enabled_providers);
615 # Cleanup temporary directory.
616 &cleanup_tmp_directory
();
620 ## Function to merge the classifications for a given amount of providers and write them
621 ## to the classifications file.
623 sub merge_classifications
(@
) {
626 # Hash to store all collected classifications.
627 my %classifications = ();
629 # Loop through the given array of providers.
630 foreach my $provider (@providers) {
631 # Generate full path to classification file.
632 my $classification_file = "$tmp_conf_directory/$provider\-classification.config";
634 # Skip provider if no classification file exists.
635 next unless (-f
"$classification_file");
637 # Open the classification file.
638 open(CLASSIFICATION
, $classification_file) or die "Could not open file $classification_file. $!\n";
640 # Loop through the file content.
641 while(<CLASSIFICATION
>) {
642 # Parse the file and grab the classification details.
643 if ($_ =~/.*config classification\: (.*)/) {
644 # Split the grabbed details.
645 my ($short_name, $short_desc, $priority) = split("\,", $1);
647 # Check if the grabbed classification is allready known and the priority value is greater
648 # than the stored one (which causes less priority in the IDS).
649 if (($classifications{$short_name}) && ($classifications{$short_name}[1] >= $priority)) {
650 #Change the priority value to the stricter one.
651 $classifications{$short_name} = [ "$classifications{$short_name}[0]", "$priority" ];
653 # Add the classification to the hash.
654 $classifications{$short_name} = [ "$short_desc", "$priority" ];
660 close(CLASSIFICATION
);
663 # Open classification file for writing.
664 open(FILE
, ">", "$classification_file") or die "Could not write to $classification_file. $!\n";
666 # Print notice about autogenerated file.
667 print FILE
"#Autogenerated file. Any custom changes will be overwritten!\n\n";
669 # Sort and loop through the hash of classifications.
670 foreach my $key (sort keys %classifications) {
671 # Assign some nice variable names for the items.
672 my $short_name = $key;
673 my $short_desc = $classifications{$key}[0];
674 my $priority = $classifications{$key}[1];
676 # Write the classification to the file.
677 print FILE
"config classification: $short_name,$short_desc,$priority\n";
685 ## Function to merge the "sid to message mapping" files of various given providers.
687 sub merge_sid_msg
(@
) {
690 # Hash which contains all the sid to message mappings.
693 # Loop through the array of given providers.
694 foreach my $provider (@providers) {
695 # Generate full path and filename.
696 my $sid_msg_file = "$tmp_conf_directory/$provider\-sid-msg.map";
698 # Skip provider if no sid to msg mapping file for this provider exists.
699 next unless (-f
$sid_msg_file);
702 open(MAPPING
, $sid_msg_file) or die "Could not open $sid_msg_file. $!\n";
704 # Loop through the file content.
709 # Skip lines which do not start with a number,
710 next unless ($_ =~ /^\d+/);
712 # Split line content and assign it to an array.
713 my @line = split(/ \|\| /, $_);
715 # Grab the first element (and remove it) from the line array.
716 # It contains the sid.
717 my $sid = shift(@line);
719 # Store the grabbed sid and the remain array as hash value.
720 # It still contains the messages, references etc.
721 $mappings{$sid} = [@line];
728 # Open mappings file for writing.
729 open(FILE
, ">", $sid_msg_file) or die "Could not write $sid_msg_file. $!\n";
731 # Write notice about autogenerated file.
732 print FILE
"#Autogenerated file. Any custom changes will be overwritten!\n\n";
734 # Loop through the hash of mappings.
735 foreach my $sid ( sort keys %mappings) {
736 # Grab data for the sid.
737 my @data = @
{$mappings{$sid}};
739 # Add the sid to the data array.
740 unshift(@data, $sid);
743 my $line = join(" \|\| ", @data);
745 print FILE
"$line\n";
754 ## A very tiny function to move an extracted ruleset from the temporary directory into
755 ## the rules directory.
757 sub move_tmp_ruleset
() {
761 # Do a directory listing of the temporary directory.
762 opendir DH
, $tmp_rules_directory;
764 # Loop over all files.
765 while(my $file = readdir DH
) {
766 # Move them to the rules directory.
767 move
"$tmp_rules_directory/$file" , "$rulespath/$file";
770 # Close directory handle.
775 ## Function to cleanup the temporary IDS directroy.
777 sub cleanup_tmp_directory
() {
778 # Load rmtree() function from file path perl module.
779 use File
::Path
'rmtree';
781 # Delete temporary directory and all containing files.
782 rmtree
([ "$tmp_directory" ]);
786 ## Function to do all the logging stuff if the downloading or updating of the ruleset fails.
791 # Remove any newline.
794 # Call private function to log the error message to syslog.
795 &_log_to_syslog
($error);
797 # Call private function to write/store the error message in the storederrorfile.
798 &_store_error_message
($error);
802 ## Function to log a given error message to the kernel syslog.
804 sub _log_to_syslog
($) {
807 # Load perl module to talk to the kernel syslog.
808 use Sys
::Syslog
qw(:DEFAULT setlogsock);
810 # The syslog function works best with an array based input,
811 # so generate one before passing the message details to syslog.
812 my @syslog = ("ERR", "<ERROR> $message");
814 # Establish the connection to the syslog service.
815 openlog
('oinkmaster', 'cons,pid', 'user');
817 # Send the log message.
820 # Close the log handle.
825 ## Private function to write a given error message to the storederror file.
827 sub _store_error_message
($) {
830 # Remove any newline.
833 # Open file for writing.
834 open (ERRORFILE
, ">$storederrorfile") or die "Could not write to $storederrorfile. $!\n";
836 # Write error to file.
837 print ERRORFILE
"$message\n";
842 # Set correct ownership for the file.
843 &set_ownership
("$storederrorfile");
847 ## Private function to get the path and filename for a downloaded ruleset by a given provider.
849 sub _get_dl_rulesfile
($) {
852 # Gather the download type for the given provider.
853 my $dl_type = $IDS::Ruleset
::Providers
{$provider}{'dl_type'};
855 # Obtain the file suffix for the download file type.
856 my $suffix = $dl_type_to_suffix{$dl_type};
858 # Check if a suffix has been found.
860 # Abort return - nothing.
864 # Generate the full filename and path for the stored rules file.
865 my $rulesfile = "$dl_rules_path/$dl_rulesfile_prefix-$provider$suffix";
867 # Check if the file exists.
868 unless (-f
"$rulesfile") {
869 # Abort return - nothing.
873 # Return the generated filename.
878 ## Tiny function to delete the stored ruleset file or tarball for a given provider.
880 sub drop_dl_rulesfile
($) {
883 # Gather the full path and name of the stored rulesfile.
884 my $rulesfile = &_get_dl_rulesfile
($provider);
886 # Check if the given rulesfile exists.
888 # Delete the stored rulesfile.
889 unlink($rulesfile) or die "Could not delete $rulesfile. $!\n";
894 ## Tiny function to get/generate the full path and filename for the providers oinkmaster
895 ## modified sids file.
897 sub get_oinkmaster_provider_modified_sids_file
($) {
900 # Generate the filename.
901 my $filename = "$settingsdir/oinkmaster-$provider-modified-sids.conf";
903 # Return the filename.
908 ## Function to directly altering the oinkmaster provider includes file.
910 ## Requires tha acition "remove" or "add" and a provider handle.
912 sub alter_oinkmaster_provider_includes_file
($$) {
913 my ($action, $provider) = @_;
915 # Call function to get the path and name for the given providers
916 # oinkmaster modified sids file.
917 my $provider_modified_sids_file = &get_oinkmaster_provider_modified_sids_file
($provider);
919 # Open the file for reading..
920 open (FILE
, $oinkmaster_provider_includes_file) or die "Could not read $oinkmaster_provider_includes_file. $!\n";
922 # Read-in file content.
925 # Close file after reading.
928 # Re-open the file for writing.
929 open(FILE
, ">", $oinkmaster_provider_includes_file) or die "Could not write to $oinkmaster_provider_includes_file. $!\n";
931 # Loop through the file content.
932 foreach my $line (@lines) {
936 # Skip line if we found our given provider and the action should be remove.
937 next if (($line =~ /$provider/) && ($action eq "remove"));
939 # Write the read-in line back to the file.
940 print FILE
"$line\n";
943 # Check if the file exists and add the provider if requested.
944 if ((-f
$provider_modified_sids_file) && ($action eq "add")) {
945 print FILE
"include $provider_modified_sids_file\n";
953 ## Function to read-in the given enabled or disables sids file.
955 sub read_enabled_disabled_sids_file
($) {
958 # Temporary hash to store the sids and their state. It will be
959 # returned at the end of this function.
962 # Open the given filename.
963 open(FILE
, "$file") or die "Could not open $file. $!\n";
965 # Loop through the file.
971 next if ($_ =~ /^\s*$/);
974 next if ($_ =~ /^\#/);
976 # Splitt line into sid and state part.
977 my ($state, $sid) = split(" ", $_);
979 # Skip line if the sid is not numeric.
980 next unless ($sid =~ /\d+/ );
982 # Check if the sid was enabled.
983 if ($state eq "enablesid") {
984 # Add the sid and its state as enabled to the temporary hash.
985 $temphash{$sid} = "enabled";
986 # Check if the sid was disabled.
987 } elsif ($state eq "disablesid") {
988 # Add the sid and its state as disabled to the temporary hash.
989 $temphash{$sid} = "disabled";
990 # Invalid state - skip the current sid and state.
1004 ## Function to check if the IDS is running.
1006 sub ids_is_running
() {
1007 if(-f
$idspidfile) {
1008 # Open PID file for reading.
1009 open(PIDFILE
, "$idspidfile") or die "Could not open $idspidfile. $!\n";
1011 # Grab the process-id.
1012 my $pid = <PIDFILE
>;
1017 # Remove any newline.
1020 # Check if a directory for the process-id exists in proc.
1021 if(-d
"/proc/$pid") {
1022 # The IDS daemon is running return the process id.
1027 # Return nothing - IDS is not running.
1032 ## Function to call suricatactrl binary with a given command.
1034 sub call_suricatactrl
($) {
1035 # Get called option.
1036 my ($option, $interval) = @_;
1038 # Loop through the array of supported commands and check if
1039 # the given one is part of it.
1040 foreach my $cmd (@suricatactrl_cmds) {
1041 # Skip current command unless the given one has been found.
1042 next unless($cmd eq $option);
1044 # Check if the given command is "cron".
1045 if ($option eq "cron") {
1046 # Check if an interval has been given.
1048 # Check if the given interval is valid.
1049 foreach my $element (@cron_intervals) {
1050 # Skip current element until the given one has been found.
1051 next unless($element eq $interval);
1053 # Call the suricatactrl binary and pass the "cron" command
1054 # with the requrested interval.
1055 &General
::system("$suricatactrl", "$option", "$interval");
1057 # Return "1" - True.
1062 # If we got here, the given interval is not supported or none has been given. - Return nothing.
1065 # Call the suricatactrl binary and pass the requrested
1067 &General
::system("$suricatactrl", "$option");
1069 # Return "1" - True.
1074 # Command not found - return nothing.
1079 ## Function to create a new empty file.
1081 sub create_empty_file
($) {
1084 # Check if the given file exists.
1086 # Do nothing to prevent from overwriting existing files.
1090 # Open the file for writing.
1091 open(FILE
, ">$file") or die "Could not write to $file. $!\n";
1093 # Close file handle.
1101 ## Private function to check if the file permission of the rulespath are correct.
1102 ## If not, call suricatactrl to fix them.
1104 sub _check_rulesdir_permissions
() {
1105 # Check if the rulepath main directory is writable.
1106 unless (-W
$rulespath) {
1107 # If not call suricatctrl to fix it.
1108 &call_suricatactrl
("fix-rules-dir");
1111 # Open snort rules directory and do a directory listing.
1112 opendir(DIR
, $rulespath) or die $!;
1113 # Loop through the direcory.
1114 while (my $file = readdir(DIR
)) {
1115 # We only want files.
1116 next unless (-f
"$rulespath/$file");
1118 # Check if the file is writable by the user.
1119 if (-W
"$rulespath/$file") {
1120 # Everything is okay - go on to the next file.
1123 # There are wrong permissions, call suricatactrl to fix it.
1124 &call_suricatactrl
("fix-rules-dir");
1130 ## Private function to cleanup the directory which contains
1131 ## the IDS rules, before extracting and modifing the new ruleset.
1133 sub _cleanup_rulesdir
() {
1134 # Open rules directory and do a directory listing.
1135 opendir(DIR
, $rulespath) or die $!;
1137 # Loop through the direcory.
1138 while (my $file = readdir(DIR
)) {
1139 # We only want files.
1140 next unless (-f
"$rulespath/$file");
1142 # Skip element if it has config as file extension.
1143 next if ($file =~ m/\.config$/);
1145 # Skip rules file for whitelisted hosts.
1146 next if ("$rulespath/$file" eq $whitelist_file);
1148 # Skip rules file with local rules.
1149 next if ("$rulespath/$file" eq $local_rules_file);
1151 # Delete the current processed file, if not, exit this function
1152 # and return an error message.
1153 unlink("$rulespath/$file") or return "Could not delete $rulespath/$file. $!\n";
1161 ## Function to generate the file which contains the home net information.
1163 sub generate_home_net_file
() {
1166 # Read-in network settings.
1167 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
1169 # Get available network zones.
1170 my @network_zones = &Network
::get_available_network_zones
();
1172 # Temporary array to store network address and prefix of the configured
1176 # Loop through the array of available network zones.
1177 foreach my $zone (@network_zones) {
1178 # Check if the current processed zone is red.
1179 if($zone eq "red") {
1180 # Grab the IP-address of the red interface.
1181 my $red_address = &get_red_address
();
1183 # Check if an address has been obtained.
1185 # Generate full network string.
1186 my $red_network = join("/", $red_address, "32");
1188 # Add the red network to the array of networks.
1189 push(@networks, $red_network);
1192 # Check if the configured RED_TYPE is static.
1193 if ($netsettings{'RED_TYPE'} eq "STATIC") {
1194 # Get configured and enabled aliases.
1195 my @aliases = &get_aliases
();
1197 # Loop through the array.
1198 foreach my $alias (@aliases) {
1200 my $network = join("/", $alias, "32");
1202 # Add the generated network to the array of networks.
1203 push(@networks, $network);
1206 # Process remaining network zones.
1208 # Convert current zone name into upper case.
1211 # Generate key to access the required data from the netsettings hash.
1212 my $zone_netaddress = $zone . "_NETADDRESS";
1213 my $zone_netmask = $zone . "_NETMASK";
1215 # Obtain the settings from the netsettings hash.
1216 my $netaddress = $netsettings{$zone_netaddress};
1217 my $netmask = $netsettings{$zone_netmask};
1219 # Convert the subnetmask into prefix notation.
1220 my $prefix = &Network
::convert_netmask2prefix
($netmask);
1222 # Generate full network string.
1223 my $network = join("/", $netaddress,$prefix);
1225 # Check if the network is valid.
1226 if(&Network
::check_subnet
($network)) {
1227 # Add the generated network to the array of networks.
1228 push(@networks, $network);
1233 # Format home net declaration.
1234 my $line = "\"[" . join(',', @networks) . "]\"";
1236 # Open file to store the addresses of the home net.
1237 open(FILE
, ">$homenet_file") or die "Could not open $homenet_file. $!\n";
1239 # Print yaml header.
1240 print FILE
"%YAML 1.1\n";
1241 print FILE
"---\n\n";
1243 # Print notice about autogenerated file.
1244 print FILE
"#Autogenerated file. Any custom changes will be overwritten!\n";
1246 # Print the generated and required HOME_NET declaration to the file.
1247 print FILE
"HOME_NET:\t$line\n";
1249 # Close file handle.
1254 # Function to generate and write the file which contains the configured and used DNS servers.
1256 sub generate_dns_servers_file
() {
1257 # Get the used DNS servers.
1258 my @nameservers = &General
::get_nameservers
();
1260 # Get network settings.
1262 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
1264 # Format dns servers declaration.
1267 # Check if the system has configured nameservers.
1269 # Add the GREEN address as DNS servers.
1270 push(@nameservers, $netsettings{'GREEN_ADDRESS'});
1272 # Check if a BLUE zone exists.
1273 if ($netsettings{'BLUE_ADDRESS'}) {
1274 # Add the BLUE address to the array of nameservers.
1275 push(@nameservers, $netsettings{'BLUE_ADDRESS'});
1278 # Generate the line which will be written to the DNS servers file.
1279 $line = join(",", @nameservers);
1281 # External net simply contains (any).
1282 $line = "\$EXTERNAL_NET";
1285 # Open file to store the used DNS server addresses.
1286 open(FILE
, ">$dns_servers_file") or die "Could not open $dns_servers_file. $!\n";
1288 # Print yaml header.
1289 print FILE
"%YAML 1.1\n";
1290 print FILE
"---\n\n";
1292 # Print notice about autogenerated file.
1293 print FILE
"#Autogenerated file. Any custom changes will be overwritten!\n";
1295 # Print the generated DNS declaration to the file.
1296 print FILE
"DNS_SERVERS:\t\"[$line]\"\n";
1298 # Close file handle.
1303 # Function to generate and write the file which contains the HTTP_PORTS definition.
1305 sub generate_http_ports_file
() {
1308 # Read-in proxy settings
1309 &General
::readhash
("${General::swroot}/proxy/advanced/settings", \
%proxysettings);
1311 # Check if the proxy is enabled.
1312 if (( -e
"${General::swroot}/proxy/enable") || (-e
"${General::swroot}/proxy/enable_blue")) {
1313 # Add the proxy port to the array of HTTP ports.
1314 push(@http_ports, $proxysettings{'PROXY_PORT'});
1317 # Check if the transparent mode of the proxy is enabled.
1318 if ((-e
"${General::swroot}/proxy/transparent") || (-e
"${General::swroot}/proxy/transparent_blue")) {
1319 # Add the transparent proxy port to the array of HTTP ports.
1320 push(@http_ports, $proxysettings{'TRANSPARENT_PORT'});
1323 # Format HTTP_PORTS declaration.
1326 # Generate line which will be written to the http ports file.
1327 $line = join(",", @http_ports);
1329 # Open file to store the HTTP_PORTS.
1330 open(FILE
, ">$http_ports_file") or die "Could not open $http_ports_file. $!\n";
1332 # Print yaml header.
1333 print FILE
"%YAML 1.1\n";
1334 print FILE
"---\n\n";
1336 # Print notice about autogenerated file.
1337 print FILE
"#Autogenerated file. Any custom changes will be overwritten!\n";
1339 # Print the generated HTTP_PORTS declaration to the file.
1340 print FILE
"HTTP_PORTS:\t\"[$line]\"\n";
1342 # Close file handle.
1347 ## Function to generate and write the file for used rulefiles file for a given provider.
1349 ## The function requires as first argument a provider handle, and as second an array with files.
1351 sub write_used_provider_rulefiles_file
($@
) {
1352 my ($provider, @files) = @_;
1354 # Get the path and file for the provider specific used rulefiles file.
1355 my $used_provider_rulesfile_file = &get_used_provider_rulesfile_file
($provider);
1357 # Open file for used rulefiles.
1358 open (FILE
, ">", "$used_provider_rulesfile_file") or die "Could not write to $used_provider_rulesfile_file. $!\n";
1360 # Write yaml header to the file.
1361 print FILE
"%YAML 1.1\n";
1362 print FILE
"---\n\n";
1364 # Write header to file.
1365 print FILE
"#Autogenerated file. Any custom changes will be overwritten!\n";
1367 # Loop through the array of given files.
1368 foreach my $file (@files) {
1369 # Check if the given filename exists and write it to the file of used rulefiles.
1370 if(-f
"$rulespath/$file") {
1371 print FILE
" - $file\n";
1375 # Close file after writing.
1380 ## Function to write the main file for provider rulesfiles inclusions.
1382 ## This function requires an array of provider handles.
1384 sub write_main_used_rulefiles_file
(@
) {
1385 my (@providers) = @_;
1387 # Call function to write the static rulefiles file.
1388 &_write_static_rulefiles_file
();
1390 # Open file for used rulefils inclusion.
1391 open (FILE
, ">", "$suricata_used_providers_file") or die "Could not write to $suricata_used_providers_file. $!\n";
1393 # Write yaml header to the file.
1394 print FILE
"%YAML 1.1\n";
1395 print FILE
"---\n\n";
1397 # Write header to file.
1398 print FILE
"#Autogenerated file. Any custom changes will be overwritten!\n";
1400 # Loop through the list of given providers.
1401 foreach my $provider (@providers) {
1402 # Call function to get the providers used rulefiles file.
1403 my $filename = &get_used_provider_rulesfile_file
($provider);
1405 # Check if the file exists and write it into the used rulefiles file.
1407 # Print the provider to the file.
1408 print FILE
"include\: $filename\n";
1412 # Always include the file which hold the static includes.
1413 print FILE
"include\: $suricata_static_rulefiles_file\n";
1415 # Close the filehandle after writing.
1419 sub _write_static_rulefiles_file
() {
1421 open (FILE
, ">", $suricata_static_rulefiles_file) or die "Could not write to $suricata_static_rulefiles_file. $!\n";
1423 # Write yaml header to the file.
1424 print FILE
"%YAML 1.1\n";
1425 print FILE
"---\n\n";
1427 # Write notice about autogenerated file.
1428 print FILE
"#Autogenerated file. Any custom changes will be overwritten!\n";
1430 # Loop through the array of static included rulesfiles.
1431 foreach my $file (@static_included_rulefiles) {
1432 # Check if the file exists.
1433 if (-f
"$rulespath/$file") {
1434 # Write the rulesfile name to the file.
1435 print FILE
" - $file\n";
1439 # Close the file handle
1444 ## Tiny function to generate the full path and name for the used_provider_rulesfile file of a given provider.
1446 sub get_used_provider_rulesfile_file
($) {
1447 my ($provider) = @_;
1449 my $filename = "$settingsdir/suricata\-$provider\-used\-rulefiles.yaml";
1451 # Return the gernerated file.
1456 ## Function to generate and write the file for modify the ruleset.
1458 sub write_modify_sids_file
() {
1459 # Get configured settings.
1461 &General
::readhash
("$ids_settings_file", \
%idssettings);
1463 # Open modify sid's file for writing.
1464 open(FILE
, ">$modify_sids_file") or die "Could not write to $modify_sids_file. $!\n";
1466 # Write file header.
1467 print FILE
"#Autogenerated file. Any custom changes will be overwritten!\n";
1469 # Check if the traffic only should be monitored.
1470 unless($idssettings{'MONITOR_TRAFFIC_ONLY'} eq 'on') {
1471 # Suricata is in IPS mode, which means that the rule actions have to be changed
1472 # from 'alert' to 'drop', however not all rules should be changed. Some rules
1473 # exist purely to set a flowbit which is used to convey other information, such
1474 # as a specific type of file being downloaded, to other rulewhich then check for
1475 # malware in that file. Rules which fall into the first category should stay as
1476 # alert since not all flows of that type contain malware.
1478 # These types of rulesfiles contain meta-data which gives the action that should
1479 # be used when in IPS mode. Do the following:
1481 # 1. Disable all rules and set the action to 'drop'
1482 # 2. Set the action back to 'alert' if the rule contains 'flowbits:noalert;'
1483 # This should give rules not in the policy a reasonable default if the user
1484 # manually enables them.
1485 # 3. Enable rules and set actions according to the meta-data strings.
1487 my $policy = 'balanced'; # Placeholder to allow policy to be changed.
1490 modifysid * "^#(?:alert|drop)(.+policy $policy-ips alert)" | "alert\${1}"
1491 modifysid * "^#(?:alert|drop)(.+policy $policy-ips drop)" | "drop\${1}"
1492 modifysid * "^(#?)(?:alert|drop)" | "\${1}drop"
1493 modifysid * "^(#?)drop(.+flowbits:noalert;)" | "\${1}alert\${2}"
1497 # Close file handle.
1502 ## Function to get the ruleset date for a given provider.
1504 ## The function simply return the creation date in a human read-able format
1505 ## of the stored providers rulesfile.
1507 sub get_ruleset_date
($) {
1508 my ($provider) = @_;
1512 # Load neccessary perl modules for file stat and to format the timestamp.
1514 use POSIX
qw( strftime );
1516 # Get the stored rulesfile for this provider.
1517 my $stored_rulesfile = &_get_dl_rulesfile
($provider);
1519 # Check if we got a file.
1520 if ($stored_rulesfile) {
1521 # Call stat on the rulestarball.
1522 my $stat = stat("$stored_rulesfile");
1524 # Get timestamp the file creation.
1525 $mtime = $stat->mtime;
1528 # Check if the timestamp has not been grabbed.
1530 # Return N/A for Not available.
1534 # Convert into human read-able format.
1535 $date = strftime
('%Y-%m-%d %H:%M:%S', localtime($mtime));
1542 ## Function to gather the version of suricata.
1544 sub get_suricata_version
($) {
1547 # Execute piped suricata command and return the version information.
1548 open(SURICATA
, "suricata -V |") or die "Couldn't execute program: $!";
1550 # Grab and store the output of the piped program.
1551 my $version_string = <SURICATA
>;
1557 chomp($version_string);
1559 # Grab the version from the version string.
1560 $version_string =~ /([0-9]+([.][0-9]+)+)/;
1562 # Splitt the version into single chunks.
1563 my ($major_ver, $minor_ver, $patchlevel) = split(/\./, $1);
1565 # Check and return the requested version sheme.
1566 if ($format eq "major") {
1567 # Return the full version.
1568 return "$major_ver";
1569 } elsif ($format eq "minor") {
1570 # Return the major and minor part.
1571 return "$major_ver.$minor_ver";
1573 # Return the full version string.
1574 return "$major_ver.$minor_ver.$patchlevel";
1579 ## Function to generate the rules file with whitelisted addresses.
1581 sub generate_ignore_file
() {
1584 # SID range 1000000-1999999 Reserved for Local Use
1585 # Put your custom rules in this range to avoid conflicts
1588 # Read-in ignoredfile.
1589 &General
::readhasharray
($IDS::ignored_file
, \
%ignored);
1591 # Open ignorefile for writing.
1592 open(FILE
, ">$IDS::whitelist_file") or die "Could not write to $IDS::whitelist_file. $!\n";
1594 # Config file header.
1595 print FILE
"# Autogenerated file.\n";
1596 print FILE
"# All user modifications will be overwritten.\n\n";
1598 # Add all user defined addresses to the whitelist.
1600 # Check if the hash contains any elements.
1601 if (keys (%ignored)) {
1602 # Loop through the entire hash and write the host/network
1603 # and remark to the ignore file.
1604 while ( (my $key) = each %ignored) {
1605 my $address = $ignored{$key}[0];
1606 my $remark = $ignored{$key}[1];
1607 my $status = $ignored{$key}[2];
1609 # Check if the status of the entry is "enabled".
1610 if ($status eq "enabled") {
1611 # Check if the address/network is valid.
1612 if ((&General
::validip
($address)) || (&General
::validipandmask
($address))) {
1613 # Write rule line to the file to pass any traffic from this IP
1614 print FILE
"pass ip $address any -> any any (msg:\"pass all traffic from/to $address\"\; sid:$sid\;)\n";
1627 ## Function to set correct ownership for single files and directories.
1630 sub set_ownership
($) {
1633 # User and group of the WUI.
1634 my $uname = "nobody";
1635 my $grname = "nobody";
1637 # The chown function implemented in perl requies the user and group as nummeric id's.
1638 my $uid = getpwnam($uname);
1639 my $gid = getgrnam($grname);
1641 # Check if the given target exists.
1643 # Stop the script and print error message.
1644 die "The $target does not exist. Cannot change the ownership!\n";
1647 # Check weather the target is a file or directory.
1649 # Change ownership ot the single file.
1650 chown($uid, $gid, "$target");
1651 } elsif (-d
$target) {
1652 # Do a directory listing.
1653 opendir(DIR
, $target) or die $!;
1654 # Loop through the direcory.
1655 while (my $file = readdir(DIR
)) {
1657 # We only want files.
1658 next unless (-f
"$target/$file");
1660 # Set correct ownership for the files.
1661 chown($uid, $gid, "$target/$file");
1666 # Change ownership of the directory.
1667 chown($uid, $gid, "$target");
1672 ## Function to read-in the aliases file and returns all configured and enabled aliases.
1675 # Location of the aliases file.
1676 my $aliases_file = "${General::swroot}/ethernet/aliases";
1678 # Array to store the aliases.
1681 # Check if the file is empty.
1682 if (-z
$aliases_file) {
1683 # Abort nothing to do.
1687 # Open the aliases file.
1688 open(ALIASES
, $aliases_file) or die "Could not open $aliases_file. $!\n";
1690 # Loop through the file content.
1691 while (my $line = <ALIASES
>) {
1695 # Splitt line content into single chunks.
1696 my ($address, $state, $remark) = split(/\,/, $line);
1698 # Check if the state of the current processed alias is "on".
1699 if ($state eq "on") {
1700 # Check if the address is valid.
1701 if(&Network
::check_ip_address
($address)) {
1702 # Add the alias to the array of aliases.
1703 push(@aliases, $address);
1708 # Close file handle.
1716 ## Function to grab the current assigned IP-address on red.
1718 sub get_red_address
() {
1719 # File, which contains the current IP-address of the red interface.
1720 my $file = "${General::swroot}/red/local-ipaddress";
1722 # Check if the file exists.
1724 # Open the given file.
1725 open(FILE
, "$file") or die "Could not open $file.";
1727 # Obtain the address from the first line of the file.
1728 my $address = <FILE
>;
1736 # Check if the grabbed address is valid.
1737 if (&General
::validip
($address)) {
1738 # Return the address.
1748 ## Function to get the used rules files of a given provider.
1750 sub read_used_provider_rulesfiles
($) {
1751 my ($provider) = @_;
1753 # Array to store the used rulefiles.
1754 my @used_rulesfiles = ();
1756 # Get the used rulesefile file for the provider.
1757 my $rulesfile_file = &get_used_provider_rulesfile_file
($provider);
1759 # Check if the a used rulesfile exists for this provider.
1760 if (-f
$rulesfile_file) {
1761 # Open the file or used rulefiles and read-in content.
1762 open(FILE
, $rulesfile_file) or die "Could not open $rulesfile_file. $!\n";
1765 # Assign the current line to a nice variable.
1772 next if ($line =~ /\#/);
1775 next if ($line =~ /^\s*$/);
1777 # Gather the rulefile.
1778 if ($line =~ /.*- (.*)/) {
1781 # Add the rulefile to the array of used rulesfiles.
1782 push(@used_rulesfiles, $rulefile);
1790 # Return the array of used rulesfiles.
1791 return @used_rulesfiles;
1795 ## Function to write the lock file for locking the WUI, while
1796 ## the autoupdate script runs.
1798 sub lock_ids_page
() {
1799 # Call subfunction to create the file.
1800 &create_empty_file
($ids_page_lock_file);
1804 ## Function to release the lock of the WUI, again.
1806 sub unlock_ids_page
() {
1808 unlink($ids_page_lock_file);