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 IPFire Team <info@ipfire.org>. #
22 ############################################################################
26 require '/var/ipfire/general-functions.pl';
28 # Location where all config and settings files are stored.
29 our $settingsdir = "${General::swroot}/suricata";
31 # File where the used rulefiles are stored.
32 our $used_rulefiles_file = "$settingsdir/suricata-used-rulefiles.yaml";
34 # File where the addresses of the homenet are stored.
35 our $homenet_file = "$settingsdir/suricata-homenet.yaml";
37 # File which contains the enabled sids.
38 our $enabled_sids_file = "$settingsdir/oinkmaster-enabled-sids.conf";
40 # File which contains the disabled sids.
41 our $disabled_sids_file = "$settingsdir/oinkmaster-disabled-sids.conf";
43 # File which contains wheater the rules should be changed.
44 our $modify_sids_file = "$settingsdir/oinkmaster-modify-sids.conf";
46 # File which stores the configured IPS settings.
47 our $ids_settings_file = "$settingsdir/settings";
49 # File which stores the configured rules-settings.
50 our $rules_settings_file = "$settingsdir/rules-settings";
52 # File which stores the configured settings for whitelisted addresses.
53 our $ignored_file = "$settingsdir/ignored";
55 # Location and name of the tarball which contains the ruleset.
56 our $rulestarball = "/var/tmp/idsrules.tar.gz";
58 # File to store any errors, which also will be read and displayed by the wui.
59 our $storederrorfile = "/tmp/ids_storederror";
61 # File to lock the WUI, while the autoupdate script runs.
62 our $ids_page_lock_file = "/tmp/ids_page_locked";
64 # Location where the rulefiles are stored.
65 our $rulespath = "/var/lib/suricata";
67 # File which contains the rules to whitelist addresses on suricata.
68 our $whitelist_file = "$rulespath/whitelist.rules";
70 # File which contains a list of all supported ruleset sources.
71 # (Sourcefire, Emergingthreads, etc..)
72 our $rulesetsourcesfile = "$settingsdir/ruleset-sources";
74 # The pidfile of the IDS.
75 our $idspidfile = "/var/run/suricata.pid";
77 # Location of suricatactrl.
78 my $suricatactrl = "/usr/local/bin/suricatactrl";
80 # Array with allowed commands of suricatactrl.
81 my @suricatactrl_cmds = ( 'start', 'stop', 'restart', 'reload', 'fix-rules-dir', 'cron' );
83 # Array with supported cron intervals.
84 my @cron_intervals = ('off', 'daily', 'weekly' );
87 ## Function to check and create all IDS related files, if the does not exist.
89 sub check_and_create_filelayout
() {
90 # Check if the files exist and if not, create them.
91 unless (-f
"$enabled_sids_file") { &create_empty_file
($enabled_sids_file); }
92 unless (-f
"$disabled_sids_file") { &create_empty_file
($disabled_sids_file); }
93 unless (-f
"$modify_sids_file") { &create_empty_file
($modify_sids_file); }
94 unless (-f
"$used_rulefiles_file") { &create_empty_file
($used_rulefiles_file); }
95 unless (-f
"$ids_settings_file") { &create_empty_file
($ids_settings_file); }
96 unless (-f
"$rules_settings_file") { &create_empty_file
($rules_settings_file); }
97 unless (-f
"$ignored_file") { &create_empty_file
($ignored_file); }
98 unless (-f
"$whitelist_file" ) { &create_empty_file
($whitelist_file); }
102 ## Function for checking if at least 300MB of free disk space are available
103 ## on the "/var" partition.
105 sub checkdiskspace
() {
106 # Call diskfree to gather the free disk space of /var.
107 my @df = `/bin/df -B M /var`;
109 # Loop through the output.
110 foreach my $line (@df) {
111 # Ignore header line.
112 next if $line =~ m/^Filesystem/;
114 # Search for a line with the device information.
115 if ($line =~ m/dev/ ) {
116 # Split the line into single pieces.
117 my @values = split(' ', $line);
118 my ($filesystem, $blocks, $used, $available, $used_perenctage, $mounted_on) = @values;
120 # Check if the available disk space is more than 300MB.
121 if ($available < 300) {
122 # Log error to syslog.
123 &_log_to_syslog
("Not enough free disk space on /var. Only $available MB from 300 MB available.");
125 # Exit function and return "1" - False.
131 # Everything okay, return nothing.
136 ## This function is responsible for downloading the configured IDS ruleset.
138 ## * At first it obtains from the stored rules settings which ruleset should be downloaded.
139 ## * The next step is to get the download locations for all available rulesets.
140 ## * After that, the function will check if an upstream proxy should be used and grab the settings.
141 ## * The last step will be to generate the final download url, by obtaining the URL for the desired
142 ## ruleset, add the settings for the upstream proxy and final grab the rules tarball from the server.
144 sub downloadruleset
{
145 # Get rules settings.
146 my %rulessettings=();
147 &General
::readhash
("$rules_settings_file", \
%rulessettings);
149 # Check if a ruleset has been configured.
150 unless($rulessettings{'RULES'}) {
151 # Log that no ruleset has been configured and abort.
152 &_log_to_syslog
("No ruleset source has been configured.");
158 # Get all available ruleset locations.
159 my %rulesetsources=();
160 &General
::readhash
($rulesetsourcesfile, \
%rulesetsources);
162 # Read proxysettings.
163 my %proxysettings=();
164 &General
::readhash
("${General::swroot}/proxy/settings", \
%proxysettings);
166 # Load required perl module to handle the download.
169 # Init the download module.
170 my $downloader = LWP
::UserAgent
->new;
172 # Set timeout to 10 seconds.
173 $downloader->timeout(10);
175 # Check if an upstream proxy is configured.
176 if ($proxysettings{'UPSTREAM_PROXY'}) {
179 $proxy_url = "http://";
181 # Check if the proxy requires authentication.
182 if (($proxysettings{'UPSTREAM_USER'}) && ($proxysettings{'UPSTREAM_PASSWORD'})) {
183 $proxy_url .= "$proxysettings{'UPSTREAM_USER'}\:$proxysettings{'UPSTREAM_PASSWORD'}\@";
186 # Add proxy server address and port.
187 $proxy_url .= $proxysettings{'UPSTREAM_PROXY'};
189 # Setup proxy settings.
190 $downloader->proxy(['http', 'https'], $proxy_url);
193 # Grab the right url based on the configured vendor.
194 my $url = $rulesetsources{$rulessettings{'RULES'}};
196 # Check if the vendor requires an oinkcode and add it if needed.
197 $url =~ s/\<oinkcode\>/$rulessettings{'OINKCODE'}/g;
199 # Abort if no url could be determined for the vendor.
201 # Log error and abort.
202 &_log_to_syslog
("Unable to gather a download URL for the selected ruleset.");
206 # Variable to store the filesize of the remote object.
209 # The sourcfire (snort rules) does not allow to send "HEAD" requests, so skip this check
210 # for this webserver.
212 # Check if the ruleset source contains "snort.org".
213 unless ($url =~ /\.snort\.org/) {
214 # Pass the requrested url to the downloader.
215 my $request = HTTP
::Request
->new(HEAD
=> $url);
217 # Accept the html header.
218 $request->header('Accept' => 'text/html');
220 # Perform the request and fetch the html header.
221 my $response = $downloader->request($request);
223 # Check if there was any error.
224 unless ($response->is_success) {
226 my $error = $response->status_line();
229 &_log_to_syslog
("Unable to download the ruleset. \($error\)");
231 # Return "1" - false.
235 # Assign the fetched header object.
236 my $header = $response->headers();
238 # Grab the remote file size from the object and store it in the
240 $remote_filesize = $header->content_length;
243 # Load perl module to deal with temporary files.
246 # Generate temporay file name, located in "/var/tmp" and with a suffix of ".tar.gz".
247 my $tmp = File
::Temp
->new( SUFFIX
=> ".tar.gz", DIR
=> "/var/tmp/", UNLINK
=> 0 );
248 my $tmpfile = $tmp->filename();
250 # Pass the requested url to the downloader.
251 my $request = HTTP
::Request
->new(GET
=> $url);
253 # Perform the request and save the output into the tmpfile.
254 my $response = $downloader->request($request, $tmpfile);
256 # Check if there was any error.
257 unless ($response->is_success) {
259 my $error = $response->content;
262 &_log_to_syslog
("Unable to download the ruleset. \($error\)");
264 # Return "1" - false.
268 # Load perl stat module.
271 # Perform stat on the tmpfile.
272 my $stat = stat($tmpfile);
274 # Grab the local filesize of the downloaded tarball.
275 my $local_filesize = $stat->size;
277 # Check if both file sizes match.
278 if (($remote_filesize) && ($remote_filesize ne $local_filesize)) {
280 &_log_to_syslog
("Unable to completely download the ruleset. ");
281 &_log_to_syslog
("Only got $local_filesize Bytes instead of $remote_filesize Bytes. ");
283 # Delete temporary file.
286 # Return "1" - false.
290 # Load file copy module, which contains the move() function.
293 # Overwrite existing rules tarball with the new downloaded one.
294 move
("$tmpfile", "$rulestarball");
296 # If we got here, everything worked fine. Return nothing.
301 ## A tiny wrapper function to call the oinkmaster script.
304 # Check if the files in rulesdir have the correct permissions.
305 &_check_rulesdir_permissions
();
307 # Cleanup the rules directory before filling it with the new rulest.
308 &_cleanup_rulesdir
();
310 # Load perl module to talk to the kernel syslog.
311 use Sys
::Syslog
qw(:DEFAULT setlogsock);
313 # Establish the connection to the syslog service.
314 openlog
('oinkmaster', 'cons,pid', 'user');
316 # Call oinkmaster to generate ruleset.
317 open(OINKMASTER
, "/usr/local/bin/oinkmaster.pl -s -u file://$rulestarball -C $settingsdir/oinkmaster.conf -o $rulespath 2>&1 |") or die "Could not execute oinkmaster $!\n";
319 # Log output of oinkmaster to syslog.
320 while(<OINKMASTER
>) {
321 # The syslog function works best with an array based input,
322 # so generate one before passing the message details to syslog.
323 my @syslog = ("INFO", "$_");
325 # Send the log message.
329 # Close the pipe to oinkmaster process.
332 # Close the log handle.
337 ## Function to do all the logging stuff if the downloading or updating of the ruleset fails.
342 # Remove any newline.
345 # Call private function to log the error message to syslog.
346 &_log_to_syslog
($error);
348 # Call private function to write/store the error message in the storederrorfile.
349 &_store_error_message
($error);
353 ## Function to log a given error message to the kernel syslog.
355 sub _log_to_syslog
($) {
358 # Load perl module to talk to the kernel syslog.
359 use Sys
::Syslog
qw(:DEFAULT setlogsock);
361 # The syslog function works best with an array based input,
362 # so generate one before passing the message details to syslog.
363 my @syslog = ("ERR", "<ERROR> $message");
365 # Establish the connection to the syslog service.
366 openlog
('oinkmaster', 'cons,pid', 'user');
368 # Send the log message.
371 # Close the log handle.
376 ## Private function to write a given error message to the storederror file.
378 sub _store_error_message
($) {
381 # Remove any newline.
384 # Open file for writing.
385 open (ERRORFILE
, ">$storederrorfile") or die "Could not write to $storederrorfile. $!\n";
387 # Write error to file.
388 print ERRORFILE
"$message\n";
393 # Set correct ownership for the file.
394 &set_ownership
("$storederrorfile");
398 ## Function to get a list of all available network zones.
400 sub get_available_network_zones
() {
402 my %netsettings = ();
403 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
405 # Obtain the configuration type from the netsettings hash.
406 my $config_type = $netsettings{'CONFIG_TYPE'};
408 # Hash which contains the conversation from the config mode
409 # to the existing network interface names. They are stored like
412 # Mode "0" red is a modem and green
413 # Mode "1" red is a netdev and green
414 # Mode "2" red, green and orange
415 # Mode "3" red, green and blue
416 # Mode "4" red, green, blue, orange
417 my %config_type_to_interfaces = (
418 "0" => [ "red", "green" ],
419 "1" => [ "red", "green" ],
420 "2" => [ "red", "green", "orange" ],
421 "3" => [ "red", "green", "blue" ],
422 "4" => [ "red", "green", "blue", "orange" ]
425 # Obtain and dereference the corresponding network interaces based on the read
426 # network config type.
427 my @network_zones = @
{ $config_type_to_interfaces{$config_type} };
430 return @network_zones;
434 ## Function to check if the IDS is running.
436 sub ids_is_running
() {
438 # Open PID file for reading.
439 open(PIDFILE
, "$idspidfile") or die "Could not open $idspidfile. $!\n";
441 # Grab the process-id.
447 # Remove any newline.
450 # Check if a directory for the process-id exists in proc.
451 if(-d
"/proc/$pid") {
452 # The IDS daemon is running return the process id.
457 # Return nothing - IDS is not running.
462 ## Function to call suricatactrl binary with a given command.
464 sub call_suricatactrl
($) {
466 my ($option, $interval) = @_;
468 # Loop through the array of supported commands and check if
469 # the given one is part of it.
470 foreach my $cmd (@suricatactrl_cmds) {
471 # Skip current command unless the given one has been found.
472 next unless($cmd eq $option);
474 # Check if the given command is "cron".
475 if ($option eq "cron") {
476 # Check if an interval has been given.
478 # Check if the given interval is valid.
479 foreach my $element (@cron_intervals) {
480 # Skip current element until the given one has been found.
481 next unless($element eq $interval);
483 # Call the suricatactrl binary and pass the "cron" command
484 # with the requrested interval.
485 system("$suricatactrl $option $interval &>/dev/null");
492 # If we got here, the given interval is not supported or none has been given. - Return nothing.
495 # Call the suricatactrl binary and pass the requrested
497 system("$suricatactrl $option &>/dev/null");
504 # Command not found - return nothing.
509 ## Function to create a new empty file.
511 sub create_empty_file
($) {
514 # Check if the given file exists.
516 # Do nothing to prevent from overwriting existing files.
520 # Open the file for writing.
521 open(FILE
, ">$file") or die "Could not write to $file. $!\n";
531 ## Private function to check if the file permission of the rulespath are correct.
532 ## If not, call suricatactrl to fix them.
534 sub _check_rulesdir_permissions
() {
535 # Check if the rulepath main directory is writable.
536 unless (-W
$rulespath) {
537 # If not call suricatctrl to fix it.
538 &call_suricatactrl
("fix-rules-dir");
541 # Open snort rules directory and do a directory listing.
542 opendir(DIR
, $rulespath) or die $!;
543 # Loop through the direcory.
544 while (my $file = readdir(DIR
)) {
545 # We only want files.
546 next unless (-f
"$rulespath/$file");
548 # Check if the file is writable by the user.
549 if (-W
"$rulespath/$file") {
550 # Everything is okay - go on to the next file.
553 # There are wrong permissions, call suricatactrl to fix it.
554 &call_suricatactrl
("fix-rules-dir");
560 ## Private function to cleanup the directory which contains
561 ## the IDS rules, before extracting and modifing the new ruleset.
563 sub _cleanup_rulesdir
() {
564 # Open rules directory and do a directory listing.
565 opendir(DIR
, $rulespath) or die $!;
567 # Loop through the direcory.
568 while (my $file = readdir(DIR
)) {
569 # We only want files.
570 next unless (-f
"$rulespath/$file");
572 # Skip element if it has config as file extension.
573 next if ($file =~ m/\.config$/);
575 # Delete the current processed file, if not, exit this function
576 # and return an error message.
577 unlink("$rulespath/$file") or return "Could not delete $rulespath/$file. $!\n";
585 ## Function to generate the file which contains the home net information.
587 sub generate_home_net_file
() {
590 # Read-in network settings.
591 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
593 # Get available network zones.
594 my @network_zones = &get_available_network_zones
();
596 # Temporary array to store network address and prefix of the configured
600 # Loop through the array of available network zones.
601 foreach my $zone (@network_zones) {
602 # Check if the current processed zone is red.
604 # Grab the IP-address of the red interface.
605 my $red_address = &get_red_address
();
607 # Check if an address has been obtained.
609 # Generate full network string.
610 my $red_network = join("/", $red_address, "32");
612 # Add the red network to the array of networks.
613 push(@networks, $red_network);
616 # Check if the configured RED_TYPE is static.
617 if ($netsettings{'RED_TYPE'} eq "STATIC") {
618 # Get configured and enabled aliases.
619 my @aliases = &get_aliases
();
621 # Loop through the array.
622 foreach my $alias (@aliases) {
624 my $network = join("/", $alias, "32");
626 # Add the generated network to the array of networks.
627 push(@networks, $network);
630 # Process remaining network zones.
632 # Convert current zone name into upper case.
635 # Generate key to access the required data from the netsettings hash.
636 my $zone_netaddress = $zone . "_NETADDRESS";
637 my $zone_netmask = $zone . "_NETMASK";
639 # Obtain the settings from the netsettings hash.
640 my $netaddress = $netsettings{$zone_netaddress};
641 my $netmask = $netsettings{$zone_netmask};
643 # Convert the subnetmask into prefix notation.
644 my $prefix = &Network
::convert_netmask2prefix
($netmask);
646 # Generate full network string.
647 my $network = join("/", $netaddress,$prefix);
649 # Check if the network is valid.
650 if(&Network
::check_subnet
($network)) {
651 # Add the generated network to the array of networks.
652 push(@networks, $network);
657 # Format home net declaration.
660 # Loop through the array of networks.
661 foreach my $network (@networks) {
662 # Add the network to the line.
663 $line = "$line" . "$network";
665 # Check if the current network was the last in the array.
666 if ($network eq $networks[-1]) {
668 $line = "$line" . "\]\"";
670 # Add "," for the next network.
671 $line = "$line" . "\,";
675 # Open file to store the addresses of the home net.
676 open(FILE
, ">$homenet_file") or die "Could not open $homenet_file. $!\n";
679 print FILE
"%YAML 1.1\n";
680 print FILE
"---\n\n";
682 # Print notice about autogenerated file.
683 print FILE
"#Autogenerated file. Any custom changes will be overwritten!\n";
685 # Print the generated and required HOME_NET declaration to the file.
686 print FILE
"HOME_NET:\t$line\n";
693 ## Function to generate and write the file for used rulefiles.
695 sub write_used_rulefiles_file
(@
) {
698 # Open file for used rulefiles.
699 open (FILE
, ">$used_rulefiles_file") or die "Could not write to $used_rulefiles_file. $!\n";
701 # Write yaml header to the file.
702 print FILE
"%YAML 1.1\n";
703 print FILE
"---\n\n";
705 # Write header to file.
706 print FILE
"#Autogenerated file. Any custom changes will be overwritten!\n";
708 # Allways use the whitelist.
709 print FILE
" - whitelist.rules\n";
711 # Loop through the array of given files.
712 foreach my $file (@files) {
713 # Check if the given filename exists and write it to the file of used rulefiles.
714 if(-f
"$rulespath/$file") {
715 print FILE
" - $file\n";
719 # Close file after writing.
724 ## Function to generate and write the file for modify the ruleset.
726 sub write_modify_sids_file
($) {
727 my ($ruleaction) = @_;
729 # Open modify sid's file for writing.
730 open(FILE
, ">$modify_sids_file") or die "Could not write to $modify_sids_file. $!\n";
733 print FILE
"#Autogenerated file. Any custom changes will be overwritten!\n";
735 # Check if the traffic only should be monitored.
736 unless($ruleaction eq "alert") {
737 # Tell oinkmaster to switch all rules from alert to drop.
738 print FILE
"modifysid \* \"alert\" \| \"drop\"\n";
746 ## Function to gather the version of suricata.
748 sub get_suricata_version
($) {
751 # Execute piped suricata command and return the version information.
752 open(SURICATA
, "suricata -V |") or die "Couldn't execute program: $!";
754 # Grab and store the output of the piped program.
755 my $version_string = <SURICATA
>;
761 chomp($version_string);
763 # Grab the version from the version string.
764 $version_string =~ /([0-9]+([.][0-9]+)+)/;
766 # Splitt the version into single chunks.
767 my ($major_ver, $minor_ver, $patchlevel) = split(/\./, $1);
769 # Check and return the requested version sheme.
770 if ($format eq "major") {
771 # Return the full version.
773 } elsif ($format eq "minor") {
774 # Return the major and minor part.
775 return "$major_ver.$minor_ver";
777 # Return the full version string.
778 return "$major_ver.$minor_ver.$patchlevel";
783 ## Function to generate the rules file with whitelisted addresses.
785 sub generate_ignore_file
() {
788 # SID range 1000000-1999999 Reserved for Local Use
789 # Put your custom rules in this range to avoid conflicts
792 # Read-in ignoredfile.
793 &General
::readhasharray
($IDS::ignored_file
, \
%ignored);
795 # Open ignorefile for writing.
796 open(FILE
, ">$IDS::whitelist_file") or die "Could not write to $IDS::whitelist_file. $!\n";
798 # Config file header.
799 print FILE
"# Autogenerated file.\n";
800 print FILE
"# All user modifications will be overwritten.\n\n";
802 # Add all user defined addresses to the whitelist.
804 # Check if the hash contains any elements.
805 if (keys (%ignored)) {
806 # Loop through the entire hash and write the host/network
807 # and remark to the ignore file.
808 while ( (my $key) = each %ignored) {
809 my $address = $ignored{$key}[0];
810 my $remark = $ignored{$key}[1];
811 my $status = $ignored{$key}[2];
813 # Check if the status of the entry is "enabled".
814 if ($status eq "enabled") {
815 # Check if the address/network is valid.
816 if ((&General
::validip
($address)) || (&General
::validipandmask
($address))) {
817 # Write rule line to the file to pass any traffic from this IP
818 print FILE
"pass ip $address any -> any any (msg:\"pass all traffic from/to $address\"\; sid:$sid\;)\n";
831 ## Function to set correct ownership for single files and directories.
834 sub set_ownership
($) {
837 # User and group of the WUI.
838 my $uname = "nobody";
839 my $grname = "nobody";
841 # The chown function implemented in perl requies the user and group as nummeric id's.
842 my $uid = getpwnam($uname);
843 my $gid = getgrnam($grname);
845 # Check if the given target exists.
847 # Stop the script and print error message.
848 die "The $target does not exist. Cannot change the ownership!\n";
851 # Check weather the target is a file or directory.
853 # Change ownership ot the single file.
854 chown($uid, $gid, "$target");
855 } elsif (-d
$target) {
856 # Do a directory listing.
857 opendir(DIR
, $target) or die $!;
858 # Loop through the direcory.
859 while (my $file = readdir(DIR
)) {
861 # We only want files.
862 next unless (-f
"$target/$file");
864 # Set correct ownership for the files.
865 chown($uid, $gid, "$target/$file");
870 # Change ownership of the directory.
871 chown($uid, $gid, "$target");
876 ## Function to read-in the aliases file and returns all configured and enabled aliases.
879 # Location of the aliases file.
880 my $aliases_file = "${General::swroot}/ethernet/aliases";
882 # Array to store the aliases.
885 # Check if the file is empty.
886 if (-z
$aliases_file) {
887 # Abort nothing to do.
891 # Open the aliases file.
892 open(ALIASES
, $aliases_file) or die "Could not open $aliases_file. $!\n";
894 # Loop through the file content.
895 while (my $line = <ALIASES
>) {
899 # Splitt line content into single chunks.
900 my ($address, $state, $remark) = split(/\,/, $line);
902 # Check if the state of the current processed alias is "on".
903 if ($state eq "on") {
904 # Check if the address is valid.
905 if(&Network
::check_ip_address
($address)) {
906 # Add the alias to the array of aliases.
907 push(@aliases, $address);
920 ## Function to grab the current assigned IP-address on red.
922 sub get_red_address
() {
923 # File, which contains the current IP-address of the red interface.
924 my $file = "${General::swroot}/red/local-ipaddress";
926 # Check if the file exists.
928 # Open the given file.
929 open(FILE
, "$file") or die "Could not open $file.";
931 # Obtain the address from the first line of the file.
932 my $address = <FILE
>;
940 # Check if the grabbed address is valid.
941 if (&General
::validip
($address)) {
942 # Return the address.
952 ## Function to write the lock file for locking the WUI, while
953 ## the autoupdate script runs.
955 sub lock_ids_page
() {
956 # Call subfunction to create the file.
957 &create_empty_file
($ids_page_lock_file);
961 ## Function to release the lock of the WUI, again.
963 sub unlock_ids_page
() {
965 unlink($ids_page_lock_file);