]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
dns.cgi: Introduce red_is_active()
authorStefan Schantl <stefan.schantl@ipfire.org>
Wed, 8 Jan 2020 10:12:42 +0000 (11:12 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Wed, 8 Jan 2020 10:12:42 +0000 (11:12 +0100)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
html/cgi-bin/dns.cgi

index 1e609eb49eb8a16607016016282b8bd40a2bd8fa..54f3aa3c426a796f5c95fcf2fe654b9cddcb5dce 100755 (executable)
@@ -522,7 +522,7 @@ END
                                my $rdns;
 
                                # Only do the reverse lookup if the system is online.
-                               if ( -f "/var/ipfire/red/active") {
+                               if (&red_is_active()) {
                                        my $iaddr = inet_aton($nameserver);
                                        $rdns = gethostbyaddr($iaddr, AF_INET);
                                }
@@ -734,6 +734,18 @@ END
        &Header::closebox();
 }
 
+# Check if the system is online (RED is connected).
+sub red_is_active () {
+       # Check if the "active" file is present.
+       if ( -f "${General::swroot}/red/active") {
+               # Return "1" - True.
+               return 1;
+       } else {
+               # Return nothing - False.
+               return;
+       }
+}
+
 # Tiny function to grab an IP-address of a given file.
 sub grab_address_from_file($) {
        my ($file) = @_;