From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.haj.ipfire.org (localhost [IPv6:::1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4j0z2G0Bvsz2xqy for ; Thu, 08 Oct 2026 18:25:42 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1 raw public key) server-digest SHA384 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mail01.haj.ipfire.org", Issuer "YR1" (not verified)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4j0z2F6t9rz2xPP for ; Thu, 08 Oct 2026 18:25:41 +0000 (UTC) Received: from people01.haj.ipfire.org (people01.haj.ipfire.org [IPv6:2001:678:b28::161]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bit raw public key) server-digest SHA256 client-signature ECDSA (secp384r1) client-digest SHA384) (Client CN "people01.haj.ipfire.org", Issuer "YE1" (not verified)) by mail01.ipfire.org (Postfix) with ESMTPS id 4j0z2F1fgDz46R for ; Thu, 08 Oct 2026 18:25:41 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1791483941; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc; bh=/0EbvmiOYbtI3DQaiGTRo88tOviqEzzGXzhkMhi4QwE=; b=5KQELSI0oSGlEE9MDwQfJP+lMBaoI3Ex0Ef1viHyHHhl2l0za4qw9k4T4BsgCbBeBl+HAg vqzm5AeThGFN8fCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1791483941; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc; bh=/0EbvmiOYbtI3DQaiGTRo88tOviqEzzGXzhkMhi4QwE=; b=UFFaY1FrH2Bxhp4s14+0b+Qji0yq4gjsdc3/0Lz/iF7X9jZ3yNQEGBL8B/hJCfOskeGG1U 7SMTnB1Wa7GTBqRNabDzn5sprNPmdP9x2O1ygISrKBP7v/ZjkHPSd6t8WayWiPE5WekHGv XK+s+w7bR/ffNEvY2BH7KwpJVFsMWrdm2AjccCb55VgFlpG2tgsJgvut0JJa62oteYVYWr PNgD9bT/W2Nec4PAyz0Gcqcgn1KxT2INn0wSPuL/dh375l/Nn0iZl1dc/X/O3t62Bfryc+ EfGvdEGw5Qstz8NX8GByqEpE2M9PyOa86f4Gt61DXKyKNw59zXvg76usBE0b5A== Received: by people01.haj.ipfire.org (Postfix, from userid 1000) id 4j0z2D4cDMz2xQv; Thu, 08 Oct 2026 18:25:40 +0000 (UTC) To: ipfire-scm@lists.ipfire.org Subject: [git.ipfire.org] IPFire 2.x development tree branch, next, updated. e753736607d10c88ab403ddc58e9e15d61687d93 X-Git-Refname: refs/heads/next X-Git-Reftype: branch X-Git-Oldrev: 3cbaad5cf20704b534a4a97fc7fba3328c577996 X-Git-Newrev: e753736607d10c88ab403ddc58e9e15d61687d93 Message-Id: <4j0z2D4cDMz2xQv@people01.haj.ipfire.org> Date: Thu, 08 Oct 2026 18:25:40 +0000 (UTC) From: Michael Tremer X-Spam: Yes Precedence: list List-Id: List-Subscribe: , List-Unsubscribe: , List-Post: List-Help: Sender: Mail-Followup-To: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "IPFire 2.x development tree". The branch, next has been updated via e753736607d10c88ab403ddc58e9e15d61687d93 (commit) via ce2ba3fa84d9705567a1f8d936be5f2e4d436c27 (commit) via aa7193e7724294b50386ff09e66e11bc41480f19 (commit) via ff2fe5ee56b3c7b1ed5ef3a5148153700c7db65d (commit) via 1e4ae8110b3ada2abf40145666cd3f5ebddd06f7 (commit) via c1902fb7bb8f6bdac7eff7f442f475c57ca54862 (commit) via 3faec56c17517138ba58d0602bb89393c4d671cf (commit) via 62acf4e28bc1cbfa1c0d55b5573630dc929d2078 (commit) via 718d92446ec653438ef328307d45481f65ff4baa (commit) via 94177b67dc1dcf8c12c89fcb67288e08f13e12d1 (commit) via f25d800dee0446a6148feb7f02b562eed51a1f14 (commit) via 6cc12f9a24a47b4d0209daa18bf0f1727300a78d (commit) via cd7ff279c50d1b94ce10477b7bdbc3a23be78dde (commit) via 0c24ec9cd610dc986641214b6a686352f06ee9bd (commit) via 9ed829a4a0b4ca667053b988ac554b72fb08f544 (commit) via 54dd632effbee8f32dbfac580c216818fdc5a9ec (commit) via 5162be0312391357bf133b8ae39b0fd1af7aa5ad (commit) via 4acc62b0fe0f152b6771b164e0e13c4596f932a1 (commit) via 81f7420413ab4334b7817cfa64ac41618a828486 (commit) via f7d2648b7582d5c929f0fd0d95577d141fbefbac (commit) via 6d6be4f984840c08983f143a48b555babfa4f017 (commit) via 36bacc44d7b154126bf0cd52dac7e6af5bff2372 (commit) via 193537e3a297cb7577126b57b8249a476ae87f1d (commit) via 097a4764d4c254097873631f9ae2a7d019afe4f2 (commit) via 105af434b4f78edd60cf77aec74d8348fe509e39 (commit) via 356f002c0a3e05b0adeff97f2d6f7351fbb5938c (commit) via 1a173651223112e0ed1aff1318e2364cbf0df9fa (commit) via 29d74edc30ffe2ab789c7d47a58fa04ecb30813b (commit) via d4136952bd452e9f6993e8e3555b356b6349a9b1 (commit) via 69889e5a7592666b8c4ccb64134ff97a51c4b25d (commit) via ffc5ccca6533cc0447592009a14622d24cc41254 (commit) via 5b6f3f9e6a3f610540dc6bd0fd5b2bb81fb266a3 (commit) via 6150e93e727bc3763241930312ff0b26ff3ef6c4 (commit) via dbd0210a65ea2fa99c783b4ebc73a30362b2a0cf (commit) via b079df5d28c34db72f5018a2a5c8e43b3d81cea1 (commit) via 23fc567092ea90bb812d663875147b01e32d3c01 (commit) via 8cca14f598d69f0b7ee94797b80f3b3fe213560c (commit) via 737953bb6721dd2d0c81b3f998b43eeb0dac0248 (commit) via 0a10289996d41498ae79136dc0a8a237ccc33f6f (commit) via 174367f08f30b149f4cd8a5b96c4d6431cc1a2cf (commit) via 7c77bd5f547979f9222f068578d7bc17bad09a2c (commit) via f7436a62372ca001d378ede9bc98946fe142f49c (commit) via 4e7261ef9852e8b0e4b95cc9d61f7e9ccd989224 (commit) via 889d3458e22dbcfaf7c485ee9b9b431777fac1c4 (commit) via a54f1c7511de3b5a23f47aa485f76ccc6535df8b (commit) via 7fa0027e1f9fb4ce2791cbdb9bb1d4bcf45b378f (commit) via cee814148e7c7ec06248de59b054f5579a51edd6 (commit) from 3cbaad5cf20704b534a4a97fc7fba3328c577996 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e753736607d10c88ab403ddc58e9e15d61687d93 Author: Michael Tremer Date: Thu Oct 8 18:24:45 2026 +0000 perl-File-ReadBackwards: Move from package into main system pakfire.cgi is using this module to read the messages of the last Pakfire run from the end of the log file. As it has only been available as a package that was installed together with proxy-accounting, the page would not have loaded on any other system. Signed-off-by: Michael Tremer commit ce2ba3fa84d9705567a1f8d936be5f2e4d436c27 Merge: 3cbaad5cf aa7193e77 Author: Michael Tremer Date: Thu Oct 8 18:22:33 2026 +0000 Merge branch 'webif-cleanup' into next commit aa7193e7724294b50386ff09e66e11bc41480f19 Author: Michael Tremer Date: Thu Oct 8 17:01:35 2026 +0000 header.pl: Show that the system is connecting when pppd is running When the system is not connected, but is supposed to keep the connection up, the connection status has only been showing that the system is connecting when pppd was not running, and that it is idle when pppd was running. This check has been the wrong way around, because system() returns zero when the command was successful. Signed-off-by: Michael Tremer commit ff2fe5ee56b3c7b1ed5ef3a5148153700c7db65d Author: Michael Tremer Date: Thu Oct 8 16:50:35 2026 +0000 web-user-interface: Don't launch commands in a shell A couple of pages have been putting variables into a command line which was then executed by a shell. Those commands are now being launched directly with their arguments passed as a list. iostat has been called three times on the media page, once for each column that is being shown. It is now being called only once. The connection tracking table has been piped through sort, which is now being done in Perl. Signed-off-by: Michael Tremer commit 1e4ae8110b3ada2abf40145666cd3f5ebddd06f7 Author: Michael Tremer Date: Thu Oct 8 16:50:35 2026 +0000 wio.cgi: Don't launch wioscan in a shell When a network is being scanned, the name of the device and the range of IP addresses have been put into a command line which was executed by a shell. The page reads its CGI parameters into the hash that holds the network settings, too. Therefore a request seems to be able to change the name of the device and to have any shell commands executed as the user of the web server. wioscan is now being launched directly with its arguments passed as a list. Signed-off-by: Michael Tremer commit c1902fb7bb8f6bdac7eff7f442f475c57ca54862 Author: Michael Tremer Date: Thu Oct 8 16:45:43 2026 +0000 web-user-interface: Don't launch a shell for trivial things There is no need to launch a shell to create or to empty a file, to find out the release or the architecture of the kernel, or to remove files and to change their permissions. The URL filter has been launching chmod for each file of a blacklist when setting the permissions, which is now being done without launching any processes. It is still calling cp to copy directories, but no longer in a shell. Signed-off-by: Michael Tremer commit 3faec56c17517138ba58d0602bb89393c4d671cf Author: Michael Tremer Date: Thu Oct 8 16:45:42 2026 +0000 wio.pl: Fix command injection when a single client is being checked After a single client has been checked, its line in the list of clients has been replaced by calling sed in a shell command which had all fields of the client passed to it. This includes the remark, which can be freely chosen by the user and only has its commas escaped. Therefore it has been possible to execute any shell commands by adding a client with a remark that contains a single quote and by checking it afterwards. As the web user interface launches wio.pl using wiohelper, which is setuid, those commands have been executed as root. The line is now being replaced without calling any commands and by comparing the entire line instead of matching it as a regular expression. Signed-off-by: Michael Tremer commit 62acf4e28bc1cbfa1c0d55b5573630dc929d2078 Author: Michael Tremer Date: Thu Oct 8 16:45:42 2026 +0000 wio.cgi: Fix command injection when changing the sort order The table of clients can be sorted by clicking on the header of a column which passes the name of the column as query string. Anything that started with IPADR or HOST has been accepted and was then passed to sed in a shell command to change the configuration file. Therefore it has been possible to execute any shell commands as the user of the web server by sending a request like: wio.cgi?IPADR';;' The query string must now be exactly IPADR or HOST and the configuration file is being changed without calling any commands. Signed-off-by: Michael Tremer commit 718d92446ec653438ef328307d45481f65ff4baa Author: Michael Tremer Date: Thu Oct 8 16:41:55 2026 +0000 web-user-interface: Don't call ps or pidof to find processes Who Is Online?, Pakfire and the connection status in the header have been launching ps or pidof to find out whether a process is running. They are now calling General::find_pids() which searches for the process in /proc. The Update Accelerator has been searching the output of ps for the command line of a download. It now reads the command lines from /proc and matches the same expressions against them. The check for pppd in the connection status shows that the system is connecting when pppd is not running. This looks like it is the wrong way around, but has been left like it was. Signed-off-by: Michael Tremer commit 94177b67dc1dcf8c12c89fcb67288e08f13e12d1 Author: Michael Tremer Date: Thu Oct 8 16:36:31 2026 +0000 web-user-interface: Don't launch a shell to read files A couple of pages have been calling cat, grep, tail, awk or cut in a shell to read from a file. The files are now being read directly. The page that shows the status of ATM modems has been launching three shells for each attribute. Attributes that have multiple lines have been shown once for each of their lines and are now only being shown once. The configuration of the Samba shares has been split into its sections by calling tail and head for each section. This did not work if the file was not terminated with a newline character. Pakfire now uses File::ReadBackwards to find the log messages of its last run, which is still reading the log file from its end. Who Is Online? now reads the status of OpenVPN and the PID files without calling cat or awk and searches for the remarks of the connections in the configuration that it has already read. Signed-off-by: Michael Tremer commit f25d800dee0446a6148feb7f02b562eed51a1f14 Author: Michael Tremer Date: Thu Oct 8 16:29:20 2026 +0000 web-user-interface: Don't launch a shell to list files Many pages have been calling ls or find in a shell to find out which graphs, backups or devices are available. This is now being done with glob() which does not launch any other processes. The check for S.M.A.R.T. errors on the home page has also been calling cut and grep for each disk. The files are now being read directly. When listing the backups of add-ons, only files that end with .ipf are being considered now. Before, the last five characters have been cut off any file in the directory. Graphs::getprocesses() has only been calling ls, too, but is not being used anywhere and has therefore been dropped. Signed-off-by: Michael Tremer commit 6cc12f9a24a47b4d0209daa18bf0f1727300a78d Author: Michael Tremer Date: Thu Oct 8 16:20:08 2026 +0000 header.pl: Don't call /bin/cat to read the menu The menu has been put together by launching a shell that ran /bin/cat on all menu files and by evaluating all of its output at once. The files are now being read without launching any other processes and are being evaluated one after the other. That way, a broken file from an add-on no longer removes the entire menu, and any errors are being logged. The menu files remain pieces of Perl code which rely on the variables of genmenu() and can therefore not be loaded in any other way. Signed-off-by: Michael Tremer commit cd7ff279c50d1b94ce10477b7bdbc3a23be78dde Author: Michael Tremer Date: Thu Oct 8 16:12:02 2026 +0000 web-user-interface: Format all sizes with format_bytes() formatBytes() has been renamed to format_bytes() and is now being used in all places that have been printing sizes in bytes, kilobytes or megabytes which is hard to read for large values. This covers the list of backups, the memory and media pages, the Update Accelerator, the repository of the URL filter and the status page of Squid Accounting. Tor had its own copy of the function, which has been dropped. The units have been removed from the labels and from their translations as they are now a part of the value. On the Update Accelerator page, the total cache size has been summed up on top of the size of the last pending download. The counter is now being reset first. Signed-off-by: Michael Tremer commit 0c24ec9cd610dc986641214b6a686352f06ee9bd Author: Michael Tremer Date: Wed Oct 7 15:04:59 2026 +0000 guardian, tor, wio: Bump release The CGIs of these packages have been calling functions that have been removed from general-functions.pl and header.pl. Signed-off-by: Michael Tremer commit 9ed829a4a0b4ca667053b988ac554b72fb08f544 Author: Michael Tremer Date: Wed Oct 7 15:04:59 2026 +0000 core205: Ship the cleaned up network functions The old network functions have been removed from general-functions.pl and header.pl, and some more functions have been moved to where they belong. All libraries and scripts that have been changed need to be shipped together with the web user interface, which is already part of this update. Signed-off-by: Michael Tremer commit 54dd632effbee8f32dbfac580c216818fdc5a9ec Author: Michael Tremer Date: Wed Oct 7 15:02:43 2026 +0000 firewalllog.dat: Move generateProtoTransHash() here The function is only being called by this page to translate the numbers of the protocols in the firewall log into their names. Signed-off-by: Michael Tremer commit 5162be0312391357bf133b8ae39b0fd1af7aa5ad Author: Michael Tremer Date: Wed Oct 7 15:01:54 2026 +0000 Drop protocols.pl This file has a static copy of /etc/protocols, but it is not being installed and nothing has been loading it. Signed-off-by: Michael Tremer commit 4acc62b0fe0f152b6771b164e0e13c4596f932a1 Author: Michael Tremer Date: Wed Oct 7 15:00:15 2026 +0000 dhcp.cgi: Move the functions that show the leases here CheckSortOrder(), PrintActualLeases() and leasesort() have only been called by this page, but have been part of header.pl. They have been using their own copy of the DHCP settings which has only been loaded when the sort order has been changed. Therefore the list has only been sorted right after one of the column headers was clicked, but no longer when the page was loaded again. They are now using the settings of the page, so that the list always remains sorted. The variables are now being declared, because this page is using strict, and header.pl no longer needs Time::Local. Signed-off-by: Michael Tremer commit 81f7420413ab4334b7817cfa64ac41618a828486 Author: Michael Tremer Date: Wed Oct 7 14:58:04 2026 +0000 location-functions.pl: Move validcc() here The function validates a country code and is only being used when a location group is being edited. Signed-off-by: Michael Tremer commit f7d2648b7582d5c929f0fd0d95577d141fbefbac Author: Michael Tremer Date: Wed Oct 7 14:57:29 2026 +0000 http-client-functions.pl: Move DyndnsServiceSync() here The function compares what a hostname resolves to with the IP address that is being returned by GetDyndnsRedIP() which is already here. Signed-off-by: Michael Tremer commit 6d6be4f984840c08983f143a48b555babfa4f017 Author: Michael Tremer Date: Wed Oct 7 14:57:29 2026 +0000 http-client-functions.pl: Move MakeUserAgent() here The function is only being used to send HTTP requests and comes with GetCoreUpdateVersion() which is not being called from anywhere else. ipblocklist-functions.pl is using its own HTTP client and now has to load http-client-functions.pl to compose the user agent. Signed-off-by: Michael Tremer commit 36bacc44d7b154126bf0cd52dac7e6af5bff2372 Author: Michael Tremer Date: Wed Oct 7 14:53:49 2026 +0000 network-functions.pl: Don't pass disabled aliases to the firewall get_aliases() has added all aliases to the hash that is being used by the firewall and the IPsec page, no matter whether they have been enabled or not. Therefore they could be selected although the system does not have that IP address. Aliases that are disabled or invalid are now being skipped. They are still being counted, so that the names of aliases without a remark don't change. Firewall rules that are using a disabled alias as source or destination no longer match anything, and NAT rules are falling back to the default IP address of the RED interface. Signed-off-by: Michael Tremer commit 193537e3a297cb7577126b57b8249a476ae87f1d Author: Michael Tremer Date: Wed Oct 7 14:52:04 2026 +0000 network-functions.pl: Merge the two get_aliases() functions There has been a second function in ids-functions.pl which has read the same file, but returned a list of the addresses of all aliases that are enabled instead of filling a hash for the firewall. Network::get_aliases() now does both. It returns the list and still fills the hash if one is being passed, so that nothing changes for the firewall which refers to aliases without a name by their position. Signed-off-by: Michael Tremer commit 097a4764d4c254097873631f9ae2a7d019afe4f2 Author: Michael Tremer Date: Wed Oct 7 14:48:59 2026 +0000 network-functions.pl: Move get_aliases() here This function reads the aliases of the RED interface and is being used by the firewall. Signed-off-by: Michael Tremer commit 105af434b4f78edd60cf77aec74d8348fe509e39 Author: Michael Tremer Date: Wed Oct 7 14:48:59 2026 +0000 network-functions.pl: Move get_nameservers() here This function returns the configured DNS servers and is only being called by the IDS functions. Signed-off-by: Michael Tremer commit 356f002c0a3e05b0adeff97f2d6f7351fbb5938c Author: Michael Tremer Date: Wed Oct 7 14:48:59 2026 +0000 network-functions.pl: Move grab_address_from_file() here This function reads an IP address from a file and is being used outside of the web user interface. Signed-off-by: Michael Tremer commit 1a173651223112e0ed1aff1318e2364cbf0df9fa Author: Michael Tremer Date: Wed Oct 7 14:48:09 2026 +0000 network-functions.pl: Move validfqdn() here The function is now called check_fqdn(). Signed-off-by: Michael Tremer commit 29d74edc30ffe2ab789c7d47a58fa04ecb30813b Author: Michael Tremer Date: Wed Oct 7 14:48:09 2026 +0000 network-functions.pl: Move validdomainname() and validwildcarddomainname() here The functions are now called check_domainname() and check_wildcard_domainname(). Signed-off-by: Michael Tremer commit d4136952bd452e9f6993e8e3555b356b6349a9b1 Author: Michael Tremer Date: Wed Oct 7 14:48:09 2026 +0000 network-functions.pl: Move validhostname() here The function is now called check_hostname(). Signed-off-by: Michael Tremer commit 69889e5a7592666b8c4ccb64134ff97a51c4b25d Author: Michael Tremer Date: Wed Oct 7 14:48:09 2026 +0000 network-functions.pl: Move validport() here The function is now called check_port() like the other functions that are validating input. validportrange() remains where it is, because it returns translated error messages for the web user interface. Signed-off-by: Michael Tremer commit ffc5ccca6533cc0447592009a14622d24cc41254 Author: Michael Tremer Date: Wed Oct 7 14:48:08 2026 +0000 general-functions.pl: Drop unused functions validproxyport(), GetIcmpDescription(), read_file_utf8() and write_file_utf8() are not being called from anywhere. Signed-off-by: Michael Tremer commit 5b6f3f9e6a3f610540dc6bd0fd5b2bb81fb266a3 Author: Michael Tremer Date: Wed Oct 7 14:45:26 2026 +0000 general-functions.pl: Drop the remaining old network functions IpInSubnet(), getnetworkip(), subtocidr(), cidrtosub(), iporsubtodec() and iporsubtocidr() are no longer being called from anywhere. checksubnets() and check_net_internal_range() have been the last users and are now calling the functions in network-functions.pl. Signed-off-by: Michael Tremer commit 6150e93e727bc3763241930312ff0b26ff3ef6c4 Author: Michael Tremer Date: Wed Oct 7 14:45:26 2026 +0000 Use the functions in network-functions.pl to match and convert subnets General::IpInSubnet() and General::getnetworkip() have only been wrappers around Network::ip_address_in_network() and Network::get_netaddress() which are now being called directly. Both take the netmask as well as the prefix, so that there is no need to convert it using General::iporsubtodec() before. Where a netmask or a prefix is needed, General::iporsubtodec() and iporsubtocidr() are replaced by Network::get_netmask() and Network::get_prefix() which are returning undef for invalid input instead of "3". Signed-off-by: Michael Tremer commit dbd0210a65ea2fa99c783b4ebc73a30362b2a0cf Author: Michael Tremer Date: Wed Oct 7 14:44:57 2026 +0000 Don't call General::subtocidr() and General::cidrtosub() any more These have only been wrappers around Network::convert_netmask2prefix() and Network::convert_prefix2netmask(). Signed-off-by: Michael Tremer commit b079df5d28c34db72f5018a2a5c8e43b3d81cea1 Author: Michael Tremer Date: Wed Oct 7 14:44:57 2026 +0000 general-functions.pl: Drop validipandmask() This is replaced by Network::check_subnet(). Unlike the old function, it accepts networks that start with a zero like 0.0.0.0/0, and it no longer accepts leading zeroes in the address or the prefix. Signed-off-by: Michael Tremer commit 23fc567092ea90bb812d663875147b01e32d3c01 Author: Michael Tremer Date: Wed Oct 7 14:44:56 2026 +0000 general-functions.pl: Drop validip() This is replaced by Network::check_ip_address() which does not accept an IP address that is followed by a newline. Signed-off-by: Michael Tremer commit 8cca14f598d69f0b7ee94797b80f3b3fe213560c Author: Michael Tremer Date: Wed Oct 7 14:44:56 2026 +0000 general-functions.pl: Drop validmask() This has only been a wrapper around Network::check_netmask() and Network::check_prefix(). Signed-off-by: Michael Tremer commit 737953bb6721dd2d0c81b3f998b43eeb0dac0248 Author: Michael Tremer Date: Wed Oct 7 14:44:56 2026 +0000 general-functions.pl: Drop validipormask() The callers are now checking for an IP address or a subnet using Network::check_ip_address() and Network::check_subnet(). Signed-off-by: Michael Tremer commit 0a10289996d41498ae79136dc0a8a237ccc33f6f Author: Michael Tremer Date: Wed Oct 7 14:44:56 2026 +0000 general-functions.pl: Drop ip2dec() and dec2ip() These have only been wrappers around Network::ip2bin() and Network::bin2ip(). Signed-off-by: Michael Tremer commit 174367f08f30b149f4cd8a5b96c4d6431cc1a2cf Author: Michael Tremer Date: Wed Oct 7 14:44:56 2026 +0000 general-functions.pl: Drop validmac() This is replaced by Network::valid_mac(). Signed-off-by: Michael Tremer commit 7c77bd5f547979f9222f068578d7bc17bad09a2c Author: Michael Tremer Date: Wed Oct 7 14:44:56 2026 +0000 header.pl: Drop orange_used() and blue_used() Network::is_zone_available() does the same and can be used outside of the web user interface. green_used() remains, because it checks whether a device has been assigned, which is_zone_available() does not do. Signed-off-by: Michael Tremer commit f7436a62372ca001d378ede9bc98946fe142f49c Author: Michael Tremer Date: Wed Oct 7 14:44:55 2026 +0000 network-functions.pl: Move RedIsWireless() here The function is now called is_red_wireless() like the other functions that are checking the configuration of the zones. Signed-off-by: Michael Tremer commit 4e7261ef9852e8b0e4b95cc9d61f7e9ccd989224 Author: Michael Tremer Date: Wed Oct 7 14:44:55 2026 +0000 network-functions.pl: Move get_red_interface() here This function has nothing to do with the web user interface and has already been called by Network::get_red_interfaces(). Signed-off-by: Michael Tremer commit 889d3458e22dbcfaf7c485ee9b9b431777fac1c4 Author: Michael Tremer Date: Wed Oct 7 14:44:48 2026 +0000 http-client-functions.pl: Fix typo in the RFC1918 check There has been a trailing dot after 172.16.0.0 which is not a valid IP address. Therefore 172.16.0.0/12 has never been considered private. Signed-off-by: Michael Tremer commit a54f1c7511de3b5a23f47aa485f76ccc6535df8b Author: Michael Tremer Date: Wed Oct 7 14:44:48 2026 +0000 network-functions.pl: Fix the prototype of is_zone_available() The function takes the name of the zone, but has been declared to take no arguments at all. Signed-off-by: Michael Tremer commit 7fa0027e1f9fb4ce2791cbdb9bb1d4bcf45b378f Author: Michael Tremer Date: Wed Oct 7 14:44:48 2026 +0000 network-functions.pl: Fix the assertions for get_prefix() The testsuite has been checking that the function does not return the correct prefix. Signed-off-by: Michael Tremer commit cee814148e7c7ec06248de59b054f5579a51edd6 Author: Michael Tremer Date: Wed Oct 7 14:44:48 2026 +0000 network-functions.pl: Fix network_equal() never returning true The function checked whether the scalars $bin1 and $bin2 were defined, but the results of network2bin() are stored in the arrays @bin1 and @bin2. Those scalars never exist, so the function always returned undef. Therefore General::check_net_internal_exact() has never found a network that is equal to one of the local zones, which is what the routing and firewall groups pages rely on. The assertion in the testsuite has expected the wrong result, too. Signed-off-by: Michael Tremer ----------------------------------------------------------------------- Summary of changes: config/cfgroot/general-functions.pl | 662 +-------------------- config/cfgroot/graphs.pl | 19 +- config/cfgroot/header.pl | 217 +------ config/cfgroot/http-client-functions.pl | 75 ++- config/cfgroot/ids-functions.pl | 52 +- config/cfgroot/ipblocklist-functions.pl | 3 +- config/cfgroot/location-functions.pl | 8 + config/cfgroot/network-functions.pl | 268 ++++++++- config/cfgroot/protocols.pl | 162 ----- config/cfgroot/wireguard-functions.pl | 4 +- config/firewall/convert-dmz | 20 +- config/firewall/convert-outgoingfw | 30 +- config/firewall/convert-portfw | 2 +- config/firewall/firewall-lib.pl | 11 +- config/firewall/rules.pl | 2 +- .../{packages => common}/perl-File-ReadBackwards | 0 config/rootfiles/core/205/filelists/files | 9 + .../core/205/filelists/perl-File-ReadBackwards | 1 + config/rootfiles/core/205/update.sh | 8 + config/wio/wio.pl | 38 +- config/wio/wiovpn.pl | 12 +- html/cgi-bin/aliases.cgi | 6 +- html/cgi-bin/atm-status.cgi | 49 +- html/cgi-bin/backup.cgi | 48 +- html/cgi-bin/captive/index.cgi | 2 +- html/cgi-bin/captive/redirect.cgi | 4 +- html/cgi-bin/connections.cgi | 15 +- html/cgi-bin/ddns.cgi | 6 +- html/cgi-bin/dhcp.cgi | 234 +++++++- html/cgi-bin/dns.cgi | 12 +- html/cgi-bin/dnsbl.cgi | 4 +- html/cgi-bin/dnsforward.cgi | 4 +- html/cgi-bin/extrahd.cgi | 4 +- html/cgi-bin/firewall.cgi | 106 ++-- html/cgi-bin/fwhosts.cgi | 53 +- html/cgi-bin/guardian.cgi | 10 +- html/cgi-bin/hosts.cgi | 6 +- html/cgi-bin/ids.cgi | 2 +- html/cgi-bin/index.cgi | 28 +- html/cgi-bin/ipinfo.cgi | 2 +- html/cgi-bin/logs.cgi/config.dat | 4 +- html/cgi-bin/logs.cgi/firewalllog.dat | 37 +- html/cgi-bin/logs.cgi/firewalllogcountry.dat | 2 +- html/cgi-bin/logs.cgi/ovpnclients.dat | 4 +- html/cgi-bin/logs.cgi/urlfilter.dat | 4 +- html/cgi-bin/mac.cgi | 4 +- html/cgi-bin/mail.cgi | 4 +- html/cgi-bin/media.cgi | 34 +- html/cgi-bin/memory.cgi | 18 +- html/cgi-bin/netinternal.cgi | 12 +- html/cgi-bin/netother.cgi | 8 +- html/cgi-bin/netovpnrw.cgi | 10 +- html/cgi-bin/netovpnsrv.cgi | 10 +- html/cgi-bin/optionsfw.cgi | 4 +- html/cgi-bin/ovpnmain.cgi | 109 ++-- html/cgi-bin/pakfire.cgi | 24 +- html/cgi-bin/pppsetup.cgi | 16 +- html/cgi-bin/proxy.cgi | 56 +- html/cgi-bin/qos.cgi | 10 +- html/cgi-bin/remote.cgi | 2 +- html/cgi-bin/routing.cgi | 10 +- html/cgi-bin/samba.cgi | 45 +- html/cgi-bin/services.cgi | 2 +- html/cgi-bin/time.cgi | 8 +- html/cgi-bin/tor.cgi | 34 +- html/cgi-bin/traffic.cgi | 6 +- html/cgi-bin/updatexlrator.cgi | 60 +- html/cgi-bin/urlfilter.cgi | 34 +- html/cgi-bin/vpnmain.cgi | 14 +- html/cgi-bin/wakeonlan.cgi | 8 +- html/cgi-bin/wio.cgi | 62 +- html/cgi-bin/wireguard.cgi | 12 +- html/cgi-bin/wireless.cgi | 8 +- html/cgi-bin/wlanap.cgi | 10 +- lfs/guardian | 2 +- lfs/perl-File-ReadBackwards | 6 - lfs/proxy-accounting | 2 +- lfs/tor | 2 +- lfs/wio | 2 +- po/de.po | 60 +- po/es.po | 60 +- po/fr.po | 60 +- po/ipfire.pot | 30 +- po/it.po | 60 +- po/nl.po | 60 +- po/pl.po | 60 +- po/ru.po | 60 +- po/tr.po | 60 +- po/zh_CN.po | 60 +- po/zh_TW.po | 60 +- src/squid-accounting/accounting.cgi | 10 +- 91 files changed, 1537 insertions(+), 2000 deletions(-) delete mode 100644 config/cfgroot/protocols.pl rename config/rootfiles/{packages => common}/perl-File-ReadBackwards (100%) create mode 120000 config/rootfiles/core/205/filelists/perl-File-ReadBackwards Difference in files: diff --git a/config/cfgroot/general-functions.pl b/config/cfgroot/general-functions.pl index 4eb95c7c8..3d014885a 100644 --- a/config/cfgroot/general-functions.pl +++ b/config/cfgroot/general-functions.pl @@ -235,7 +235,7 @@ sub setup_default_networks if(defined($ovpnSettings{'DOVPN_SUBNET'})) { my ($ip,$sub) = split(/\//,$ovpnSettings{'DOVPN_SUBNET'}); - $sub=&General::iporsubtocidr($sub); + $sub=&Network::get_prefix($ovpnSettings{'DOVPN_SUBNET'}); my @tempovpnsubnet = split("\/", $ovpnSettings{'DOVPN_SUBNET'}); $defaultNetworks->{'OpenVPN ' ."($ip/$sub)"}{'ADR'} = $tempovpnsubnet[0]; $defaultNetworks->{'OpenVPN ' ."($ip/$sub)"}{'NAME'} = "OpenVPN-Dyn"; @@ -264,30 +264,6 @@ sub setup_default_networks $defaultNetworks->{$name}{'NAME'} = "WGRW"; } } -sub get_aliases -{ - - my $defaultNetworks = shift; - open(FILE, "${General::swroot}/ethernet/aliases") or die 'Unable to open aliases file.'; - my @current = ; - close(FILE); - my $ctr = 0; - foreach my $line (@current) - { - if ($line ne ''){ - chomp($line); - my @temp = split(/\,/,$line); - if ($temp[2] eq '') { - $temp[2] = "Alias $ctr : $temp[0]"; - } - $defaultNetworks->{$temp[2]}{'IPT'} = "$temp[0]"; - $defaultNetworks->{$temp[2]}{'NET'} = "$temp[0]"; - - $ctr++; - } - } -} - sub set_defaults($$) { my $hash = shift; my $defaults = shift; @@ -404,175 +380,6 @@ sub format_time($) { return join(" ", reverse(@s)); } -sub validip -{ - my $ip = $_[0]; - - if (!($ip =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/)) { - return 0; } - else - { - my @octets = ($1, $2, $3, $4); - foreach $_ (@octets) - { - if (/^0./) { - return 0; } - if ($_ < 0 || $_ > 255) { - return 0; } - } - return 1; - } -} - -sub validmask { - my $mask = shift; - - return &Network::check_netmask($mask) || &Network::check_prefix($mask); -} - -sub validipormask -{ - my $ipormask = $_[0]; - - # see if it is a IP only. - if (&validip($ipormask)) { - return 1; } - # split it into number and mask. - if (!($ipormask =~ /^(.*?)\/(.*?)$/)) { - return 0; } - my $ip = $1; - my $mask = $2; - # first part not a ip? - if (!(&validip($ip))) { - return 0; } - return &validmask($mask); -} - -sub subtocidr { - return &Network::convert_netmask2prefix(shift); -} - -sub cidrtosub { - return &Network::convert_prefix2netmask(shift); -} - -sub iporsubtodec -{ - #Gets: Ip address or subnetmask in decimal oder CIDR - #Gives: What it gets only in CIDR format - my $subnet=$_[0]; - my $net; - my $mask; - my $full=0; - if ($subnet =~ /^(.*?)\/(.*?)$/) { - ($net,$mask) = split (/\//,$subnet); - $full=1; - return "$subnet"; - }else{ - $mask=$subnet; - } - #Subnet already in decimal and valid? - if ($mask=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ &&(($1<=255 && $2<=$1 && $3<=$2 && $4<=$3 ))) { - for (my $i=0;$i<=32;$i++){ - if (&General::cidrtosub($i) eq $mask){ - if ($full == 0){return $mask;}else{ - return $net."/".$mask; - } - } - } - } - #Subnet in binary format? - if ($mask=~/^(\d{1,2})$/ && (($1<=32 && $1>=0))){ - if($full == 0){ return &General::cidrtosub($mask);}else{ - return $net."/".&General::cidrtosub($mask); - } - }else{ - return 3; - } - return 3; -} - - -sub iporsubtocidr -{ - #gets: Ip Address or subnetmask in decimal oder CIDR - #Gives: What it gets only in CIDR format - my $subnet=$_[0]; - my $net; - my $mask; - my $full=0; - if ($subnet =~ /^(.*?)\/(.*?)$/) { - ($net,$mask) = split (/\//,$subnet); - $full=1; - }else{ - $mask=$subnet; - } - #Subnet in decimal and valid? - if ($mask=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ &&(($1<=255 && $2<=$1 && $3<=$2 && $4<=$3 ))) { - for (my $i=0;$i<=32;$i++){ - if (&General::cidrtosub($i) eq $mask){ - if ($full == 0){return &General::subtocidr($mask);}else{ - return $net."/".&General::subtocidr($mask); - } - } - } - } - #Subnet already in binary format? - if ($mask=~/^(\d{1,2})$/ && (($1<=32 && $1>=0))){ - if($full == 0){ return $mask;}else{ - return $net."/".$mask; - } - }else{ - return 3; - } - return 3; -} - -sub getnetworkip { - my $arg = join("/", @_); - - return &Network::get_netaddress($arg); -} - -sub ip2dec { - return &Network::ip2bin(shift); -} - -sub dec2ip { - return &Network::bin2ip(shift); -} - -sub validipandmask -{ - #Gets: Ip address in 192.168.0.0/24 or 192.168.0.0/255.255.255.0 and checks if subnet valid - #Gives: True bzw 0 if success or false - my $ccdnet=$_[0]; - my $subcidr; - - if (!($ccdnet =~ /^(.*?)\/(.*?)$/)) { - return 0; - } - my ($ccdip,$ccdsubnet)=split (/\//, $ccdnet); - #IP valid? - if ($ccdip=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ &&(($1>0 && $1<=255 && $2>=0 && $2<=255 && $3>=0 && $3<=255 && $4<=255 ))) { - #Subnet in decimal and valid? - if ($ccdsubnet=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ &&(($1<=255 && $2<=$1 && $3<=$2 && $4<=$3 ))) { - for (my $i=0;$i<=32;$i++){ - if (&General::cidrtosub($i) eq $ccdsubnet){ - return 1; - } - } - #Subnet already in binary format? - }elsif ($ccdsubnet=~/^(\d{1,2})$/ && (($1<=32 && $1>=0))){ - return 1; - }else{ - return 0; - } - - } - return 0; -} - sub checksubnets { my %ccdconfhash=(); @@ -581,19 +388,18 @@ sub checksubnets my %ipsecconf=(); my %ownnet=(); my %ovpnconf=(); - my @ccdconf=(); my $ccdname=$_[0]; my $ccdnet=$_[1]; my $ownnet=$_[2]; my $checktype=$_[3]; my $errormessage; my ($ip,$cidr)=split(/\//,$ccdnet); - $cidr=&iporsubtocidr($cidr); + $cidr=&Network::get_prefix($ccdnet); #get OVPN-Subnet (dynamic range) &readhash("${General::swroot}/ovpn/settings", \%ovpnconf); my ($ovpnip,$ovpncidr)= split (/\//,$ovpnconf{'DOVPN_SUBNET'}); - $ovpncidr=&iporsubtocidr($ovpncidr); + $ovpncidr=&Network::get_prefix($ovpnconf{'DOVPN_SUBNET'}); #check if we try to use same network as ovpn server if ("$ip/$cidr" eq "$ovpnip/$ovpncidr") { @@ -606,8 +412,7 @@ sub checksubnets &readhasharray("${General::swroot}/ovpn/ovpnconfig", \%ovpnconfhash); foreach my $key (keys %ovpnconfhash) { if ($ovpnconfhash{$key}[3] eq 'net'){ - my @ovpnnet=split (/\//,$ovpnconfhash{$key}[11]); - if (&IpInSubnet($ip,$ovpnnet[0],&iporsubtodec($ovpnnet[1]))){ + if (&Network::ip_address_in_network($ip, $ovpnconfhash{$key}[11])){ $errormessage=$errormessage._('The subnet address is already in use for an OpenVPN net-to-net connection.')." $ovpnconfhash{$key}[1]
"; return $errormessage; } @@ -618,14 +423,12 @@ sub checksubnets #check if we use a network-name/subnet (static-ovpn) that already exists &readhasharray("${General::swroot}/ovpn/ccd.conf", \%ccdconfhash); foreach my $key (keys %ccdconfhash) { - @ccdconf=split(/\//,$ccdconfhash{$key}[1]); if ($ccdname eq $ccdconfhash{$key}[0]) { $errormessage=$errormessage._('Name already exists.')."
"; return $errormessage; } - my ($newip,$newsub) = split(/\//,$ccdnet); - if (&IpInSubnet($newip,$ccdconf[0],&iporsubtodec($ccdconf[1]))) + if (&Network::ip_address_in_network($ip, $ccdconfhash{$key}[1])) { $errormessage=$errormessage._('Subnet address already in use.')." $ccdconfhash{$key}[0]
"; return $errormessage; @@ -638,10 +441,8 @@ sub checksubnets foreach my $key (keys %ipsecconf){ if ($ipsecconf{$key}[11] ne '' && $ipsecconf{$key}[36] eq ""){ foreach my $ipsecsubitem (split(/\|/, $ipsecconf{$key}[11])) { - my ($ipsecip,$ipsecsub) = split (/\//, $ipsecsubitem); - $ipsecsub=&iporsubtodec($ipsecsub); if($ipsecconf{$key}[1] ne $ccdname){ - if ( &IpInSubnet ($ip,$ipsecip,$ipsecsub) ){ + if (&Network::ip_address_in_network($ip, $ipsecsubitem)){ $errormessage=_('The given subnet address is already used by an IPsec network.')." Name: $ipsecconf{$key}[1]"; return $errormessage; } @@ -654,8 +455,7 @@ sub checksubnets #check if we use the ipsec RW Network (if defined) &readhash("${General::swroot}/vpn/settings", \%vpnconf); if ($vpnconf{'RW_NET'} ne ''){ - my ($ipsecrwnet,$ipsecrwsub)=split (/\//, $vpnconf{'RW_NET'}); - if (&IpInSubnet($ip,$ipsecrwnet,&iporsubtodec($ipsecrwsub))) + if (&Network::ip_address_in_network($ip, $vpnconf{'RW_NET'})) { $errormessage=$errormessage._('The given subnet address is already used by the IPsec rw network.')."
"; return $errormessage; @@ -676,12 +476,11 @@ sub check_net_internal_range{ my ($ip,$cidr)=split(/\//,$network); my %ownnet = %Network::ethernet; my $errormessage; - $cidr=&iporsubtocidr($cidr); #check if we use one of ipfire's networks (green,orange,blue) - if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &IpInSubnet($ip,$ownnet{'GREEN_NETADDRESS'},&iporsubtodec($ownnet{'GREEN_NETMASK'}))){ $errormessage=_('This is the GREEN subnet.');return $errormessage;} - if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &IpInSubnet($ip,$ownnet{'ORANGE_NETADDRESS'},&iporsubtodec($ownnet{'ORANGE_NETMASK'}))){ $errormessage=_('This is the ORANGE subnet.');return $errormessage;} - if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &IpInSubnet($ip,$ownnet{'BLUE_NETADDRESS'},&iporsubtodec($ownnet{'BLUE_NETMASK'}))){ $errormessage=_('This is the BLUE subnet.');return $errormessage;} - if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &IpInSubnet($ip,$ownnet{'RED_NETADDRESS'},&iporsubtodec($ownnet{'RED_NETMASK'}))){ $errormessage=_('This is the RED subnet.');return $errormessage;} + if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &Network::ip_address_in_network($ip, "$ownnet{'GREEN_NETADDRESS'}/$ownnet{'GREEN_NETMASK'}")){ $errormessage=_('This is the GREEN subnet.');return $errormessage;} + if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &Network::ip_address_in_network($ip, "$ownnet{'ORANGE_NETADDRESS'}/$ownnet{'ORANGE_NETMASK'}")){ $errormessage=_('This is the ORANGE subnet.');return $errormessage;} + if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &Network::ip_address_in_network($ip, "$ownnet{'BLUE_NETADDRESS'}/$ownnet{'BLUE_NETMASK'}")){ $errormessage=_('This is the BLUE subnet.');return $errormessage;} + if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &Network::ip_address_in_network($ip, "$ownnet{'RED_NETADDRESS'}/$ownnet{'RED_NETMASK'}")){ $errormessage=_('This is the RED subnet.');return $errormessage;} } sub check_net_internal_exact{ @@ -689,7 +488,6 @@ sub check_net_internal_exact{ my ($ip,$cidr)=split(/\//,$network); my %ownnet = %Network::ethernet; my $errormessage; - $cidr=&iporsubtocidr($cidr); #check if we use one of ipfire's networks (green,orange,blue) if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &Network::network_equal("$ownnet{'GREEN_NETADDRESS'}/$ownnet{'GREEN_NETMASK'}", $network)){ $errormessage=_('This is the GREEN subnet.');return $errormessage;} if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &Network::network_equal("$ownnet{'ORANGE_NETADDRESS'}/$ownnet{'ORANGE_NETMASK'}", $network)){ $errormessage=_('This is the ORANGE subnet.');return $errormessage;} @@ -697,132 +495,6 @@ sub check_net_internal_exact{ if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &Network::network_equal("$ownnet{'RED_NETADDRESS'}/$ownnet{'RED_NETMASK'}", $network)){ $errormessage=_('This is the RED subnet.');return $errormessage;} } -sub validport -{ - $_ = $_[0]; - - if (!/^\d+$/) { - return 0; } - if (/^0./) { - return 0; } - if ($_ >= 1 && $_ <= 65535) { - return 1; } - return 0; -} - -sub validproxyport -{ - $_ = $_[0]; - - if (!/^\d+$/) { - return 0; } - if (/^0./) { - return 0; } - if ($_ == 53 || $_ == 222 || $_ == 444 || $_ == 81 ) { - return 0; } - elsif ($_ >= 1 && $_ <= 65535) { - return 1; } - return 0; -} - -sub validmac -{ - my $checkmac = $_[0]; - my $ot = '[0-9a-f]{2}'; # 2 Hex digits (one octet) - if ($checkmac !~ /^$ot:$ot:$ot:$ot:$ot:$ot$/i) - { - return 0; - } - return 1; -} - -sub validhostname -{ - # Checks a hostname against RFC1035 - my $hostname = $_[0]; - - # Hostname should be at least one character in length - # but no more than 63 characters - if (length ($hostname) < 1 || length ($hostname) > 63) { - return 0;} - # Only valid characters are a-z, A-Z, 0-9 and - - if ($hostname !~ /^[a-zA-Z0-9-]*$/) { - return 0;} - # First character can only be a letter or a digit - if (substr ($hostname, 0, 1) !~ /^[a-zA-Z0-9]*$/) { - return 0;} - # Last character can only be a letter or a digit - if (substr ($hostname, -1, 1) !~ /^[a-zA-Z0-9]*$/) { - return 0;} - return 1; -} - -sub validdomainname -{ - my $part; - - # Checks a domain name against RFC1035 and RFC2181 - my $domainname = $_[0]; - my @parts = split (/\./, $domainname); # Split domain name at the '.' - - foreach $part (@parts) { - # Each part should be at least one character in length - # but no more than 63 characters - if (length ($part) < 1 || length ($part) > 63) { - return 0;} - # Only valid characters are a-z, A-Z, 0-9, _ and - - if ($part !~ /^[a-zA-Z0-9_-]*$/) { - return 0;} - } - return 1; -} - -sub validwildcarddomainname($) { - my $domainname = shift; - - # Ignore any leading dots - if ($domainname =~ m/^\*\.([^\*]*)\*?/) { - $domainname = $1; - } - - return &validdomainname($domainname); -} - -sub validfqdn -{ - # Checks a fully qualified domain name against RFC1035 and RFC2181 - my $fqdn = $_[0]; - my @parts = split (/\./, $fqdn); # Split FQDN at the '.' - if (scalar(@parts) < 2) { # At least two parts should - return 0;} # exist in a FQDN - # (i.e.hostname.domain) - - for (my $index=0; $index < scalar(@parts); $index++) { - # Each part should be at least one character in length - # but no more than 63 characters - if (length ($parts[$index]) < 1 || length ($parts[$index]) > 63) { - return 0;} - if ($index eq 0) { - # This is the hostname part - # Only valid characters are a-z, A-Z, 0-9 and - - if ($parts[$index] !~ /^[a-zA-Z0-9-]*$/) { - return 0;} - # First character can only be a letter or a digit - if (substr ($parts[$index], 0, 1) !~ /^[a-zA-Z0-9]*$/) { - return 0;} - # Last character can only be a letter or a digit - if (substr ($parts[$index], -1, 1) !~ /^[a-zA-Z0-9]*$/) { - return 0;} - } else{ - # This is the domain part - # Only valid characters are a-z, A-Z, 0-9, _ and - - if ($parts[$index] !~ /^[a-zA-Z0-9_-]*$/) { - return 0;} - } - } - return 1; -} - sub validportrange # used to check a port range { my $port = $_[0]; # port values @@ -831,7 +503,7 @@ sub validportrange # used to check a port range if (!($port =~ /^(\d+)\:(\d+)$/)) { - if (!(&validport($port))) { + if (!(&Network::check_port($port))) { if ($srcdst eq 'src'){ return _('Source port must be a valid port number or port range.'); } else { @@ -851,7 +523,7 @@ sub validportrange # used to check a port range } foreach $_ (@ports) { - if (!(&validport($_))) { + if (!(&Network::check_port($_))) { if ($srcdst eq 'src'){ return _('Source port must be a valid port number or port range.'); } else { @@ -863,22 +535,6 @@ sub validportrange # used to check a port range } } -# Checks for a valid country code -sub validcc($) { - my $cc = shift; - - # Must contain of exactly two uppercase characters, or must be A1, A2, or A3 - return ($cc =~ m/^([A-Z]{2}|A[123])$/); -} - -sub IpInSubnet { - my $addr = shift; - my $network = shift; - my $netmask = shift; - - return &Network::ip_address_in_network($addr, "$network/$netmask"); -} - sub validemail { my $address = shift; my @parts = split( /\@/, $address ); @@ -953,159 +609,6 @@ sub findhasharraykey { } } -# -# Check if hostname.domain provided have IP provided -# use gethostbyname to verify that -# Params: -# IP -# hostname -# domain -# Output -# 1 IP matches host.domain -# 0 not in sync -# -sub DyndnsServiceSync ($;$;$) { - - my ($ip,$hostName,$domain) = @_; - my @addresses; - - #fix me no ip GROUP, what is the name ? - $hostName =~ s/$General::noipprefix//; - if ($hostName) { #may be empty - $hostName = "$hostName.$domain"; - @addresses = gethostbyname($hostName); - } - - if ($addresses[0] eq '') { # nothing returned ? - $hostName = $domain; # try resolving with domain only - @addresses = gethostbyname($hostName); - } - - if ($addresses[0] ne '') { # got something ? - #&General::log("name:$addresses[0], alias:$addresses[1]"); - # Build clear text list of IP - @addresses = map ( &Socket::inet_ntoa($_), @addresses[4..$#addresses]); - if (grep (/$ip/, @addresses)) { - return 1; - } - } - return 0; -} - -# Translate ICMP code to text -# ref: http://www.iana.org/assignments/icmp-parameters -sub GetIcmpDescription ($) { - my $index = shift; - my @icmp_description = ( - 'Echo Reply', #0 - 'Unassigned', - 'Unassigned', - 'Destination Unreachable', - 'Source Quench', - 'Redirect', - 'Alternate Host Address', - 'Unassigned', - 'Echo', - 'Router Advertisement', - 'Router Solicitation', #10 - 'Time Exceeded', - 'Parameter Problem', - 'Timestamp', - 'Timestamp Reply', - 'Information Request', - 'Information Reply', - 'Address Mask Request', - 'Address Mask Reply', - 'Reserved (for Security)', - 'Reserved (for Robustness Experiment)', #20 - 'Reserved', - 'Reserved', - 'Reserved', - 'Reserved', - 'Reserved', - 'Reserved', - 'Reserved', - 'Reserved', - 'Reserved', - 'Traceroute', #30 - 'Datagram Conversion Error', - 'Mobile Host Redirect', - 'IPv6 Where-Are-You', - 'IPv6 I-Am-Here', - 'Mobile Registration Request', - 'Mobile Registration Reply', - 'Domain Name Request', - 'Domain Name Reply', - 'SKIP', - 'Photur', #40 - 'Experimental'); - if ($index>41) {return 'unknown'} else {return $icmp_description[$index]}; -} - -sub GetCoreUpdateVersion() { - my $core_update; - - open(FILE, "/opt/pakfire/db/core/mine"); - $core_update = ; - close(FILE); - chomp($core_update); - - return $core_update; -} - -sub MakeUserAgent() { - my $user_agent = "IPFire/$General::version"; - - my $core_update = &GetCoreUpdateVersion(); - if ($core_update ne "") { - $user_agent .= "/$core_update"; - } - - return $user_agent; -} - -sub RedIsWireless() { - # This function checks if a network device is a wireless device. - - # Find the name of the network device. - my $device = $Network::ethernet{'RED_DEV'}; - - # Exit, if no device is configured. - return 0 if ($device eq ""); - - # Return 1 if the device is a wireless one. - my $path = "/sys/class/net/$device/wireless"; - if (-d $path) { - return 1; - } - - # Otherwise return zero. - return 0; -} - -# Function to read a file with UTF-8 charset. -sub read_file_utf8 ($) { - my ($file) = @_; - - open my $in, '<:encoding(UTF-8)', $file or die "Could not open '$file' for reading $!"; - local $/ = undef; - my $all = <$in>; - close $in; - - return $all; -} - -# Function to write a file with UTF-8 charset. -sub write_file_utf8 ($) { - my ($file, $content) = @_; - - open my $out, '>:encoding(UTF-8)', $file or die "Could not open '$file' for writing $!";; - print $out $content; - close $out; - - return; -} - my $FIREWALL_RELOAD_INDICATOR = "${General::swroot}/firewall/reread"; sub firewall_config_changed() { @@ -1125,22 +628,6 @@ sub firewall_reload() { &system("/usr/local/bin/firewallctrl"); } -# Function which will return the used interface for the red network zone (red0, ppp0, etc). -# if you change this also check speed.cgi that include a local copy for systemload reasons -sub get_red_interface() { - my $interface; - my $red_iface_file = "${General::swroot}/red/iface"; - - if (-e $red_iface_file) { - open(IFACE, "$red_iface_file") or die "Could not open $red_iface_file"; - $interface = ; - close(IFACE); - chomp $interface; - } - - return $interface; -} - sub number_cpu_cores() { open my $cpuinfo, "/proc/cpuinfo" or die "Can't open cpuinfo: $!\n"; my $cores = scalar (map /^processor/, <$cpuinfo>); @@ -1149,90 +636,9 @@ sub number_cpu_cores() { return $cores; } -# Tiny function to grab a single IP-address from a given file. -sub grab_address_from_file($) { - my ($file) = @_; - - my $address; - - # Check if the given file exists. - if(-f $file) { - # Open the file for reading. - open(FILE, $file) or die "Could not read from $file. $!\n"; - - # Read the address from the file. - $address = ; - - # Close filehandle. - close(FILE); - - # Remove newlines. - chomp($address); - - # Check if the obtained address is valid. - if (&validip($address)) { - # Return the address. - return $address; - } - } - - # Return nothing. - return; -} - -# Function to get all configured and enabled nameservers. -sub get_nameservers () { - my %settings; - my %servers; - - my @nameservers; - - # Read DNS configuration. - &readhash("$General::swroot/dns/settings", \%settings); - - # Read configured DNS servers. - &readhasharray("$General::swroot/dns/servers", \%servers); - - # Check if the ISP assigned server should be used. - if ($settings{'USE_ISP_NAMESERVERS'} eq "on") { - # Assign ISP nameserver files. - my @ISP_nameserver_files = ( "/var/run/dns1", "/var/run/dns2" ); - - # Loop through the array of ISP assigned DNS servers. - foreach my $file (@ISP_nameserver_files) { - # Grab the IP address. - my $address = &grab_address_from_file($file); - - # Check if an address has been grabbed. - if ($address) { - # Add the address to the array of nameservers. - push(@nameservers, $address); - } - } - } - - # Check if DNS servers are configured. - if (%servers) { - # Loop through the hash of configured DNS servers. - foreach my $id (keys %servers) { - my $address = $servers{$id}[0]; - my $status = $servers{$id}[2]; - - # Check if the current processed server is enabled. - if ($status eq "enabled") { - # Add the address to the array of nameservers. - push(@nameservers, $address); - } - } - } - - # Return the array. - return &uniq(@nameservers); -} - # Function to format a string containing the amount of bytes to # something human-readable. -sub formatBytes { +sub format_bytes { # Private array which contains the units. my @units = qw(B KB MB GB TB PB); @@ -1248,49 +654,13 @@ sub formatBytes { last if $bytes < 1024; # Divide bytes amount with 1024. - $bytes /= 1024; - } + $bytes /= 1024; + } # Return the divided and rounded bytes count and the unit. return sprintf("%.2f %s", $bytes, $unit); } -# Function to collect and generate a hash for translating protocol numbers into -# their names. -sub generateProtoTransHash () { - # File which contains the protocol definitions. - my $protocols_file = "/etc/protocols"; - - my %protocols = (); - - # Open protocols file. - open(FILE, "$protocols_file") or die "Could not open $protocols_file. $!\n"; - - # Loop through the file. - while (my $line = ) { - # Skip comments. - next if ($line =~ /^\#/); - - # Skip blank lines. - next if ($line =~ /^\s*$/); - - # Remove any newlines. - chomp($line); - - # Split line content. - my ($protocol_lc, $number, $protocol_uc, $comment) = split(' ', $line); - - # Add proto details to the hash of protocols. - $protocols{$number} = $protocol_uc; - } - - # Close file handle. - close(FILE); - - # Return the hash. - return %protocols; -} - # Cloud Stuff sub running_in_cloud() { diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl index 16e3c5ace..efbf46e34 100644 --- a/config/cfgroot/graphs.pl +++ b/config/cfgroot/graphs.pl @@ -91,11 +91,9 @@ if ( $mainsettings{'RRDLOG'} eq "" ){ my $count = 0; my @sensorsgraphs = (); -my @sensorsdir = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/sensors-*/ 2>/dev/null`; -foreach (@sensorsdir){ - chomp($_);chop($_); - foreach (`ls $_/*`){ - chomp($_); +my @sensorsdir = grep { -d $_ } glob("$mainsettings{'RRDLOG'}/collectd/localhost/sensors-*"); +foreach my $sensorsdir (@sensorsdir) { + foreach (glob("$sensorsdir/*")) { push(@sensorsgraphs,$_); $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; my $label = $2.$3;$label=~ s/-//g; @@ -149,7 +147,7 @@ END # collectd we are now able to handle any kind of cpucount sub updatecpugraph { - my $cpucount = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/cpu-*/ 2>/dev/null | wc -l`; + my $cpucount = scalar(grep { -d $_ } glob("$mainsettings{'RRDLOG'}/collectd/localhost/cpu-*")); my $period = $_[0]; my @command = ( @GRAPH_ARGS, @@ -1081,7 +1079,7 @@ sub updateqosgraph { # Generate the CPU Frequency Graph for the current period of time for values given by collectd an lm_sensors sub updatecpufreqgraph { - my $cpucount = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/cpu-*/ 2>/dev/null | wc -l`; + my $cpucount = scalar(grep { -d $_ } glob("$mainsettings{'RRDLOG'}/collectd/localhost/cpu-*")); my $period = $_[0]; my @command = ( @GRAPH_ARGS, @@ -1120,7 +1118,7 @@ sub updatecpufreqgraph { # Generate the Thermal Zone Temp CPU Graph sub updatethermaltempgraph { - my $thermalcount = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/thermal-thermal_zone* 2>/dev/null | wc -l`; + my $thermalcount = scalar(() = glob("$mainsettings{'RRDLOG'}/collectd/localhost/thermal-thermal_zone*")); my $period = $_[0]; my @command = ( @GRAPH_ARGS, @@ -1167,11 +1165,6 @@ sub random_hex_color { return join('', '#', @color); } -sub getprocesses { - my @processesgraph = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/processes-*/ 2>/dev/null`; - return @processesgraph; -} - sub updateconntrackgraph { my $period = $_[0]; my @command = ( diff --git a/config/cfgroot/header.pl b/config/cfgroot/header.pl index abc7140d1..6146ef7ab 100644 --- a/config/cfgroot/header.pl +++ b/config/cfgroot/header.pl @@ -15,7 +15,6 @@ use CGI(); use File::Basename; use HTML::Entities(); use Socket; -use Time::Local; use Encode; use Unicode::Normalize; @@ -409,20 +408,6 @@ sub green_used() { return 0; } -sub orange_used () { - if ($Network::ethernet{'CONFIG_TYPE'} =~ /^[24]$/) { - return 1; - } - return 0; -} - -sub blue_used () { - if ($Network::ethernet{'CONFIG_TYPE'} =~ /^[34]$/) { - return 1; - } - return 0; -} - ### Initialize menu sub genmenu { @@ -447,17 +432,25 @@ sub genmenu { my %sublogshash = (); my $sublogs = \%sublogshash; - eval `/bin/cat /var/ipfire/menu.d/*.menu`; - eval `/bin/cat /var/ipfire/menu.d/*.main`; + # Read all menu files. They are pieces of Perl code which fill the + # hashes from above and therefore have to be evaluated right here. + foreach my $file (glob("${swroot}/menu.d/*.menu"), glob("${swroot}/menu.d/*.main")) { + open(my $fh, "<", $file) or next; + my $code = do { local $/; <$fh> }; + close($fh); + + eval $code; + warn "Could not load menu from $file: $@" if ($@); + } - if (! blue_used()) { + if (! &Network::is_zone_available("blue")) { $menu->{'05.firewall'}{'subMenu'}->{'70.wireless'}{'enabled'} = 0; } if ( $Network::ethernet{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $Network::ethernet{'RED_TYPE'} eq 'STATIC' ) { $menu->{'03.network'}{'subMenu'}->{'70.aliases'}{'enabled'} = 1; } - if (&General::RedIsWireless()) { + if (&Network::is_red_wireless()) { $menu->{'01.system'}{'subMenu'}->{'21.wlan'}{'enabled'} = 1; } @@ -666,189 +659,13 @@ sub connectionstatus if (open(KEEPCONNECTED, " - -@{[ _('IP Address') ]} -@{[ _('MAC Address') ]} -@{[ _('Hostname') ]} -@{[ _('Lease Expires') ]} (local time d/m/y) -@{[ _('Add to Fix Leases') ]} - -END -; - - open(LEASES,"/var/state/dhcp/dhcpd.leases") or die "Can't open dhcpd.leases"; - while (my $line = ) { - next if( $line =~ /^\s*#/ ); - chomp($line); - @temp = split (' ', $line); - - if ($line =~ /^\s*lease/) { - $ip = $temp[1]; - #All field are not necessarily read. Clear everything - $endtime = 0; - $endtime_print = ""; - $expired = 0; - $ether = ""; - $hostname = ""; - } - - if ($line =~ /^\s*ends \d (\d+)\/(\d+)\/(\d+) (\d+):(\d+):(\d+)/) { - $endtime = timegm($6, $5, $4, $3, $2 - 1, $1 - 1900); - ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $dst) = localtime($endtime); - $endtime_print = sprintf ("%02d/%02d/%d %02d:%02d:%02d",$mday,$mon+1,$year+1900,$hour,$min,$sec); - $expired = $endtime < time(); - - } elsif ($line =~ /^\s*ends never/) { - $endtime = 0; - $endtime_print = _('Never'); - $expired = 0; - } - - if ($line =~ /^\s*hardware ethernet/) { - $ether = $temp[2]; - $ether =~ s/;//g; - } - - if ($line =~ /^\s*client-hostname/) { - $hostname = "$temp[1] $temp[2] $temp[3]"; - $hostname =~ s/\"|[;\s]+?$//g; # remove quotes, trim semicolon and white space - } - - if ($line eq "}") { - @record = ('IPADDR',$ip,'ENDTIME',$endtime,'ETHER',$ether,'HOSTNAME',$hostname,'endtime_print',$endtime_print,'expired',$expired); - $record = {}; # create a reference to empty hash - %{$record} = @record; # populate that hash with @record - $entries{$record->{'IPADDR'}} = $record; # add this to a hash of hashes - } - } - close(LEASES); - - my $id = 0; - my $col = ""; - my $divider_printed = 0; - foreach my $key (sort leasesort keys %entries) { - my $hostname = &escape($entries{$key}->{HOSTNAME}); - my $hostname_print = $hostname; - if($hostname_print eq "") { #print blank space if no hostname is found - $hostname_print = "   "; - } - - # separate active and expired leases with a horizontal line - if(($entries{$key}->{expired}) && ($divider_printed == 0)) { - $divider_printed = 1; - if ($id % 2) { - print "
\n"; - } else { - print "
\n"; - } - $id++; - } - - print "
\n"; - if ($id % 2) { - $col="bgcolor='$table1colour'"; - } else { - $col="bgcolor='$table2colour'"; - } - - if($entries{$key}->{expired}) { - print <$entries{$key}->{IPADDR} -$entries{$key}->{ETHER} -$hostname_print -$entries{$key}->{endtime_print} -END -; - } else { - print <$entries{$key}->{IPADDR} -$entries{$key}->{ETHER} -$hostname_print -$entries{$key}->{endtime_print} -END -; - } - - print < - -END -; - $id++; - } - - print ""; - &closebox(); -} - - -# This sub is used during display of actives leases -sub leasesort { - if (rindex ($dhcpsettings{'SORT_LEASELIST'},'Rev') != -1) - { - $qs=substr ($dhcpsettings{'SORT_LEASELIST'},0,length($dhcpsettings{'SORT_LEASELIST'})-3); - if ($qs eq 'IPADDR') { - @a = split(/\./,$entries{$a}->{$qs}); - @b = split(/\./,$entries{$b}->{$qs}); - $entries{$a}->{'expired'} <=> $entries{$b}->{'expired'} || # always sort by expiration first - ($b[0]<=>$a[0]) || - ($b[1]<=>$a[1]) || - ($b[2]<=>$a[2]) || - ($b[3]<=>$a[3]); - } else { - $entries{$a}->{'expired'} <=> $entries{$b}->{'expired'} || - $entries{$b}->{$qs} cmp $entries{$a}->{$qs}; - } - } - else #not reverse - { - $qs=$dhcpsettings{'SORT_LEASELIST'}; - if ($qs eq 'IPADDR') { - @a = split(/\./,$entries{$a}->{$qs}); - @b = split(/\./,$entries{$b}->{$qs}); - $entries{$a}->{'expired'} <=> $entries{$b}->{'expired'} || - ($a[0]<=>$b[0]) || - ($a[1]<=>$b[1]) || - ($a[2]<=>$b[2]) || - ($a[3]<=>$b[3]); - } else { - $entries{$a}->{'expired'} <=> $entries{$b}->{'expired'} || - $entries{$a}->{$qs} cmp $entries{$b}->{$qs}; - } - } -} - sub colorize { my $string = $_[0]; my @array = split(/\//,$string); @@ -862,13 +679,13 @@ sub colorize { return "".$string.""; } elsif ( $string =~ "lo" or $string =~ "127.0.0.0" ){ return "".$string.""; - } elsif ( $string =~ $Network::ethernet{'GREEN_DEV'} or &General::IpInSubnet($string2,$Network::ethernet{'GREEN_NETADDRESS'},$Network::ethernet{'GREEN_NETMASK'}) ){ + } elsif ( $string =~ $Network::ethernet{'GREEN_DEV'} or &Network::ip_address_in_network($string2, "$Network::ethernet{'GREEN_NETADDRESS'}/$Network::ethernet{'GREEN_NETMASK'}") ){ return "".$string.""; } elsif ( $string =~ "ppp0" or $string =~ $Network::ethernet{'RED_DEV'} or $string =~ "0.0.0.0" or $string =~ $Network::ethernet{'RED_ADDRESS'} ){ return "".$string.""; - } elsif ( $Network::ethernet{'CONFIG_TYPE'}>1 and ( $string =~ $Network::ethernet{'BLUE_DEV'} or &General::IpInSubnet($string2,$Network::ethernet{'BLUE_NETADDRESS'},$Network::ethernet{'BLUE_NETMASK'}) )){ + } elsif ( $Network::ethernet{'CONFIG_TYPE'}>1 and ( $string =~ $Network::ethernet{'BLUE_DEV'} or &Network::ip_address_in_network($string2, "$Network::ethernet{'BLUE_NETADDRESS'}/$Network::ethernet{'BLUE_NETMASK'}") )){ return "".$string.""; - } elsif ( $Network::ethernet{'CONFIG_TYPE'}>2 and ( $string =~ $Network::ethernet{'ORANGE_DEV'} or &General::IpInSubnet($string2,$Network::ethernet{'ORANGE_NETADDRESS'},$Network::ethernet{'ORANGE_NETMASK'}) )){ + } elsif ( $Network::ethernet{'CONFIG_TYPE'}>2 and ( $string =~ $Network::ethernet{'ORANGE_DEV'} or &Network::ip_address_in_network($string2, "$Network::ethernet{'ORANGE_NETADDRESS'}/$Network::ethernet{'ORANGE_NETMASK'}") )){ return "".$string.""; } else { return $string; @@ -969,7 +786,7 @@ EOF my $mem = &General::get_memory_consumption(@pids); # Format memory - $mem = &General::formatBytes($mem); + $mem = &General::format_bytes($mem); print < diff --git a/config/cfgroot/http-client-functions.pl b/config/cfgroot/http-client-functions.pl index 7f7675bbf..6b68917d3 100644 --- a/config/cfgroot/http-client-functions.pl +++ b/config/cfgroot/http-client-functions.pl @@ -122,7 +122,7 @@ sub downloader (%) { $ua->max_size($max_size) if ($max_size); # Generate UserAgent. - my $agent = &General::MakeUserAgent(); + my $agent = &MakeUserAgent(); # Set the generated UserAgent. $ua->agent($agent); @@ -322,24 +322,85 @@ sub GetDyndnsRedIP { &General::readhash("${General::swroot}/ddns/settings", \%settings); # Try to grab the address from the local-ipaddress file. - my $ip = &General::grab_address_from_file("${General::swroot}/red/local-ipaddress") or return 'unavailable'; + my $ip = &Network::grab_address_from_file("${General::swroot}/red/local-ipaddress") or return 'unavailable'; # 100.64.0.0/10 is reserved for dual-stack lite (http://tools.ietf.org/html/rfc6598). - if (&General::IpInSubnet ($ip,'10.0.0.0','255.0.0.0') || - &General::IpInSubnet ($ip,'172.16.0.0.','255.240.0.0') || - &General::IpInSubnet ($ip,'192.168.0.0','255.255.0.0') || - &General::IpInSubnet ($ip,'100.64.0.0', '255.192.0.0')) + if (&Network::ip_address_in_network($ip, "10.0.0.0/255.0.0.0") || + &Network::ip_address_in_network($ip, "172.16.0.0/255.240.0.0") || + &Network::ip_address_in_network($ip, "192.168.0.0/255.255.0.0") || + &Network::ip_address_in_network($ip, "100.64.0.0/255.192.0.0")) { if ($settings{'BEHINDROUTER'} eq 'FETCH_IP') { # Call function to omit the real address. my $RealIP = &FetchPublicIp; # Check if the grabbed address is valid. - $ip = (&General::validip ($RealIP) ? $RealIP : 'unavailable'); + $ip = (&Network::check_ip_address ($RealIP) ? $RealIP : 'unavailable'); } } return $ip; } +sub GetCoreUpdateVersion() { + my $core_update; + + open(FILE, "/opt/pakfire/db/core/mine"); + $core_update = ; + close(FILE); + chomp($core_update); + + return $core_update; +} + +sub MakeUserAgent() { + my $user_agent = "IPFire/$General::version"; + + my $core_update = &GetCoreUpdateVersion(); + if ($core_update ne "") { + $user_agent .= "/$core_update"; + } + + return $user_agent; +} + +# +# Check if hostname.domain provided have IP provided +# use gethostbyname to verify that +# Params: +# IP +# hostname +# domain +# Output +# 1 IP matches host.domain +# 0 not in sync +# +sub DyndnsServiceSync ($;$;$) { + + my ($ip,$hostName,$domain) = @_; + my @addresses; + + #fix me no ip GROUP, what is the name ? + $hostName =~ s/$General::noipprefix//; + if ($hostName) { #may be empty + $hostName = "$hostName.$domain"; + @addresses = gethostbyname($hostName); + } + + if ($addresses[0] eq '') { # nothing returned ? + $hostName = $domain; # try resolving with domain only + @addresses = gethostbyname($hostName); + } + + if ($addresses[0] ne '') { # got something ? + #&General::log("name:$addresses[0], alias:$addresses[1]"); + # Build clear text list of IP + @addresses = map ( &Socket::inet_ntoa($_), @addresses[4..$#addresses]); + if (grep (/$ip/, @addresses)) { + return 1; + } + } + return 0; +} + 1; diff --git a/config/cfgroot/ids-functions.pl b/config/cfgroot/ids-functions.pl index 55a461f59..d0b7fd1a5 100644 --- a/config/cfgroot/ids-functions.pl +++ b/config/cfgroot/ids-functions.pl @@ -1136,7 +1136,7 @@ sub generate_home_net_file() { # Check if the configured RED_TYPE is static. if ($netsettings{'RED_TYPE'} eq "STATIC") { # Get configured and enabled aliases. - my @aliases = &get_aliases(); + my @aliases = &Network::get_aliases(); # Loop through the array. foreach my $alias (@aliases) { @@ -1199,7 +1199,7 @@ sub generate_home_net_file() { # sub generate_dns_servers_file() { # Get the used DNS servers. - my @nameservers = &General::get_nameservers(); + my @nameservers = &Network::get_nameservers(); # Get network settings. my %netsettings; @@ -1584,7 +1584,7 @@ sub generate_ignore_file() { # Check if the status of the entry is "enabled". if ($status eq "enabled") { # Check if the address/network is valid. - if ((&General::validip($address)) || (&General::validipandmask($address))) { + if ((&Network::check_ip_address($address)) || (&Network::check_subnet($address))) { # Write rule line to the file to pass any traffic from this IP print FILE "pass ip $address any -> any any (msg:\"pass all traffic from/to $address\"\; bypass; sid:$sid\;)\n"; @@ -1643,50 +1643,6 @@ sub set_ownership($) { } } -# -## Function to read-in the aliases file and returns all configured and enabled aliases. -# -sub get_aliases() { - # Location of the aliases file. - my $aliases_file = "${General::swroot}/ethernet/aliases"; - - # Array to store the aliases. - my @aliases; - - # Check if the file is empty. - if (-z $aliases_file) { - # Abort nothing to do. - return; - } - - # Open the aliases file. - open(ALIASES, $aliases_file) or die "Could not open $aliases_file. $!\n"; - - # Loop through the file content. - while (my $line = ) { - # Remove newlines. - chomp($line); - - # Splitt line content into single chunks. - my ($address, $state, $remark) = split(/\,/, $line); - - # Check if the state of the current processed alias is "on". - if ($state eq "on") { - # Check if the address is valid. - if(&Network::check_ip_address($address)) { - # Add the alias to the array of aliases. - push(@aliases, $address); - } - } - } - - # Close file handle. - close(ALIASES); - - # Return the array. - return @aliases; -} - # ## Function to grab the current assigned IP-address on red. # @@ -1709,7 +1665,7 @@ sub get_red_address() { chomp $address; # Check if the grabbed address is valid. - if (&General::validip($address)) { + if (&Network::check_ip_address($address)) { # Return the address. return $address; } diff --git a/config/cfgroot/ipblocklist-functions.pl b/config/cfgroot/ipblocklist-functions.pl index b2d0a1a49..d8d254ec8 100644 --- a/config/cfgroot/ipblocklist-functions.pl +++ b/config/cfgroot/ipblocklist-functions.pl @@ -22,6 +22,7 @@ package IPblocklist; require '/var/ipfire/general-functions.pl'; +require "${General::swroot}/http-client-functions.pl"; require "${General::swroot}/ipblocklist/sources"; # The directory where all ipblocklist related files and settings are stored. @@ -118,7 +119,7 @@ sub download_and_create_blocklist($) { # Create a user agent for downloading the blacklist # Define the User Agent string # Limit the download size for safety - my $user_agent = &General::MakeUserAgent(); + my $user_agent = &HTTPClient::MakeUserAgent(); my $ua = LWP::UserAgent->new ( ssl_opts => { SSL_ca_file => '/etc/ssl/cert.pem', diff --git a/config/cfgroot/location-functions.pl b/config/cfgroot/location-functions.pl index 46e27c04a..cd9864f9b 100644 --- a/config/cfgroot/location-functions.pl +++ b/config/cfgroot/location-functions.pl @@ -195,6 +195,14 @@ sub get_locations() { return @sorted_locations; } +# Checks for a valid country code +sub validcc($) { + my $cc = shift; + + # Must contain of exactly two uppercase characters, or must be A1, A2, or A3 + return ($cc =~ m/^([A-Z]{2}|A[123])$/); +} + # Function to get the continent code of a given country code. sub get_continent_code($) { my ($country_code) = @_; diff --git a/config/cfgroot/network-functions.pl b/config/cfgroot/network-functions.pl index 6716cfe4b..80a500179 100644 --- a/config/cfgroot/network-functions.pl +++ b/config/cfgroot/network-functions.pl @@ -123,7 +123,7 @@ sub network_equal { my @bin1 = &network2bin($network1); my @bin2 = &network2bin($network2); - if (!defined $bin1 || !defined $bin2) { + if (!defined $bin1[0] || !defined $bin2[0]) { return undef; } @@ -395,6 +395,106 @@ sub ip_address_in_range($$) { return (($ipaddress_bin >= $ipstart_bin) && ($ipaddress_bin <= $ipend_bin)); } +sub check_port +{ + $_ = $_[0]; + + if (!/^\d+$/) { + return 0; } + if (/^0./) { + return 0; } + if ($_ >= 1 && $_ <= 65535) { + return 1; } + return 0; +} + +sub check_hostname +{ + # Checks a hostname against RFC1035 + my $hostname = $_[0]; + + # Hostname should be at least one character in length + # but no more than 63 characters + if (length ($hostname) < 1 || length ($hostname) > 63) { + return 0;} + # Only valid characters are a-z, A-Z, 0-9 and - + if ($hostname !~ /^[a-zA-Z0-9-]*$/) { + return 0;} + # First character can only be a letter or a digit + if (substr ($hostname, 0, 1) !~ /^[a-zA-Z0-9]*$/) { + return 0;} + # Last character can only be a letter or a digit + if (substr ($hostname, -1, 1) !~ /^[a-zA-Z0-9]*$/) { + return 0;} + return 1; +} + +sub check_domainname +{ + my $part; + + # Checks a domain name against RFC1035 and RFC2181 + my $domainname = $_[0]; + my @parts = split (/\./, $domainname); # Split domain name at the '.' + + foreach $part (@parts) { + # Each part should be at least one character in length + # but no more than 63 characters + if (length ($part) < 1 || length ($part) > 63) { + return 0;} + # Only valid characters are a-z, A-Z, 0-9, _ and - + if ($part !~ /^[a-zA-Z0-9_-]*$/) { + return 0;} + } + return 1; +} + +sub check_wildcard_domainname($) { + my $domainname = shift; + + # Ignore any leading dots + if ($domainname =~ m/^\*\.([^\*]*)\*?/) { + $domainname = $1; + } + + return &check_domainname($domainname); +} + +sub check_fqdn +{ + # Checks a fully qualified domain name against RFC1035 and RFC2181 + my $fqdn = $_[0]; + my @parts = split (/\./, $fqdn); # Split FQDN at the '.' + if (scalar(@parts) < 2) { # At least two parts should + return 0;} # exist in a FQDN + # (i.e.hostname.domain) + + for (my $index=0; $index < scalar(@parts); $index++) { + # Each part should be at least one character in length + # but no more than 63 characters + if (length ($parts[$index]) < 1 || length ($parts[$index]) > 63) { + return 0;} + if ($index eq 0) { + # This is the hostname part + # Only valid characters are a-z, A-Z, 0-9 and - + if ($parts[$index] !~ /^[a-zA-Z0-9-]*$/) { + return 0;} + # First character can only be a letter or a digit + if (substr ($parts[$index], 0, 1) !~ /^[a-zA-Z0-9]*$/) { + return 0;} + # Last character can only be a letter or a digit + if (substr ($parts[$index], -1, 1) !~ /^[a-zA-Z0-9]*$/) { + return 0;} + } else{ + # This is the domain part + # Only valid characters are a-z, A-Z, 0-9, _ and - + if ($parts[$index] !~ /^[a-zA-Z0-9_-]*$/) { + return 0;} + } + } + return 1; +} + sub setup_upstream_proxy() { my %proxysettings = (); &General::readhash("${General::swroot}/proxy/settings", \%proxysettings); @@ -420,8 +520,24 @@ sub setup_upstream_proxy() { } } +# Function which will return the used interface for the red network zone (red0, ppp0, etc). +# if you change this also check speed.cgi that include a local copy for systemload reasons +sub get_red_interface() { + my $interface; + my $red_iface_file = "${General::swroot}/red/iface"; + + if (-e $red_iface_file) { + open(IFACE, "$red_iface_file") or die "Could not open $red_iface_file"; + $interface = ; + close(IFACE); + chomp $interface; + } + + return $interface; +} + sub get_red_interfaces() { - my $default = &General::get_red_interface(); + my $default = &get_red_interface(); my @intfs = ( $default, @@ -440,6 +556,128 @@ sub get_red_interfaces() { return &General::uniq(@intfs); } +# Tiny function to grab a single IP-address from a given file. +sub grab_address_from_file($) { + my ($file) = @_; + + my $address; + + # Check if the given file exists. + if(-f $file) { + # Open the file for reading. + open(FILE, $file) or die "Could not read from $file. $!\n"; + + # Read the address from the file. + $address = ; + + # Close filehandle. + close(FILE); + + # Remove newlines. + chomp($address); + + # Check if the obtained address is valid. + if (&check_ip_address($address)) { + # Return the address. + return $address; + } + } + + # Return nothing. + return; +} + +# Function to get all configured and enabled nameservers. +sub get_nameservers () { + my %settings; + my %servers; + + my @nameservers; + + # Read DNS configuration. + &General::readhash("$General::swroot/dns/settings", \%settings); + + # Read configured DNS servers. + &General::readhasharray("$General::swroot/dns/servers", \%servers); + + # Check if the ISP assigned server should be used. + if ($settings{'USE_ISP_NAMESERVERS'} eq "on") { + # Assign ISP nameserver files. + my @ISP_nameserver_files = ( "/var/run/dns1", "/var/run/dns2" ); + + # Loop through the array of ISP assigned DNS servers. + foreach my $file (@ISP_nameserver_files) { + # Grab the IP address. + my $address = &grab_address_from_file($file); + + # Check if an address has been grabbed. + if ($address) { + # Add the address to the array of nameservers. + push(@nameservers, $address); + } + } + } + + # Check if DNS servers are configured. + if (%servers) { + # Loop through the hash of configured DNS servers. + foreach my $id (keys %servers) { + my $address = $servers{$id}[0]; + my $status = $servers{$id}[2]; + + # Check if the current processed server is enabled. + if ($status eq "enabled") { + # Add the address to the array of nameservers. + push(@nameservers, $address); + } + } + } + + # Return the array. + return &General::uniq(@nameservers); +} + +# Reads the aliases of the RED interface and returns the addresses of all +# aliases that are enabled. +# +# If a reference to a hash is passed, the aliases will also be added to it +# by their name, like the firewall expects. +sub get_aliases { + my $aliases = shift; + + my @addresses = (); + my $ctr = 0; + + open(FILE, "${General::swroot}/ethernet/aliases") or die "Unable to open aliases file: $!\n"; + + while (my $line = ) { + chomp($line); + + my ($address, $state, $name) = split(/\,/, $line); + + # The firewall refers to aliases without a name by their position, + # which is why aliases that are being skipped have to be counted, too + if ($name eq "") { + $name = "Alias $ctr : $address"; + } + $ctr++; + + # Skip any aliases that are disabled or invalid + next unless ($state eq "on" && &check_ip_address($address)); + + if (defined $aliases) { + $aliases->{$name}{'IPT'} = "$address"; + $aliases->{$name}{'NET'} = "$address"; + } + + push(@addresses, $address); + } + + close(FILE); + + return @addresses; +} + sub list_wireless_interfaces() { my %interfaces = (); @@ -644,7 +882,7 @@ sub get_available_network_zones () { # ## Function to check if a network zone is available in the current configuration # -sub is_zone_available() { +sub is_zone_available($) { my $zone = lc shift; # Make sure the zone is valid @@ -655,6 +893,24 @@ sub is_zone_available() { return ($zone ~~ @available_zones); } +# Returns true if the RED device is a wireless device +sub is_red_wireless() { + # Find the name of the network device. + my $device = $ethernet{'RED_DEV'}; + + # Exit, if no device is configured. + return 0 if ($device eq ""); + + # Return 1 if the device is a wireless one. + my $path = "/sys/class/net/$device/wireless"; + if (-d $path) { + return 1; + } + + # Otherwise return zero. + return 0; +} + # ## Function to determine if the RED zone is in standard IP (or modem, PPP, VDSL, ...) mode # @@ -722,7 +978,7 @@ sub testsuite() { assert('find_next_ip_address("1.2.3.4", 2)', $result eq "1.2.3.6"); $result = &network_equal("192.168.0.0/24", "192.168.0.0/255.255.255.0"); - assert('network_equal("192.168.0.0/24", "192.168.0.0/255.255.255.0")', !$result); + assert('network_equal("192.168.0.0/24", "192.168.0.0/255.255.255.0")', $result); $result = &network_equal("192.168.0.0/24", "192.168.0.0/25"); assert('network_equal("192.168.0.0/24", "192.168.0.0/25")', !$result); @@ -750,10 +1006,10 @@ sub testsuite() { # Check &get_prefix() $result = &get_prefix("192.168.0.0/24"); - assert('get_prefix("192.168.0.0/24")', $result != 24); + assert('get_prefix("192.168.0.0/24")', $result == 24); $result = &get_prefix("192.168.0.0/255.255.0.0"); - assert('get_prefix("192.168.0.0/255.255.0.0")', $result != 16); + assert('get_prefix("192.168.0.0/255.255.0.0")', $result == 16); print "Testsuite completed successfully!\n"; diff --git a/config/cfgroot/protocols.pl b/config/cfgroot/protocols.pl deleted file mode 100644 index 39fb676ba..000000000 --- a/config/cfgroot/protocols.pl +++ /dev/null @@ -1,162 +0,0 @@ -# Protocols Data File -# -# This file is part of the IPCop Firewall. -# -# IPCop is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# IPCop is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with IPCop; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# (c) The IPCop Team -# -# $Id: protocols.pl,v 1.2.2.1 2005/01/26 12:23:20 riddles Exp $ -# -# Generated from /etc/protocols using: -# cat /etc/protocols | grep -ve "^#" | grep -v "^$" | \ -# awk '{ print "\"" $1 "\" => \"" $2 "\","}' -# -# Code supplied by Mark Wormgroor -# - -package Protocols; - -%protocols = ( -"ip" => "0", -"icmp" => "1", -"igmp" => "2", -"ggp" => "3", -"ipencap" => "4", -"st" => "5", -"tcp" => "6", -"cbt" => "7", -"egp" => "8", -"igp" => "9", -"bbn-rcc" => "10", -"nvp" => "11", -"pup" => "12", -"argus" => "13", -"emcon" => "14", -"xnet" => "15", -"chaos" => "16", -"udp" => "17", -"mux" => "18", -"dcn" => "19", -"hmp" => "20", -"prm" => "21", -"xns-idp" => "22", -"trunk-1" => "23", -"trunk-2" => "24", -"leaf-1" => "25", -"leaf-2" => "26", -"rdp" => "27", -"irtp" => "28", -"iso-tp4" => "29", -"netblt" => "30", -"mfe-nsp" => "31", -"merit-inp" => "32", -"sep" => "33", -"3pc" => "34", -"idpr" => "35", -"xtp" => "36", -"ddp" => "37", -"idpr-cmtp" => "38", -"tp++" => "39", -"il" => "40", -"ipv6" => "41", -"sdrp" => "42", -"ipv6-route" => "43", -"ipv6-frag" => "44", -"idrp" => "45", -"rsvp" => "46", -"gre" => "47", -"mhrp" => "48", -"bna" => "49", -"ipv6-crypt" => "50", -"ipv6-auth" => "51", -"i-nlsp" => "52", -"swipe" => "53", -"narp" => "54", -"mobile" => "55", -"tlsp" => "56", -"skip" => "57", -"ipv6-icmp" => "58", -"ipv6-nonxt" => "59", -"ipv6-opts" => "60", -"cftp" => "62", -"sat-expak" => "64", -"kryptolan" => "65", -"rvd" => "66", -"ippc" => "67", -"sat-mon" => "69", -"visa" => "70", -"ipcv" => "71", -"cpnx" => "72", -"cphb" => "73", -"wsn" => "74", -"pvp" => "75", -"br-sat-mon" => "76", -"sun-nd" => "77", -"wb-mon" => "78", -"wb-expak" => "79", -"iso-ip" => "80", -"vmtp" => "81", -"secure-vmtp" => "82", -"vines" => "83", -"ttp" => "84", -"nsfnet-igp" => "85", -"dgp" => "86", -"tcf" => "87", -"eigrp" => "88", -"ospf" => "89", -"sprite-rpc" => "90", -"larp" => "91", -"mtp" => "92", -"ax.25" => "93", -"ipip" => "94", -"micp" => "95", -"scc-sp" => "96", -"etherip" => "97", -"encap" => "98", -"gmtp" => "100", -"ifmp" => "101", -"pnni" => "102", -"pim" => "103", -"aris" => "104", -"scps" => "105", -"qnx" => "106", -"a/n" => "107", -"ipcomp" => "108", -"snp" => "109", -"compaq-peer" => "110", -"ipx-in-ip" => "111", -"vrrp" => "112", -"pgm" => "113", -"l2tp" => "115", -"ddx" => "116", -"iatp" => "117", -"stp" => "118", -"srp" => "119", -"uti" => "120", -"smp" => "121", -"sm" => "122", -"ptp" => "123", -"isis" => "124", -"fire" => "125", -"crtp" => "126", -"crdup" => "127", -"sscopmce" => "128", -"iplt" => "129", -"sps" => "130", -"pipe" => "131", -"sctp" => "132", -"fc" => "133", -); diff --git a/config/cfgroot/wireguard-functions.pl b/config/cfgroot/wireguard-functions.pl index 918eb027f..76b7a43b5 100644 --- a/config/cfgroot/wireguard-functions.pl +++ b/config/cfgroot/wireguard-functions.pl @@ -534,7 +534,7 @@ sub parse_configuration($$) { # ListenPort } elsif ($key eq "ListenPort") { - if (&General::validport($val)) { + if (&Network::check_port($val)) { $peer{'PORT'} = $val; } else { push(@errormessages, _('Invalid Endpoint Port')); @@ -598,7 +598,7 @@ sub parse_configuration($$) { # nothing # Check if we have a valid FQDN - } elsif (&General::validfqdn($address)) { + } elsif (&Network::check_fqdn($address)) { # nothing # Otherwise this fails diff --git a/config/firewall/convert-dmz b/config/firewall/convert-dmz index 7b7704548..25f003229 100755 --- a/config/firewall/convert-dmz +++ b/config/firewall/convert-dmz @@ -86,7 +86,7 @@ sub process_rules{ $field2=$e if($e eq 'ON'); #SOURCE IP-check $b=&check_ip($b); - if (&General::validipandmask($b)){ + if (&Network::check_subnet($b)){ #When ip valid, check if we have a network my ($ip,$subnet) = split ("/",$b); if ($f eq 'orange' && $ip eq $ifaces{'ORANGE_NETADDRESS'}){ @@ -95,10 +95,10 @@ sub process_rules{ }elsif($f eq 'blue' && $ip eq $ifaces{'BLUE_NETADDRESS'}){ $field3='std_net_src'; $field4='BLUE'; - }elsif($f eq 'orange' && &General::IpInSubnet($ip,$ifaces{'ORANGE_NETADDRESS'},$ifaces{'ORANGE_NETMASK'})){ + }elsif($f eq 'orange' && &Network::ip_address_in_network($ip, "$ifaces{'ORANGE_NETADDRESS'}/$ifaces{'ORANGE_NETMASK'}")){ $field3='src_addr'; $field4=$b; - }elsif($f eq 'blue' && &General::IpInSubnet($ip,$ifaces{'BLUE_NETADDRESS'},$ifaces{'BLUE_NETMASK'})){ + }elsif($f eq 'blue' && &Network::ip_address_in_network($ip, "$ifaces{'BLUE_NETADDRESS'}/$ifaces{'BLUE_NETMASK'}")){ $field3='src_addr'; $field4=$b; }else{ @@ -111,7 +111,7 @@ sub process_rules{ } #TARGET IP-check $c=&check_ip($c); - if (&General::validipandmask($c)){ + if (&Network::check_subnet($c)){ my $now=localtime; #When ip valid, check if we have a network my ($ip,$subnet) = split ("/",$c); @@ -121,10 +121,10 @@ sub process_rules{ }elsif($g eq 'blue' && $ip eq $ifaces{'BLUE_NETADDRESS'}){ $field5='std_net_tgt'; $field6='BLUE'; - }elsif($g eq 'green' && &General::IpInSubnet($ip,$ifaces{'GREEN_NETADDRESS'},$ifaces{'GREEN_NETMASK'})){ + }elsif($g eq 'green' && &Network::ip_address_in_network($ip, "$ifaces{'GREEN_NETADDRESS'}/$ifaces{'GREEN_NETMASK'}")){ $field5='tgt_addr'; $field6=$c; - }elsif($g eq 'blue' && &General::IpInSubnet($ip,$ifaces{'BLUE_NETADDRESS'},$ifaces{'BLUE_NETMASK'})){ + }elsif($g eq 'blue' && &Network::ip_address_in_network($ip, "$ifaces{'BLUE_NETADDRESS'}/$ifaces{'BLUE_NETMASK'}")){ $field5='tgt_addr'; $field6=$c; }else{ @@ -187,16 +187,16 @@ sub check_ip #ip with subnet in decimal if($adr =~ m/^(\d\d?\d?).(\d\d?\d?).(\d\d?\d?).(\d\d?\d?)\/(\d{1,2})$/){ $adr=int($1).".".int($2).".".int($3).".".int($4); - my $b = &General::iporsubtodec($5); + my $b = &Network::convert_prefix2netmask($5); $a=$adr."/".$b; }elsif($adr =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){ $adr=int($1).".".int($2).".".int($3).".".int($4); - if(&General::validip($adr)){ + if(&Network::check_ip_address($adr)){ $a=$adr."/32"; } } - if(&General::validipandmask($adr)){ - $a=&General::iporsubtodec($adr); + if(&Network::check_subnet($adr)){ + $a=$adr; } return $a; } diff --git a/config/firewall/convert-outgoingfw b/config/firewall/convert-outgoingfw index c917f8438..3414bc0fb 100755 --- a/config/firewall/convert-outgoingfw +++ b/config/firewall/convert-outgoingfw @@ -143,7 +143,7 @@ sub process_groups $mac =~ s/\s//gi; print LOG "$now Checking MAC $mac from group $group "; #MAC checking - if(&General::validmac($mac)){ + if(&Network::valid_mac($mac)){ $val=$mac; } if($val){ @@ -168,16 +168,16 @@ sub check_ip #ip with subnet in decimal if($adr =~ m/^(\d\d?\d?).(\d\d?\d?).(\d\d?\d?).(\d\d?\d?)\/(\d{1,2})$/){ $adr=int($1).".".int($2).".".int($3).".".int($4); - my $b = &General::iporsubtodec($5); + my $b = &Network::convert_prefix2netmask($5); $a=$adr."/".$b; }elsif($adr =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){ $adr=int($1).".".int($2).".".int($3).".".int($4); - if(&General::validip($adr)){ + if(&Network::check_ip_address($adr)){ $a=$adr."/255.255.255.255"; } } - if(&General::validipandmask($adr)){ - $a=&General::iporsubtodec($adr); + if(&Network::check_subnet($adr)){ + $a=$adr; } return $a; } @@ -221,15 +221,15 @@ sub new_hostgrp print LOG "Processing NETWORK $ippart/$subnet from Group $grp\n"; if(!&check_net($ippart,$subnet)){ #Check if this network is one one of IPFire internal networks - if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General::IpInSubnet($ippart,$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'})) + if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &Network::ip_address_in_network($ippart, "$ownnet{'GREEN_NETADDRESS'}/$ownnet{'GREEN_NETMASK'}")) { $name2='GREEN'; $name3='Standard Network'; - }elsif (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General::IpInSubnet($ippart,$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'})) + }elsif (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &Network::ip_address_in_network($ippart, "$ownnet{'ORANGE_NETADDRESS'}/$ownnet{'ORANGE_NETMASK'}")) { $name2='ORANGE'; $name3='Standard Network'; - }elsif (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General::IpInSubnet($ippart,$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'})) + }elsif (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &Network::ip_address_in_network($ippart, "$ownnet{'BLUE_NETADDRESS'}/$ownnet{'BLUE_NETMASK'}")) { $name2='BLUE'; $name3='Standard Network'; @@ -237,7 +237,7 @@ sub new_hostgrp { $name2='ALL'; $name3='Standard Network'; - }elsif(defined($ovpnSettings{'DOVPN_SUBNET'}) && "$ippart/".&General::iporsubtodec($subnet) eq $ovpnSettings{'DOVPN_SUBNET'}) + }elsif(defined($ovpnSettings{'DOVPN_SUBNET'}) && "$ippart/".&Network::get_netmask("$ippart/$subnet") eq $ovpnSettings{'DOVPN_SUBNET'}) { $name2='OpenVPN-Dyn'; $name3='Standard Network'; @@ -448,7 +448,7 @@ sub process_rules my $z=&check_ip($configline[5]); if($z){ my ($ipa,$subn) = split("/",$z); - $subn=&General::iporsubtocidr($subn); + $subn=&Network::get_prefix($z); $grp1='src_addr'; $source="$ipa/$subn"; }else{ @@ -456,7 +456,7 @@ sub process_rules next; } }elsif ($configline[2] eq 'mac') { - if(&General::validmac($configline[6])){ + if(&Network::valid_mac($configline[6])){ $grp1='src_addr'; $source=$configline[6]; }else{ @@ -483,7 +483,7 @@ sub process_rules my $address=&check_ip($configline[7]); if($address){ my ($dip,$dsub) = split("/",$address); - $dsub=&General::iporsubtocidr($dsub); + $dsub=&Network::get_prefix($address); $grp2='tgt_addr'; $target="$dip/$dsub"; }elsif(!$address){ @@ -507,7 +507,7 @@ sub process_rules foreach (@parts){ $_=~ tr/-/:/; if (!($_ =~ /^(\d+)\:(\d+)$/)) { - if(&General::validport($_)){ + if(&Network::check_port($_)){ $useport='ON'; push (@values,$_); $grp3='TGT_PORT'; @@ -517,7 +517,7 @@ sub process_rules } }else{ my ($a1,$a2) = split(/\:/,$_); - if (&General::validport($a1) && &General::validport($a2) && $a1 < $a2){ + if (&Network::check_port($a1) && &Network::check_port($a2) && $a1 < $a2){ $useport='ON'; push (@values,"$a1:$a2"); $grp3='TGT_PORT'; @@ -654,7 +654,7 @@ sub build_ovpn_grp } foreach my $key (sort keys %ccdconf){ my ($net,$subnet)=split("/",$ccdconf{$key}[1]); - $subnet=&General::iporsubtodec($subnet); + $subnet=&Network::get_netmask($ccdconf{$key}[1]); push (@ovpnnets,"$net,$subnet,$ccdconf{$key}[0]"); print LOG "$now ->found OpenVPN static net $net/$subnet\n"; } diff --git a/config/firewall/convert-portfw b/config/firewall/convert-portfw index 8383b5a61..3f9019f6d 100755 --- a/config/firewall/convert-portfw +++ b/config/firewall/convert-portfw @@ -102,7 +102,7 @@ sub build_rules $src = 'src_addr'; my ($a,$b) = split("/",$source); if ($b != ''){ - $b = &General::iporsubtocidr($b); + $b = &Network::get_prefix($source); }else{ $b = "32"; } diff --git a/config/firewall/firewall-lib.pl b/config/firewall/firewall-lib.pl index 2dfc44a94..b95be17aa 100644 --- a/config/firewall/firewall-lib.pl +++ b/config/firewall/firewall-lib.pl @@ -70,7 +70,7 @@ my $netsettings = "${General::swroot}/ethernet/settings"; &General::readhasharray("$configipsec", \%ipsecconf); &General::readhasharray("$configsrv", \%customservice); &General::readhasharray("$configsrvgrp", \%customservicegrp); -&General::get_aliases(\%aliases); +&Network::get_aliases(\%aliases); # Get all available locations. my @available_locations = &get_locations(); @@ -361,7 +361,7 @@ sub get_address # If the user manually typed an address, we just check if it is a MAC # address. Otherwise, we assume that it is an IP address. if ($key ~~ ["src_addr", "tgt_addr"]) { - if (&General::validmac($value)) { + if (&Network::valid_mac($value)) { push(@ret, ["-m mac --mac-source $value", ""]); } else { push(@ret, [$value, ""]); @@ -614,7 +614,7 @@ sub get_matching_firewall_address my $zone_subnet = $netsettings{$zone . "_NETADDRESS"}; my $zone_mask = $netsettings{$zone . "_NETMASK"}; - if (&General::IpInSubnet($address, $zone_subnet, $zone_mask)) { + if (&Network::ip_address_in_network($address, "$zone_subnet/$zone_mask")) { return $netsettings{$zone . "_ADDRESS"}; } } @@ -631,12 +631,9 @@ sub get_internal_firewall_ip_address return 0; } - # Convert net mask into correct format for &General::IpInSubnet(). - $net_mask = &General::iporsubtodec($net_mask); - my @addresses = &get_internal_firewall_ip_addresses($use_orange); foreach my $zone_address (@addresses) { - if (&General::IpInSubnet($zone_address, $net_address, $net_mask)) { + if (&Network::ip_address_in_network($zone_address, "$net_address/$net_mask")) { return $zone_address; } } diff --git a/config/firewall/rules.pl b/config/firewall/rules.pl index 1cd0dd446..5f4a306f5 100644 --- a/config/firewall/rules.pl +++ b/config/firewall/rules.pl @@ -117,7 +117,7 @@ my @locations = &Location::Functions::get_locations(); my @blocklists = &IPblocklist::get_blocklists(); # Name or the RED interface. -my $RED_DEV = &General::get_red_interface(); +my $RED_DEV = &Network::get_red_interface(); my @log_limit_options = &make_log_limit_options(); diff --git a/config/rootfiles/packages/perl-File-ReadBackwards b/config/rootfiles/common/perl-File-ReadBackwards similarity index 100% rename from config/rootfiles/packages/perl-File-ReadBackwards rename to config/rootfiles/common/perl-File-ReadBackwards diff --git a/config/rootfiles/core/205/filelists/files b/config/rootfiles/core/205/filelists/files index 84ea59750..fd0080675 100644 --- a/config/rootfiles/core/205/filelists/files +++ b/config/rootfiles/core/205/filelists/files @@ -1,12 +1,20 @@ etc/rc.d/init.d/console etc/rc.d/init.d/firewall +usr/lib/firewall/firewall-lib.pl +usr/lib/firewall/rules.pl +usr/sbin/convert-dmz +usr/sbin/convert-outgoingfw +usr/sbin/convert-portfw usr/share/suricata/rules/ipfire.rules var/ipfire/connscheduler/lib.pl var/ipfire/general-functions.pl var/ipfire/graphs.pl var/ipfire/header.pl +var/ipfire/http-client-functions.pl var/ipfire/ids-functions.pl +var/ipfire/ipblocklist-functions.pl var/ipfire/lang.pl +var/ipfire/location-functions.pl var/ipfire/main/manualpages var/ipfire/menu.d/00-menu.main var/ipfire/menu.d/10-system.menu @@ -16,4 +24,5 @@ var/ipfire/menu.d/40-services.menu var/ipfire/menu.d/50-firewall.menu var/ipfire/menu.d/60-ipfire.menu var/ipfire/menu.d/70-log.menu +var/ipfire/network-functions.pl var/ipfire/wireguard-functions.pl diff --git a/config/rootfiles/core/205/filelists/perl-File-ReadBackwards b/config/rootfiles/core/205/filelists/perl-File-ReadBackwards new file mode 120000 index 000000000..02fba93ec --- /dev/null +++ b/config/rootfiles/core/205/filelists/perl-File-ReadBackwards @@ -0,0 +1 @@ +../../../common/perl-File-ReadBackwards \ No newline at end of file diff --git a/config/rootfiles/core/205/update.sh b/config/rootfiles/core/205/update.sh index 2ffce48c2..efbdfba23 100644 --- a/config/rootfiles/core/205/update.sh +++ b/config/rootfiles/core/205/update.sh @@ -89,6 +89,14 @@ if [ -e "/opt/pakfire/db/installed/meta-perl-gettext" ] && [ -e "/opt/pakfire/db /opt/pakfire/db/rootfiles/perl-gettext fi +# perl-File-ReadBackwards is now part of the core system, remove Pakfire metadata for it +if [ -e "/opt/pakfire/db/installed/meta-perl-File-ReadBackwards" ] && [ -e "/opt/pakfire/db/meta/meta-perl-File-ReadBackwards" ]; then + rm -vf \ + /opt/pakfire/db/installed/meta-perl-File-ReadBackwards \ + /opt/pakfire/db/meta/meta-perl-File-ReadBackwards \ + /opt/pakfire/db/rootfiles/perl-File-ReadBackwards +fi + # Build initial ramdisks dracut --regenerate-all --force KVER="@KERNEL_RELEASE@" diff --git a/config/wio/wio.pl b/config/wio/wio.pl index 8169bdc16..b8a639c3b 100644 --- a/config/wio/wio.pl +++ b/config/wio/wio.pl @@ -77,12 +77,12 @@ my $rediface = "/var/ipfire/red/iface"; my $reddev = ''; if ( -e $rediface ) { - $reddev = &General::get_red_interface; + $reddev = &Network::get_red_interface; } my $redip = $hostname; -my $vpnpid = ( -e "/var/run/charon.pid" ? `awk '{print $1}' /var/run/charon.pid`: ''); -my $ovpnpid = ( -e "/var/run/openvpn-rw.pid" ? `awk '{print $1}' /var/run/openvpn-rw.pid`: ''); +my $vpnpid = &readpidfile("/var/run/charon.pid"); +my $ovpnpid = &readpidfile("/var/run/openvpn-rw.pid"); my $steptime = $wiosettings{'CRON'} *= 60; my $i_ping = 'icmp'; @@ -285,7 +285,25 @@ if ( !-e $onoffip ) { close(FILE); } else { - system("/bin/sed -i 's#$tmp[0],$tmp[1],$tmp[2],$tmp[3],$tmp[4],$tmp[5],$tmp[6],$tmp[7],$tmp[8],$tmp[9],$tmp[10],$tmp[11]#$id,$timestamp,$ipadr,$host,$enable,$remark,$dyndns,$mailon,$mailoff,$ping,$on,$httphost#g' $ipadrfile"); + # Replace the line of the client that has been checked + my $old = join(",", map { defined($_) ? $_ : '' } @tmp[0..11]); + my $new = "$id,$timestamp,$ipadr,$host,$enable,$remark,$dyndns,$mailon,$mailoff,$ping,$on,$httphost"; + + open( FILE, "< $ipadrfile" ); + my @lines = ; + close(FILE); + + foreach my $line (@lines) { + my $newline = ( $line =~ /\n$/ ? "\n" : '' ); + ( my $content = $line ) =~ s/\n$//; + + if ( $content eq $old ) { $line = $new . $newline; } + } + + open( FILE, "> $ipadrfile" ); + print FILE @lines; + close(FILE); + chmod ( 0644, $ipadrfile ); chown ( $owner, $group, $ipadrfile ); } @@ -304,6 +322,18 @@ undef (@arpclients); if ( -e $onoffip ) { unlink($onoffip); } +sub readpidfile { + my $file = shift; + + return '' unless ( -r $file ); + + open(FILE, "$file"); + my $pid = join('', ); + close (FILE); + + return $pid; +} + sub updatewiodata { my $id = $_[0]; diff --git a/config/wio/wiovpn.pl b/config/wio/wiovpn.pl index 7b06eeb51..856757c32 100644 --- a/config/wio/wiovpn.pl +++ b/config/wio/wiovpn.pl @@ -75,7 +75,11 @@ if ( ! -e "$ovpnpid" ) { } else { -@ovpnstatus = `cat /var/run/openvpn-rw.log`; +if ( -r "/var/run/openvpn-rw.log" ) { + open(FILE, "/var/run/openvpn-rw.log"); + @ovpnstatus = ; + close (FILE); +} open(FILE, "$ovpnconfig"); @ovpncfg = ; @@ -114,8 +118,7 @@ foreach (@ovpnarray) { ( $name, $remark, $status ) = split (/\,/, $_); - $remark = `/bin/cat $ovpnconfig | grep '$name' | cut -d "," -f 27`; - chomp ($remark); + $remark = join("\n", map { chomp(my $line = $_); (split(/,/, $line))[26] } grep (/$name/, @ovpncfg)); if ( $name =~ m/_/ ) { $nameul = $name; } else { ($nameul = $name) =~ s/ /_/g; } @@ -232,8 +235,7 @@ foreach (@vpnarray) { ( $name, $remark, $status ) = split (/\,/, $_); - $remark = `/bin/cat $vpnconfig | grep '$name' | cut -d "," -f 27`; - chomp ($remark); + $remark = join("\n", map { chomp(my $line = $_); (split(/,/, $line))[26] } grep (/$name/, @vpncfg)); if ( grep (/$name\{.*INSTALLED/ , @vpnstatus) ) { $vpnrwstatus = _('Active'); diff --git a/html/cgi-bin/aliases.cgi b/html/cgi-bin/aliases.cgi index 54faf6798..09af94876 100644 --- a/html/cgi-bin/aliases.cgi +++ b/html/cgi-bin/aliases.cgi @@ -54,7 +54,7 @@ my $setting = "${General::swroot}/ethernet/settings"; our $datafile = "${General::swroot}/ethernet/aliases"; # Fetch the name of the main RED interface -my $RED_INTERFACE = &General::get_red_interface(); +my $RED_INTERFACE = &Network::get_red_interface(); # Fetch all RED interfaces my @RED_INTERFACES = &Network::get_red_interfaces(); @@ -157,7 +157,7 @@ if ($settings{'ACTION'} eq _('Enable or Disable')) { if ($settings{'ACTION'} eq _('Add')) { # Validate inputs - if (! &General::validip($settings{'IP'})) {$errormessage = "invalid ip"}; + if (! &Network::check_ip_address($settings{'IP'})) {$errormessage = "invalid ip"}; $settings{'NAME'} = &Header::escape($settings{'NAME'}); # Make sure we haven't duplicated an alias or RED @@ -169,7 +169,7 @@ if ($settings{'ACTION'} eq _('Add')) { #Check if we have an emtpy name if (!$settings{'NAME'}){ $errormessage=_('Empty name.'); - }elsif(! &General::validfqdn($settings{'NAME'}) && ! &General::validhostname($settings{'NAME'})){ + }elsif(! &Network::check_fqdn($settings{'NAME'}) && ! &Network::check_hostname($settings{'NAME'})){ $errormessage=_('Invalid hostname.'); } my $idx=0; diff --git a/html/cgi-bin/atm-status.cgi b/html/cgi-bin/atm-status.cgi index 7af1e0c9a..4c68222ef 100644 --- a/html/cgi-bin/atm-status.cgi +++ b/html/cgi-bin/atm-status.cgi @@ -39,20 +39,22 @@ my %mainsettings = (); &Header::openpage(_('Status Information'), 1, ''); &Header::openbigbox('100%', 'left'); -my @modems = `find /sys/class/atm/*/device 2>/dev/null | cut -d'/' -f5`; +my @modems = map { (split(/\//, $_))[4] } glob("/sys/class/atm/*/device"); foreach (@modems){ chomp($_); &Header::openbox('100%', 'left',"ATM MODEM $_ State"); my $lines=0; print "
"; my $modem=$_; - my @pfile = `grep . /sys/class/atm/$modem/parameters/* 2>/dev/null`; - foreach (@pfile){ - chomp($_); - my $param= `echo $_ | cut -d'/' -f7 | cut -d':' -f1`; - my $value= `cat /sys/class/atm/$modem/parameters/$param`; - chomp($param); - chomp($value); + foreach my $file (glob("/sys/class/atm/$modem/parameters/*")) { + next unless (-f $file); + + my $param = (split(/\//, $file))[6]; + my $value = &read_file($file); + + # Skip anything that is empty + next if ($value eq ""); + if (!($param =~"uevent") && !($param =~"resource") && !($param eq "") @@ -67,13 +69,15 @@ foreach (@modems){ print " "; } } - my @pfile = `grep . /sys/class/atm/$modem/device/* 2>/dev/null`; - foreach (@pfile){ - chomp($_); - my $param= `echo $_ | cut -d'/' -f7 | cut -d':' -f1`; - my $value= `cat /sys/class/atm/$modem/device/$param`; - chomp($param); - chomp($value); + foreach my $file (glob("/sys/class/atm/$modem/device/*")) { + next unless (-f $file); + + my $param = (split(/\//, $file))[6]; + my $value = &read_file($file); + + # Skip anything that is empty + next if ($value eq ""); + if (!($param =~"uevent") && !($param =~"modalias") && !($param =~"bInterface") @@ -98,3 +102,18 @@ foreach (@modems){ } &Header::closebigbox(); &Header::closepage(); + +sub read_file($) { + my $file = shift; + + open(my $fh, "<", $file) or return ""; + my $content = do { local $/; <$fh> }; + close($fh); + + # Some files in sysfs cannot be read + return "" unless (defined $content); + + chomp($content); + + return $content; +} diff --git a/html/cgi-bin/backup.cgi b/html/cgi-bin/backup.cgi index 02062a342..855060f17 100644 --- a/html/cgi-bin/backup.cgi +++ b/html/cgi-bin/backup.cgi @@ -25,6 +25,7 @@ use strict; #use CGI::Carp 'fatalsToBrowser'; use File::Copy; use File::Basename; +use POSIX (); require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; @@ -149,13 +150,8 @@ if ( $message ne "" ){ &Header::closebox(); } -if ( -e "/var/ipfire/backup/" ){ - @backups = `cd /var/ipfire/backup/ && ls *.ipf 2>/dev/null`; -} - -if ( -e "/var/tmp/backupiso/" ){ - @backupisos = `cd /var/tmp/backupiso/ && ls *.iso 2>/dev/null`; -} +@backups = map { basename($_) } glob("/var/ipfire/backup/*.ipf"); +@backupisos = map { basename($_) } glob("/var/tmp/backupiso/*.iso"); &Header::openbox('100%', 'center', ); @@ -169,7 +165,7 @@ print < @{[ _('Exclude Log Files') ]}
END ; -my $MACHINE=`uname -m`; +my $MACHINE=(POSIX::uname())[4]; if (( $MACHINE =~ "x86_64" )) { print" @{[ _('Generate ISO') ]}
" } @@ -200,9 +196,8 @@ if ( $_ !~ /ipf$/){next;} chomp($_); my $Datei = "/var/ipfire/backup/".$_; my @Info = stat($Datei); -my $Size = $Info[7] / 1024 / 1024; -$Size = sprintf("%0.2f", $Size); -print "
"; +my $Size = &General::format_bytes($Info[7]); +print ""; print ""; } foreach (@backupisos){ @@ -210,9 +205,8 @@ if ( $_ !~ /iso$/){next;} chomp($_); my $Datei = "/var/tmp/backupiso/".$_; my @Info = stat($Datei); -my $Size = $Info[7] / 1024 / 1024; -$Size = sprintf("%0.2f", $Size); -print ""; +my $Size = &General::format_bytes($Info[7]); +print ""; print ""; } print </dev/null`; -my @addons = `ls /var/ipfire/backup/addons/backup/ 2>/dev/null`; -my %addons; - -foreach (@addons){ - my $addon=substr($_,0,length($_)-5); - $addons{$addon}=''; -} +my @addonincluds = map { basename($_) } glob("/var/ipfire/backup/addons/includes/*"); +my %addons = map { basename($_, ".ipf") => '' } glob("/var/ipfire/backup/addons/backup/*.ipf"); print "
$param$value
@{[ sprintf(_('Backup from %s, size %s MB'), qq{$_}, $Size) ]}
@{[ sprintf(_('Backup from %s, size %s'), qq{$_}, $Size) ]}
@{[ sprintf(_('Backup from %s, size %s MB'), qq{$_}, $Size) ]}
@{[ sprintf(_('Backup from %s, size %s'), qq{$_}, $Size) ]}
"; foreach (@addonincluds){ @@ -241,17 +229,10 @@ chomp($_); delete $addons{$_}; my $Datei = "/var/ipfire/backup/addons/backup/".$_.".ipf"; my @Info = stat($Datei); -my $Size = $Info[7] / 1024; +my $Size = &General::format_bytes($Info[7]); if ( -e $Datei ){ - if ($Size < 1) { - $Size = sprintf("%.2f", $Size); - print ""; - } else { - $Size = sprintf("%2d", $Size); - print ""; - - } + print ""; print < @@ -289,9 +270,8 @@ foreach (keys(%addons)){ chomp($_); my $Datei = "/var/ipfire/backup/addons/backup/".$_.".ipf"; my @Info = stat($Datei); -my $Size = $Info[7] / 1024; -$Size = sprintf("%2d", $Size); -print ""; +my $Size = &General::format_bytes($Info[7]); +print ""; print <
diff --git a/html/cgi-bin/captive/index.cgi b/html/cgi-bin/captive/index.cgi index c18d153e1..bf4f14a7c 100644 --- a/html/cgi-bin/captive/index.cgi +++ b/html/cgi-bin/captive/index.cgi @@ -49,7 +49,7 @@ my $errormessage; my $url=param('redirect'); #Create /var/ipfire/captive/clients if not exist -unless (-f $clients){ system("touch $clients"); } +unless (-f $clients){ open(FILE, ">>$clients"); close(FILE); } #Get GUI variables &getcgihash(\%cgiparams); diff --git a/html/cgi-bin/captive/redirect.cgi b/html/cgi-bin/captive/redirect.cgi index 7c5b5e7c9..f1fd3253b 100644 --- a/html/cgi-bin/captive/redirect.cgi +++ b/html/cgi-bin/captive/redirect.cgi @@ -40,12 +40,12 @@ my $target; my $client_address = $ENV{X_FORWARDED_FOR} || $ENV{REMOTE_ADDR} || ""; if ($settingshash{'ENABLE_GREEN'} eq "on" && $ethernethash{'GREEN_ADDRESS'} ne '') { - if (&General::IpInSubnet($client_address, $ethernethash{'GREEN_ADDRESS'}, $ethernethash{'GREEN_NETMASK'})) { + if (&Network::ip_address_in_network($client_address, "$ethernethash{'GREEN_ADDRESS'}/$ethernethash{'GREEN_NETMASK'}")) { $target = $ethernethash{'GREEN_ADDRESS'}; } } elsif($settingshash{'ENABLE_BLUE'} eq "on" && $ethernethash{'BLUE_ADDRESS'} ne '') { - if (&General::IpInSubnet($client_address, $ethernethash{'BLUE_ADDRESS'}, $ethernethash{'BLUE_NETMASK'})) { + if (&Network::ip_address_in_network($client_address, "$ethernethash{'BLUE_ADDRESS'}/$ethernethash{'BLUE_NETMASK'}")) { $target = $ethernethash{'BLUE_ADDRESS'}; } diff --git a/html/cgi-bin/connections.cgi b/html/cgi-bin/connections.cgi index bd118897a..79f81000f 100644 --- a/html/cgi-bin/connections.cgi +++ b/html/cgi-bin/connections.cgi @@ -67,7 +67,7 @@ if ($address) { } # Add all aliases -my @aliases = &IDS::get_aliases(); +my @aliases = &Network::get_aliases(); for my $alias (@aliases) { $networks{"${alias}/32"} = ${Header::colourfw}; } @@ -242,10 +242,15 @@ print <) { +# Sort by the remaining lifetime which is in the fifth column +my @conntrack = map { $_->[1] } + sort { $b->[0] <=> $a->[0] } + map { [ (split(' ', $_))[4], $_ ] } ; + +foreach my $line (@conntrack) { my @conn = split(' ', $line); # The first bit is the l3 protocol. @@ -358,8 +363,8 @@ foreach my $line () { } # Format bytes - my $bytes_in = &General::formatBytes($bytes[0]); - my $bytes_out = &General::formatBytes($bytes[1]); + my $bytes_in = &General::format_bytes($bytes[0]); + my $bytes_out = &General::format_bytes($bytes[1]); # enumerate location information my $srcccode = &Location::Functions::lookup_country_code($sip_ret); diff --git a/html/cgi-bin/ddns.cgi b/html/cgi-bin/ddns.cgi index 596a94d52..916572dee 100644 --- a/html/cgi-bin/ddns.cgi +++ b/html/cgi-bin/ddns.cgi @@ -168,7 +168,7 @@ if (($settings{'ACTION'} eq _('Add')) || ($settings{'ACTION'} eq _('Update'))) { } # Check if a valid domainname has been provided. - if (!&General::validdomainname($settings{'HOSTNAME'})) { + if (!&Network::check_domainname($settings{'HOSTNAME'})) { $errormessage = _('Invalid domain name.'); } @@ -602,8 +602,8 @@ END $gdesc = _('Enabled (click to disable)'); # Check if the given hostname is a FQDN before doing a nslookup. - if (&General::validfqdn($hostname)) { - $sync = (&General::DyndnsServiceSync ($ip,$temp[1], $temp[2]) ? "": "") ; + if (&Network::check_fqdn($hostname)) { + $sync = (&HTTPClient::DyndnsServiceSync ($ip,$temp[1], $temp[2]) ? "": "") ; } $toggle_enabled = 'off'; diff --git a/html/cgi-bin/dhcp.cgi b/html/cgi-bin/dhcp.cgi index 75227beae..a8e288df3 100644 --- a/html/cgi-bin/dhcp.cgi +++ b/html/cgi-bin/dhcp.cgi @@ -20,6 +20,7 @@ ############################################################################### use strict; +use Time::Local; use experimental 'smartmatch'; # enable only the following on debugging purpose @@ -52,7 +53,7 @@ our $OptionTypes = 'boolean|((un)?signed )?integer (8|16|32)|ip-address|text|str &Header::showhttpheaders(); our @ITFs=('GREEN'); -if (&Header::blue_used()){push(@ITFs,'BLUE');} +if (&Network::is_zone_available("blue")){push(@ITFs,'BLUE');} #Settings1 for the first screen box foreach my $itf (@ITFs) { @@ -145,7 +146,7 @@ if ($dhcpsettings{'ACTION'} eq _('Save')) { if ($dhcpsettings{"ENABLE_${itf}"} eq 'on' ) { # "Start" is defined, need "End" and vice versa if ($dhcpsettings{"START_ADDR_${itf}"}) { - if (!(&General::validip($dhcpsettings{"START_ADDR_${itf}"}))) { + if (!(&Network::check_ip_address($dhcpsettings{"START_ADDR_${itf}"}))) { $errormessage = "DHCP on ${itf}: " . _('Invalid start address.'); goto ERROR; } @@ -153,16 +154,14 @@ if ($dhcpsettings{'ACTION'} eq _('Save')) { $errormessage = "DHCP on ${itf}: " . _('Invalid end address.'); goto ERROR; } - if (! &General::IpInSubnet ( $dhcpsettings{"START_ADDR_${itf}"}, - $netsettings{"${itf}_NETADDRESS"}, - $netsettings{"${itf}_NETMASK"})) { + if (! &Network::ip_address_in_network($dhcpsettings{"START_ADDR_${itf}"}, $netsettings{"${itf}_NETADDRESS"} . "/" . $netsettings{"${itf}_NETMASK"})) { $errormessage = "DHCP on ${itf}: " . _('Invalid start address.'); goto ERROR; } } if ($dhcpsettings{"END_ADDR_${itf}"}) { - if (!(&General::validip($dhcpsettings{"END_ADDR_${itf}"}))) { + if (!(&Network::check_ip_address($dhcpsettings{"END_ADDR_${itf}"}))) { $errormessage = "DHCP on ${itf}: " . _('Invalid end address.'); goto ERROR; } @@ -170,9 +169,7 @@ if ($dhcpsettings{'ACTION'} eq _('Save')) { $errormessage = "DHCP on ${itf}: " . _('Invalid start address.'); goto ERROR; } - if (! &General::IpInSubnet ( $dhcpsettings{"END_ADDR_${itf}"}, - $netsettings{"${itf}_NETADDRESS"}, - $netsettings{"${itf}_NETMASK"})) { + if (! &Network::ip_address_in_network($dhcpsettings{"END_ADDR_${itf}"}, $netsettings{"${itf}_NETADDRESS"} . "/" . $netsettings{"${itf}_NETMASK"})) { $errormessage = "DHCP on ${itf}: " . _('Invalid end address.'); goto ERROR; } @@ -203,13 +200,13 @@ if ($dhcpsettings{'ACTION'} eq _('Save')) { } if ($dhcpsettings{"DNS1_${itf}"}) { - if (!(&General::validip($dhcpsettings{"DNS1_${itf}"}))) { + if (!(&Network::check_ip_address($dhcpsettings{"DNS1_${itf}"}))) { $errormessage = "DHCP on ${itf}: " . _('Invalid primary DNS.'); goto ERROR; } } if ($dhcpsettings{"DNS2_${itf}"}) { - if (!(&General::validip($dhcpsettings{"DNS2_${itf}"}))) { + if (!(&Network::check_ip_address($dhcpsettings{"DNS2_${itf}"}))) { $errormessage = "DHCP on ${itf}: " . _('Invalid secondary DNS.'); goto ERROR; } @@ -220,13 +217,13 @@ if ($dhcpsettings{'ACTION'} eq _('Save')) { } if ($dhcpsettings{"WINS1_${itf}"}) { - if (!(&General::validip($dhcpsettings{"WINS1_${itf}"}))) { + if (!(&Network::check_ip_address($dhcpsettings{"WINS1_${itf}"}))) { $errormessage = "DHCP on ${itf}: " . _('Invalid WINS server address.'); goto ERROR; } } if ($dhcpsettings{"WINS2_${itf}"}) { - if (!(&General::validip($dhcpsettings{"WINS2_${itf}"}))) { + if (!(&Network::check_ip_address($dhcpsettings{"WINS2_${itf}"}))) { $errormessage = "DHCP on ${itf}: " . _('Invalid WINS server address.'); goto ERROR; } @@ -236,13 +233,13 @@ if ($dhcpsettings{'ACTION'} eq _('Save')) { } } if ($dhcpsettings{"NEXT_${itf}"}) { - if (!(&General::validip($dhcpsettings{"NEXT_${itf}"}))) { + if (!(&Network::check_ip_address($dhcpsettings{"NEXT_${itf}"}))) { $errormessage = "next-server on ${itf}: " . _('Invalid IP Address'); goto ERROR; } } if ($dhcpsettings{"NTP1_${itf}"}) { - if (!(&General::validip($dhcpsettings{"NTP1_${itf}"}))) { + if (!(&Network::check_ip_address($dhcpsettings{"NTP1_${itf}"}))) { $errormessage = "DHCP on ${itf}: " . _('Invalid Primary NTP Server Address'); goto ERROR; } @@ -252,7 +249,7 @@ if ($dhcpsettings{'ACTION'} eq _('Save')) { } } if ($dhcpsettings{"NTP2_${itf}"}) { - if (!(&General::validip($dhcpsettings{"NTP2_${itf}"}))) { + if (!(&Network::check_ip_address($dhcpsettings{"NTP2_${itf}"}))) { $errormessage = "DHCP on ${itf}: " . _('Invalid Secondary NTP Server Address'); goto ERROR; } @@ -299,7 +296,7 @@ if ($ENV{'QUERY_STRING'} =~ /^FETHER|^FIPADDR/ ) { } #Sorting of allocated leases -&Header::CheckSortOrder; +&CheckSortOrder(); ## Now manipulate the two multi-line list with Settings2. @@ -423,10 +420,10 @@ if ($dhcpsettings{'ACTION'} eq _('Enable or Disable').'2') { if ($dhcpsettings{'ACTION'} eq _('Add').'2') { $dhcpsettings{'FIX_MAC'} =~ tr/-/:/; - unless(&General::validip($dhcpsettings{'FIX_ADDR'})) { $errormessage = _('Invalid Fixed IP Address'); } - unless(&General::validmac($dhcpsettings{'FIX_MAC'})) { $errormessage = _('Invalid Fixed MAC Address'); } + unless(&Network::check_ip_address($dhcpsettings{'FIX_ADDR'})) { $errormessage = _('Invalid Fixed IP Address'); } + unless(&Network::valid_mac($dhcpsettings{'FIX_MAC'})) { $errormessage = _('Invalid Fixed MAC Address'); } if ($dhcpsettings{'FIX_NEXTADDR'}) { - unless(&General::validip($dhcpsettings{'FIX_NEXTADDR'})) { $errormessage = _('Invalid Fixed IP Address'); } + unless(&Network::check_ip_address($dhcpsettings{'FIX_NEXTADDR'})) { $errormessage = _('Invalid Fixed IP Address'); } } my $key = 0; @@ -437,15 +434,11 @@ if ($dhcpsettings{'ACTION'} eq _('Add').'2') { # if ip are not inside a known subnet, I don't warn. # Also it may be needed to put duplicate fixed lease in their right subnet definition.. foreach my $itf (@ITFs) { - my $scoped = &General::IpInSubnet($dhcpsettings{'FIX_ADDR'}, - $netsettings{"${itf}_NETADDRESS"}, - $netsettings{"${itf}_NETMASK"}) && + my $scoped = &Network::ip_address_in_network($dhcpsettings{'FIX_ADDR'}, $netsettings{"${itf}_NETADDRESS"} . "/" . $netsettings{"${itf}_NETMASK"}) && $dhcpsettings{"ENABLE_${itf}"} eq 'on'; if ( $scoped && (lc($dhcpsettings{'FIX_MAC'}) eq lc($temp[0])) && - &General::IpInSubnet($temp[1], - $netsettings{"${itf}_NETADDRESS"}, - $netsettings{"${itf}_NETMASK"})) { + &Network::ip_address_in_network($temp[1], $netsettings{"${itf}_NETADDRESS"} . "/" . $netsettings{"${itf}_NETMASK"})) { $errormessage = "@{[ _('MAC address already in use') ]} $dhcpsettings{'FIX_MAC'}"; last CHECK; } @@ -1047,9 +1040,7 @@ foreach my $line (@current2) { $ipinrange{$temp[1]} = 0; foreach my $itf (@ITFs) { # Mark IP addresses outwith known subnets - if ( &General::IpInSubnet($temp[1], - $netsettings{"${itf}_NETADDRESS"}, - $netsettings{"${itf}_NETMASK"})) { + if ( &Network::ip_address_in_network($temp[1], $netsettings{"${itf}_NETADDRESS"} . "/" . $netsettings{"${itf}_NETMASK"})) { $ipoutside{$temp[1]} = 0; } # Mark IP addresses that overlap with dynamic range @@ -1191,7 +1182,7 @@ END foreach my $itf (@ITFs) { if ($dhcpsettings{"ENABLE_${itf}"} eq 'on') { # display leases with a list of actions to do with the global select checkbox. - &Header::PrintActualLeases("+"); # "+" => create fixed leases from nodeaddress + &PrintActualLeases(); last; #Print one time only for all interfaces }; } @@ -1201,6 +1192,189 @@ foreach my $itf (@ITFs) { ## Ouf it's the end ! +sub CheckSortOrder { +#Sorting of allocated leases + if ($ENV{'QUERY_STRING'} =~ /^IPADDR|^ETHER|^HOSTNAME|^ENDTIME/ ) { + my $newsort=$ENV{'QUERY_STRING'}; + my %settings = (); + &General::readhash($setting, \%settings); + my $act=$settings{'SORT_LEASELIST'}; + #Reverse actual ? + if ($act =~ $newsort) { + if ($act !~ 'Rev') {$newsort.='Rev'}; + }; + + $settings{'SORT_LEASELIST'}=$newsort; + &General::writehash($setting, \%settings); + + # Sort the list that is about to be shown + $dhcpsettings{'SORT_LEASELIST'}=$newsort; + } + +} + +sub PrintActualLeases +{ + &Header::openbox('100%', 'left', _('Current Dynamic Leases')); + print < +
+ + + + + + +END +; + + our %entries = (); + my (@temp, $ip, $endtime, $endtime_print, $expired, $ether, $hostname); + + open(LEASES,"/var/state/dhcp/dhcpd.leases") or die "Can't open dhcpd.leases"; + while (my $line = ) { + next if( $line =~ /^\s*#/ ); + chomp($line); + @temp = split (' ', $line); + + if ($line =~ /^\s*lease/) { + $ip = $temp[1]; + #All field are not necessarily read. Clear everything + $endtime = 0; + $endtime_print = ""; + $expired = 0; + $ether = ""; + $hostname = ""; + } + + if ($line =~ /^\s*ends \d (\d+)\/(\d+)\/(\d+) (\d+):(\d+):(\d+)/) { + $endtime = timegm($6, $5, $4, $3, $2 - 1, $1 - 1900); + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $dst) = localtime($endtime); + $endtime_print = sprintf ("%02d/%02d/%d %02d:%02d:%02d",$mday,$mon+1,$year+1900,$hour,$min,$sec); + $expired = $endtime < time(); + + } elsif ($line =~ /^\s*ends never/) { + $endtime = 0; + $endtime_print = _('Never'); + $expired = 0; + } + + if ($line =~ /^\s*hardware ethernet/) { + $ether = $temp[2]; + $ether =~ s/;//g; + } + + if ($line =~ /^\s*client-hostname/) { + $hostname = "$temp[1] $temp[2] $temp[3]"; + $hostname =~ s/\"|[;\s]+?$//g; # remove quotes, trim semicolon and white space + } + + if ($line eq "}") { + my @record = ('IPADDR',$ip,'ENDTIME',$endtime,'ETHER',$ether,'HOSTNAME',$hostname,'endtime_print',$endtime_print,'expired',$expired); + my $record = {}; # create a reference to empty hash + %{$record} = @record; # populate that hash with @record + $entries{$record->{'IPADDR'}} = $record; # add this to a hash of hashes + } + } + close(LEASES); + + my $id = 0; + my $col = ""; + my $divider_printed = 0; + foreach my $key (sort leasesort keys %entries) { + my $hostname = &Header::escape($entries{$key}->{HOSTNAME}); + my $hostname_print = $hostname; + if($hostname_print eq "") { #print blank space if no hostname is found + $hostname_print = "   "; + } + + # separate active and expired leases with a horizontal line + if(($entries{$key}->{expired}) && ($divider_printed == 0)) { + $divider_printed = 1; + if ($id % 2) { + print "\n"; + } else { + print "\n"; + } + $id++; + } + + print "\n"; + if ($id % 2) { + $col="bgcolor='$Header::table1colour'"; + } else { + $col="bgcolor='$Header::table2colour'"; + } + + if($entries{$key}->{expired}) { + print <$entries{$key}->{IPADDR} + + + +END +; + } else { + print <$entries{$key}->{IPADDR} + + + +END +; + } + + print < + +END +; + $id++; + } + + print "
@{[ sprintf(_('Backup from %s, size %s KB, date %s'), qq{$_}, $Size, scalar(localtime($Info[9]))) ]}
@{[ sprintf(_('Backup from %s, size %s KB, date %s'), qq{$_}, $Size, scalar(localtime($Info[9]))) ]}
@{[ sprintf(_('Backup from %s, size %s, date %s'), qq{$_}, $Size, scalar(localtime($Info[9]))) ]}
@{[ sprintf(_('Backup from %s, size %s KB, date %s'), qq{$_}, $Size, scalar(localtime($Info[9]))) ]}
@{[ sprintf(_('Backup from %s, size %s, date %s'), qq{$_}, $Size, scalar(localtime($Info[9]))) ]}
@{[ _('IP Address') ]}@{[ _('MAC Address') ]}@{[ _('Hostname') ]}@{[ _('Lease Expires') ]} (local time d/m/y)@{[ _('Add to Fix Leases') ]}


$entries{$key}->{ETHER}$hostname_print$entries{$key}->{endtime_print}$entries{$key}->{ETHER}$hostname_print$entries{$key}->{endtime_print}
"; + &Header::closebox(); +} + +# This sub is used during display of actives leases +sub leasesort { + our %entries; + my $qs; + + if (rindex ($dhcpsettings{'SORT_LEASELIST'},'Rev') != -1) + { + $qs=substr ($dhcpsettings{'SORT_LEASELIST'},0,length($dhcpsettings{'SORT_LEASELIST'})-3); + if ($qs eq 'IPADDR') { + my @a = split(/\./,$entries{$a}->{$qs}); + my @b = split(/\./,$entries{$b}->{$qs}); + $entries{$a}->{'expired'} <=> $entries{$b}->{'expired'} || # always sort by expiration first + ($b[0]<=>$a[0]) || + ($b[1]<=>$a[1]) || + ($b[2]<=>$a[2]) || + ($b[3]<=>$a[3]); + } else { + $entries{$a}->{'expired'} <=> $entries{$b}->{'expired'} || + $entries{$b}->{$qs} cmp $entries{$a}->{$qs}; + } + } + else #not reverse + { + $qs=$dhcpsettings{'SORT_LEASELIST'}; + if ($qs eq 'IPADDR') { + my @a = split(/\./,$entries{$a}->{$qs}); + my @b = split(/\./,$entries{$b}->{$qs}); + $entries{$a}->{'expired'} <=> $entries{$b}->{'expired'} || + ($a[0]<=>$b[0]) || + ($a[1]<=>$b[1]) || + ($a[2]<=>$b[2]) || + ($a[3]<=>$b[3]); + } else { + $entries{$a}->{'expired'} <=> $entries{$b}->{'expired'} || + $entries{$a}->{$qs} cmp $entries{$b}->{$qs}; + } + } +} + sub sortcurrent1 # by now, do not sort, just write { open(FILE, ">$filename1") or die 'Unable to open dhcp advanced options file.'; diff --git a/html/cgi-bin/dns.cgi b/html/cgi-bin/dns.cgi index dd8288cc0..713b0a308 100644 --- a/html/cgi-bin/dns.cgi +++ b/html/cgi-bin/dns.cgi @@ -126,13 +126,13 @@ if (($cgiparams{'SERVERS'} eq _('Save')) || ($cgiparams{'SERVERS'} eq _('Update' } # Check if the given DNS server is valid. - elsif(!&General::validip($cgiparams{"NAMESERVER"})) { + elsif(!&Network::check_ip_address($cgiparams{"NAMESERVER"})) { $errormessage = "@{[ _('Invalid IP Address:') ]} $cgiparams{'NAMESERVER'}"; } # Check if the provided hostname is valid if ($cgiparams{'TLS_HOSTNAME'} ne "") { - unless (&General::validfqdn($cgiparams{"TLS_HOSTNAME"})) { + unless (&Network::check_fqdn($cgiparams{"TLS_HOSTNAME"})) { $errormessage = "@{[ _('Invalid IP Address or Hostname:') ]} " . &Header::escape($cgiparams{'TLS_HOSTNAME'}); } } @@ -466,7 +466,7 @@ END # Loop through the array which stores the files. foreach my $file (@ISP_nameserver_files) { # Grab the address of the nameserver. - my $address = &General::grab_address_from_file($file); + my $address = &Network::grab_address_from_file($file); # Check if we got an address. if ($address) { @@ -884,10 +884,8 @@ sub check_nameserver($$$$$) { # Add nameserver to the command array. push(@command, "\@$nameserver"); - # Connect to STDOUT and STDERR. - push(@command, "2>&1"); - - my @output = qx(@command); + # Execute the command and collect STDOUT and STDERR. + my @output = &General::system_output(@command); my $output = join("", @output); my $status = 0; diff --git a/html/cgi-bin/dnsbl.cgi b/html/cgi-bin/dnsbl.cgi index 84dd5b71c..53e82b7bf 100644 --- a/html/cgi-bin/dnsbl.cgi +++ b/html/cgi-bin/dnsbl.cgi @@ -208,14 +208,14 @@ if ($cgiparams{'ACTION'} eq _('Save')) { # Check allowed domains foreach my $domain (@ascii_allowed_domains) { - unless (&General::validfqdn($domain)) { + unless (&Network::check_fqdn($domain)) { push(@errormessages, "@{[ _('Invalid domain name.') ]}: ${domain}"); } } # Check blocked domains foreach my $domain (@ascii_blocked_domains) { - unless (&General::validfqdn($domain)) { + unless (&Network::check_fqdn($domain)) { push(@errormessages, "@{[ _('Invalid domain name.') ]}: ${domain}"); } } diff --git a/html/cgi-bin/dnsforward.cgi b/html/cgi-bin/dnsforward.cgi index d7cd2233d..1705a7512 100644 --- a/html/cgi-bin/dnsforward.cgi +++ b/html/cgi-bin/dnsforward.cgi @@ -64,14 +64,14 @@ close(FILE); if ($cgiparams{'ACTION'} eq _('Add')) { # Check if the entered domainname is valid. - unless (&General::validdomainname($cgiparams{'ZONE'})) { + unless (&Network::check_domainname($cgiparams{'ZONE'})) { $errormessage = _('Invalid domain name.'); } my @forward_servers = split(/\,/, $cgiparams{'FORWARD_SERVERS'}); foreach my $forward_server (@forward_servers) { # Check if the settings for the forward server are valid. - unless(&General::validip($forward_server)) { + unless(&Network::check_ip_address($forward_server)) { $errormessage = "@{[ _('Invalid IP Address:') ]} $forward_server"; last; } diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi index 404957f4a..19c520b6a 100644 --- a/html/cgi-bin/extrahd.cgi +++ b/html/cgi-bin/extrahd.cgi @@ -226,7 +226,7 @@ END my $bsize = &get_device_size($device); # Convert size into human-readable format. - my $size = &General::formatBytes($bsize); + my $size = &General::format_bytes($bsize); print <  @@ -281,7 +281,7 @@ sub print_row ($) { my $bsize = &get_device_size($partition); # Convert into human-readable format. - my $size = &General::formatBytes($bsize); + my $size = &General::format_bytes($bsize); # Try to omit the used filesystem. my $fs = $filesystems{$partition}; diff --git a/html/cgi-bin/firewall.cgi b/html/cgi-bin/firewall.cgi index f4b1086b7..510f6004b 100644 --- a/html/cgi-bin/firewall.cgi +++ b/html/cgi-bin/firewall.cgi @@ -272,7 +272,7 @@ if ($fwdfwsettings{'ACTION'} eq 'saverule') #check if manual ip (source) is orange network if ($fwdfwsettings{'grp1'} eq 'src_addr'){ my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}}); - if ( &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){ + if ( &Network::ip_address_in_network($sip, "$netsettings{'ORANGE_ADDRESS'}/$netsettings{'ORANGE_NETMASK'}")){ $checkorange='on'; } } @@ -480,7 +480,7 @@ sub checksource #check if ip with subnet if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?)$/) { ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'}); - $subnet = &General::iporsubtocidr($subnet); + $subnet = &Network::get_prefix("$ip/$subnet"); $fwdfwsettings{'isip'}='on'; } #check if only ip @@ -491,7 +491,7 @@ sub checksource } if ($fwdfwsettings{'isip'} ne 'on'){ - if (&General::validmac($fwdfwsettings{'src_addr'})){ + if (&Network::valid_mac($fwdfwsettings{'src_addr'})){ $fwdfwsettings{'ismac'}='on'; } } @@ -500,16 +500,16 @@ sub checksource $ip = &Network::ip_remove_zero($ip); ##check if ip is valid - if (! &General::validip($ip)){ + if (! &Network::check_ip_address($ip)){ $errormessage.=_('Invalid source MAC/IP address.')."
"; return $errormessage; } #check and form valid IP - $ip=&General::ip2dec($ip); - $ip=&General::dec2ip($ip); + $ip=&Network::ip2bin($ip); + $ip=&Network::bin2ip($ip); #check if net or broadcast $fwdfwsettings{'src_addr'}="$ip/$subnet"; - if(!&General::validipandmask($fwdfwsettings{'src_addr'})){ + if(!&Network::check_subnet($fwdfwsettings{'src_addr'})){ $errormessage.=_('Invalid source MAC/IP address.')."
"; return $errormessage; } @@ -551,7 +551,7 @@ sub checksource push (@values,$_); } }else{ - if (&General::validport($_)){ + if (&Network::check_port($_)){ push (@values,$_); }else{ @@ -609,7 +609,7 @@ sub checktarget #check if ip with subnet if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?)$/) { ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'}); - $subnet = &General::iporsubtocidr($subnet); + $subnet = &Network::get_prefix("$ip/$subnet"); } #check if only ip @@ -621,15 +621,15 @@ sub checktarget $ip = &Network::ip_remove_zero($ip); #check if ip is valid - if (! &General::validip($ip)){ + if (! &Network::check_ip_address($ip)){ $errormessage.=_('Invalid destination IP address.')."
"; return $errormessage; } #check and form valid IP - $ip=&General::ip2dec($ip); - $ip=&General::dec2ip($ip); + $ip=&Network::ip2bin($ip); + $ip=&Network::bin2ip($ip); $fwdfwsettings{'tgt_addr'}="$ip/$subnet"; - if(!&General::validipandmask($fwdfwsettings{'tgt_addr'})){ + if(!&Network::check_subnet($fwdfwsettings{'tgt_addr'})){ $errormessage.=_('Invalid destination IP address.')."
"; return $errormessage; } @@ -700,7 +700,7 @@ sub checktarget push (@values,$_); } }else{ - if (&General::validport($_)){ + if (&Network::check_port($_)){ push (@values,$_); }else{ $errormessage=_('Invalid destination port.'); @@ -833,7 +833,7 @@ sub checkrule push (@values,$_); } }else{ - if (&General::validport($_)){ + if (&Network::check_port($_)){ push (@values,$_); }else{ @@ -862,10 +862,10 @@ sub checkrule ($tip,$tcidr)=&get_ip("tgt","grp2"); #check same iprange in source and target if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){ - my $networkip1=&General::getnetworkip($sip,$scidr); - my $networkip2=&General::getnetworkip($tip,$tcidr); + my $networkip1=&Network::get_netaddress("$sip/$scidr"); + my $networkip2=&Network::get_netaddress("$tip/$tcidr"); if ($scidr gt $tcidr){ - if ( &General::IpInSubnet($networkip1,$tip,&General::iporsubtodec($tcidr))){ + if ( &Network::ip_address_in_network($networkip1, "$tip/$tcidr")){ $errormessage.=_('Source and destination IP addresses are from the same subnet.'); } }elsif($scidr eq $tcidr && $scidr eq '32'){ @@ -876,7 +876,7 @@ sub checkrule $hint.=_('Please double-check if this rule makes sense:')." Source: $networkip1/$scidr Target: $networkip2/$tcidr
"; } }else{ - if ( &General::IpInSubnet($networkip2,$sip,&General::iporsubtodec($scidr)) ){ + if ( &Network::ip_address_in_network($networkip2, "$sip/$scidr") ){ $errormessage.=_('Source and destination IP addresses are from the same subnet.') . $fwdfwsettings{'grp1'} .$fwdfwsettings{$fwdfwsettings{'grp1'}} . $fwdfwsettings{'grp2'} . $fwdfwsettings{$fwdfwsettings{'grp2'}}; } } @@ -966,8 +966,7 @@ sub checkvpn &General::readhasharray("$configccdnet", \%ccdnet); foreach my $key (sort keys %ccdnet){ my ($vpnip,$vpnsubnet) = split ("/",$ccdnet{$key}[1]); - my $sub=&General::iporsubtodec($vpnsubnet); - if (&General::IpInSubnet($ip,$vpnip,$sub)){ + if (&Network::ip_address_in_network($ip, "$vpnip/$vpnsubnet")){ return 0; } } @@ -1095,7 +1094,7 @@ END my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS"; my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK"; - my $defsub1=&General::subtocidr($ifaces{$defsub}); + my $defsub1=&Network::convert_netmask2prefix($ifaces{$defsub}); $ifaces{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED'); if ($ifaces{$defnet}){ print ">$network ($ifaces{$defnet}/$defsub1)"; @@ -1268,7 +1267,7 @@ EOF foreach my $val (@arr1){ #normalize subnet to cidr notation my ($val1,$val2) = split /\//, $val; - my $val3 = &General::iporsubtocidr($val2); + my $val3 = &Network::get_prefix($val); print ""; print "" if $ifaces{'GREEN_ADDRESS'}; - print "" if (&Header::orange_used()); - print ""if (&Header::blue_used()); + print "" if (&Network::is_zone_available("orange")); + print ""if (&Network::is_zone_available("blue")); print ""; @@ -1652,7 +1652,7 @@ END foreach my $val (@arr1){ #normalize subnet to cidr notation my ($val1,$val2) = split /\//, $val; - my $val3 = &General::iporsubtocidr($val2); + my $val3 = &Network::get_prefix($val); print ""; @@ -1956,7 +1956,7 @@ END $col="bgcolor='$color{'color22'}'"; print" "; } - my $colnet="$customnetwork{$key}[1]/".&General::subtocidr($customnetwork{$key}[2]); + my $colnet="$customnetwork{$key}[1]/".&Network::convert_netmask2prefix($customnetwork{$key}[2]); my $netcount=&getnetcount($customnetwork{$key}[0]); my $netusedin=&getusedin($customnetwork{$key}[0]); print"
$customnetwork{$key}[0]".&getcolor($colnet)."$customnetwork{$key}[3]$netcount x"; @@ -1989,7 +1989,7 @@ sub getcolor my $scidr; my $tdcolor=''; #Check if MAC - if (&General::validmac($c)){ return $c;} + if (&Network::valid_mac($c)){ return $c;} #Check if we got a full IP with subnet then split it if($c =~ /^(.*?)\/(.*?)$/){ @@ -1999,15 +1999,15 @@ sub getcolor } #Now check if IP is part of ORANGE,BLUE or GREEN - if ( &Header::orange_used() && &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){ + if ( &Network::is_zone_available("orange") && &Network::ip_address_in_network($sip, "$netsettings{'ORANGE_ADDRESS'}/$netsettings{'ORANGE_NETMASK'}")){ $tdcolor="$c"; return $tdcolor; } - if ( &General::IpInSubnet($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){ + if ( &Network::ip_address_in_network($sip, "$netsettings{'GREEN_ADDRESS'}/$netsettings{'GREEN_NETMASK'}")){ $tdcolor="$c"; return $tdcolor; } - if ( &Header::blue_used() && &General::IpInSubnet($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){ + if ( &Network::is_zone_available("blue") && &Network::ip_address_in_network($sip, "$netsettings{'BLUE_ADDRESS'}/$netsettings{'BLUE_NETMASK'}")){ $tdcolor="$c"; return $tdcolor; } @@ -2027,7 +2027,7 @@ sub getcolor foreach my $key (sort keys %ccdhost){ if ($ccdhost{$key}[3] eq 'net'){ my ($a,$b) = split("/",$ccdhost{$key}[11]); - if (&General::IpInSubnet($sip,$a,$b)){ + if (&Network::ip_address_in_network($sip, "$a/$b")){ $tdcolor="$c"; return $tdcolor; } @@ -2036,7 +2036,7 @@ sub getcolor #Check if IP is part of OpenVPN dynamic subnet my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'}); - if (&General::IpInSubnet($sip,$a,$b)){ + if (&Network::ip_address_in_network($sip, "$a/$b")){ $tdcolor="$c"; return $tdcolor; } @@ -2044,8 +2044,7 @@ sub getcolor #Check if IP is part of OpenVPN static subnet foreach my $key (sort keys %ccdnet){ my ($a,$b) = split("/",$ccdnet{$key}[1]); - $b =&General::iporsubtodec($b); - if (&General::IpInSubnet($sip,$a,$b)){ + if (&Network::ip_address_in_network($sip, "$a/$b")){ $tdcolor="$c"; return $tdcolor; } @@ -2054,8 +2053,7 @@ sub getcolor #Check if IP is part of IPsec RW network if ($ipsecsettings{'RW_NET'} ne ''){ my ($a,$b) = split("/",$ipsecsettings{'RW_NET'}); - $b=&General::iporsubtodec($b); - if (&General::IpInSubnet($sip,$a,$b)){ + if (&Network::ip_address_in_network($sip, "$a/$b")){ $tdcolor="$c"; return $tdcolor; } @@ -2066,8 +2064,7 @@ sub getcolor if ($ipsecconf{$key}[11]){ foreach my $ipsecsubitem (split(/\|/, $ipsecconf{$key}[11])) { my ($a,$b) = split("/",$ipsecsubitem); - $b=&General::iporsubtodec($b); - if (&General::IpInSubnet($sip,$a,$b)){ + if (&Network::ip_address_in_network($sip, "$a/$b")){ $tdcolor="$c"; return $tdcolor; } @@ -2665,7 +2662,7 @@ sub checkip my %hash=%{(shift)}; my $a=shift; foreach my $key (keys %hash) { - if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General::iporsubtodec($fwhostsettings{'SUBNET'})){ + if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&Network::get_netmask("$fwhostsettings{'IP'}/$fwhostsettings{'SUBNET'}")){ return 0; } } @@ -3251,7 +3248,7 @@ sub plausicheck if ($fwhostsettings{'type'} ne 'mac'){ &General::readhasharray("$configccdnet", \%ccdnet); foreach my $key (keys %ccdnet) { - my $test=(&General::getnetworkip($fwhostsettings{'IP'},&General::iporsubtocidr($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'}; + my $test=(&Network::get_netaddress("$fwhostsettings{'IP'}/$fwhostsettings{'SUBNET'}"))."/".$fwhostsettings{'SUBNET'}; if($ccdnet{$key}[1] eq $test){ $errormessage=$errormessage._('This IP address is already used by an OpenVPN network connection'); $fwhostsettings{'IP'} = $fwhostsettings{'orgip'}; diff --git a/html/cgi-bin/guardian.cgi b/html/cgi-bin/guardian.cgi index 7239152df..5012e2ba2 100644 --- a/html/cgi-bin/guardian.cgi +++ b/html/cgi-bin/guardian.cgi @@ -128,7 +128,7 @@ if ($settings{'ACTION'} eq _('Save')) { if ($settings{'IGNORE_ENTRY_ADDRESS'} ne '') { # Check if the given input is no valid IP-address or IP-address with subnet, display an error message. - if ((!&General::validip($settings{'IGNORE_ENTRY_ADDRESS'})) && (!&General::validipandmask($settings{'IGNORE_ENTRY_ADDRESS'}))) { + if ((!&Network::check_ip_address($settings{'IGNORE_ENTRY_ADDRESS'})) && (!&Network::check_subnet($settings{'IGNORE_ENTRY_ADDRESS'}))) { $errormessage = _('Invalid host address or subnet.'); } } else { @@ -268,7 +268,7 @@ if ($settings{'ACTION'} eq _('Save')) { my $gatewayfile = "${General::swroot}/red/remote-ipaddress"; # Get gateway address. - my $gateway = &General::grab_address_from_file($gatewayfile); + my $gateway = &Network::grab_address_from_file($gatewayfile); # Check if any input has been performed. if ($input eq '') { @@ -291,7 +291,7 @@ if ($settings{'ACTION'} eq _('Save')) { } # Check if the given input is a valid IP address. - elsif (!&General::validip($input)) { + elsif (!&Network::check_ip_address($input)) { $errormessage = _('Invalid host address or subnet.'); } @@ -311,7 +311,7 @@ if ($settings{'ACTION'} eq _('Save')) { if ($settings{'ADDRESS_UNBLOCK'} ne '') { # Check if the given input is no valid IP-address or IP-address with subnet, display an error message. - if ((!&General::validip($settings{'ADDRESS_UNBLOCK'})) && (!&General::validipandmask($settings{'ADDRESS_UNBLOCK'}))) { + if ((!&Network::check_ip_address($settings{'ADDRESS_UNBLOCK'})) && (!&Network::check_subnet($settings{'ADDRESS_UNBLOCK'}))) { $errormessage = _('Invalid host address or subnet.'); } @@ -928,7 +928,7 @@ sub GenerateIgnoreFile() { # Check if the status of the entry is "enabled". if ($status eq "enabled") { # Check if the address/network is valid. - if ((&General::validip($address)) || (&General::validipandmask($address))) { + if ((&Network::check_ip_address($address)) || (&Network::check_subnet($address))) { # Write the remark to the file. print FILE "# $remark\n"; diff --git a/html/cgi-bin/hosts.cgi b/html/cgi-bin/hosts.cgi index d2d78eb98..af001d860 100644 --- a/html/cgi-bin/hosts.cgi +++ b/html/cgi-bin/hosts.cgi @@ -115,15 +115,15 @@ if ($settings{'ACTION'} eq _('Enable or Disable')) { if ($settings{'ACTION'} eq _('Add')) { # Validate inputs - unless(&General::validip($settings{'IP'})) { + unless(&Network::check_ip_address($settings{'IP'})) { $errormessage = _('Invalid Fixed IP Address'); } - unless(&General::validhostname($settings{'HOST'})) { + unless(&Network::check_hostname($settings{'HOST'})) { $errormessage = _('Invalid hostname.'); } - if ($settings{'DOM'} && ! &General::validdomainname($settings{'DOM'})) { + if ($settings{'DOM'} && ! &Network::check_domainname($settings{'DOM'})) { $errormessage = _('Invalid domain name.'); } diff --git a/html/cgi-bin/ids.cgi b/html/cgi-bin/ids.cgi index ee5c0d601..e6216e7e3 100644 --- a/html/cgi-bin/ids.cgi +++ b/html/cgi-bin/ids.cgi @@ -90,7 +90,7 @@ if (($cgiparams{'WHITELIST'} eq _('Add')) || ($cgiparams{'WHITELIST'} eq _('Upda if ($cgiparams{'IGNORE_ENTRY_ADDRESS'} ne '') { # Check if the given input is no valid IP-address or IP-address with subnet, display an error message. - if ((!&General::validip($cgiparams{'IGNORE_ENTRY_ADDRESS'})) && (!&General::validipandmask($cgiparams{'IGNORE_ENTRY_ADDRESS'}))) { + if ((!&Network::check_ip_address($cgiparams{'IGNORE_ENTRY_ADDRESS'})) && (!&Network::check_subnet($cgiparams{'IGNORE_ENTRY_ADDRESS'}))) { $errormessage = _('Invalid host address or subnet.'); } } else { diff --git a/html/cgi-bin/index.cgi b/html/cgi-bin/index.cgi index 6a2e5a93d..0f51ba9ff 100644 --- a/html/cgi-bin/index.cgi +++ b/html/cgi-bin/index.cgi @@ -193,7 +193,7 @@ END END } - if (&General::RedIsWireless()) { + if (&Network::is_red_wireless()) { my $iface = $netsettings{"RED_DEV"} || "red0"; my $essid = &Network::wifi_get_essid($iface); @@ -293,7 +293,7 @@ print < @@ -309,8 +309,8 @@ END print ''; print ''; } -if (&Header::blue_used()) { - my $sub=&General::iporsubtocidr($netsettings{'BLUE_NETMASK'}); +if (&Network::is_zone_available("blue")) { + my $sub=&Network::convert_netmask2prefix($netsettings{'BLUE_NETMASK'}); print < @@ -326,8 +326,8 @@ END print ''; print ''; } -if (&Header::orange_used()) { - my $sub=&General::iporsubtocidr($netsettings{'ORANGE_NETMASK'}); +if (&Network::is_zone_available("orange")) { + my $sub=&Network::convert_netmask2prefix($netsettings{'ORANGE_NETMASK'}); print < @@ -359,7 +359,7 @@ if (($confighash{'ENABLED'} eq "on") || ($confighash{'ENABLED_BLUE'} eq "on") || ($confighash{'ENABLED_ORANGE'} eq "on")) { my ($ovpnip,$sub) = split("/",$confighash{'DOVPN_SUBNET'}); - $sub=&General::iporsubtocidr($sub); + $sub=&Network::get_prefix($confighash{'DOVPN_SUBNET'}); $ovpnip="$ovpnip/$sub"; print < @@ -524,7 +524,7 @@ END $active='off'; #make cidr from ip my ($vpnip,$vpnsub) = split("/",$ovpnconfig{$dkey}[11]); - my $vpnsub=&General::iporsubtocidr($vpnsub); + my $vpnsub=&Network::get_prefix($ovpnconfig{$dkey}[11]); my $vpnip="$vpnip/$vpnsub"; print < @@ -580,14 +580,14 @@ foreach my $line (@df) { } # S.M.A.R.T. health warning -my @files = `/bin/ls /var/run/smartctl_out_hddtemp-* 2>/dev/null`; -foreach my $file (@files) { - chomp ($file); - my $disk=`echo $file | cut -d"-" -f2`; - chomp ($disk); - if (`/bin/grep "SAVE ALL DATA" $file`) { +foreach my $file (glob("/var/run/smartctl_out_hddtemp-*")) { + my ($disk) = ($file =~ m/^[^-]*-([^-]*)/); + + open(my $fh, "<", $file) or next; + if (grep { /SAVE ALL DATA/ } <$fh>) { push(@warnings, sprintf(_('Device: %s reports S.M.A.R.T. error'), "/dev/$disk")); } + close($fh); } my %coredb = &Pakfire::coredbinfo(); diff --git a/html/cgi-bin/ipinfo.cgi b/html/cgi-bin/ipinfo.cgi index 6f7efa41a..8f25863a2 100644 --- a/html/cgi-bin/ipinfo.cgi +++ b/html/cgi-bin/ipinfo.cgi @@ -60,7 +60,7 @@ my $whois_server = "whois.arin.net"; my $addr = CGI::param("ip") || ""; -if (&General::validip($addr)) { +if (&Network::check_ip_address($addr)) { # Write HTML page header... &Header::openpage(sprintf(_('IP Information for %s'), $addr), 1, ''); &Header::openbigbox('100%', 'left'); diff --git a/html/cgi-bin/logs.cgi/config.dat b/html/cgi-bin/logs.cgi/config.dat index cd3cd2fda..9a4bffb39 100644 --- a/html/cgi-bin/logs.cgi/config.dat +++ b/html/cgi-bin/logs.cgi/config.dat @@ -51,8 +51,8 @@ if ($logsettings{'ACTION'} eq _('Save')) { if ($logsettings{'ENABLE_REMOTELOG'} eq 'on') { - unless ( &General::validfqdn($logsettings{'REMOTELOG_ADDR'}) || - &General::validip ($logsettings{'REMOTELOG_ADDR'})) + unless ( &Network::check_fqdn($logsettings{'REMOTELOG_ADDR'}) || + &Network::check_ip_address ($logsettings{'REMOTELOG_ADDR'})) { $errormessage = _('Invalid Syslogd Server Address'); } diff --git a/html/cgi-bin/logs.cgi/firewalllog.dat b/html/cgi-bin/logs.cgi/firewalllog.dat index 7525d32b2..8a28bb33e 100644 --- a/html/cgi-bin/logs.cgi/firewalllog.dat +++ b/html/cgi-bin/logs.cgi/firewalllog.dat @@ -337,7 +337,7 @@ END ; # Generate hash to translate protocol numbers into protocol names. -my %protocols = &General::generateProtoTransHash(); +my %protocols = &generateProtoTransHash(); $lines = 0; foreach $_ (@log) @@ -464,3 +464,38 @@ END ; } +# Function to collect and generate a hash for translating protocol numbers into +# their names. +sub generateProtoTransHash () { + # File which contains the protocol definitions. + my $protocols_file = "/etc/protocols"; + + my %protocols = (); + + # Open protocols file. + open(FILE, "$protocols_file") or die "Could not open $protocols_file. $!\n"; + + # Loop through the file. + while (my $line = ) { + # Skip comments. + next if ($line =~ /^\#/); + + # Skip blank lines. + next if ($line =~ /^\s*$/); + + # Remove any newlines. + chomp($line); + + # Split line content. + my ($protocol_lc, $number, $protocol_uc, $comment) = split(' ', $line); + + # Add proto details to the hash of protocols. + $protocols{$number} = $protocol_uc; + } + + # Close file handle. + close(FILE); + + # Return the hash. + return %protocols; +} diff --git a/html/cgi-bin/logs.cgi/firewalllogcountry.dat b/html/cgi-bin/logs.cgi/firewalllogcountry.dat index 4c52b2f59..d02326fa6 100644 --- a/html/cgi-bin/logs.cgi/firewalllogcountry.dat +++ b/html/cgi-bin/logs.cgi/firewalllogcountry.dat @@ -293,7 +293,7 @@ END &Header::openbox('100%', 'left', _('Firewall-Diagram (Country)')); print "

@{[ sprintf(_('Total number of firewall hits for %s: %s'), qq{$longmonthstr $daystr}, $lines) ]}

"; -my $red_interface = &General::get_red_interface(); +my $red_interface = &Network::get_red_interface(); my $linesjc = 0; my %tabjc; diff --git a/html/cgi-bin/logs.cgi/ovpnclients.dat b/html/cgi-bin/logs.cgi/ovpnclients.dat index 04378e86d..4f36f58f3 100644 --- a/html/cgi-bin/logs.cgi/ovpnclients.dat +++ b/html/cgi-bin/logs.cgi/ovpnclients.dat @@ -294,8 +294,8 @@ unless ($errormessage) { my $connection_name = $row[0]; my $connection_open_time = $row[1]; my $connection_close_time = $row[2]; - my $connection_bytes_recieved = &General::formatBytes($row[3]); - my $connection_bytes_sent = &General::formatBytes($row[4]); + my $connection_bytes_recieved = &General::format_bytes($row[3]); + my $connection_bytes_sent = &General::format_bytes($row[4]); my $duration = &General::format_time($row[5]); # Colorize columns. diff --git a/html/cgi-bin/logs.cgi/urlfilter.dat b/html/cgi-bin/logs.cgi/urlfilter.dat index 11cdad5cc..ea384ce55 100644 --- a/html/cgi-bin/logs.cgi/urlfilter.dat +++ b/html/cgi-bin/logs.cgi/urlfilter.dat @@ -394,7 +394,7 @@ sub processevent $filestr = "$logdir/squidGuard.log"; foreach $logarch (<$filestr.*.gz>) { - open (LOG,"gzip -dc $logarch |"); + open (LOG, "-|", "gzip", "-dc", $logarch); foreach () { ($date,$time,$pid,@loginfo) = split(/ /); ($logyear,$logmonth,$logday) = split(/-/,$date); @@ -413,7 +413,7 @@ sub processevent foreach $logarch (<$logdir/*.gz>) { if ($logarch !~ /squidGuard\.log/) { - open (LOG,"gzip -dc $logarch |"); + open (LOG, "-|", "gzip", "-dc", $logarch); foreach () { ($date,$time,$pid,@loginfo) = split(/ /); ($logyear,$logmonth,$logday) = split(/-/,$date); diff --git a/html/cgi-bin/mac.cgi b/html/cgi-bin/mac.cgi index 10864f655..727c2f473 100644 --- a/html/cgi-bin/mac.cgi +++ b/html/cgi-bin/mac.cgi @@ -100,7 +100,9 @@ if ($macsettings{'ACTION'} eq _('Reconnect')) { &Header::closebox(); } if ($macsettings{'ACTION'} eq _('Delete') ) { - system("cat /dev/null > ${General::swroot}/mac/settings &"); + # Empty the settings file + open(FILE, ">${General::swroot}/mac/settings"); + close(FILE); &Header::openbox('100%', 'left', _('Successfully deleted!') ); print "@{[ _('The MAC address has been successfully deleted, but changes will only take effect after reboot.') ]}\n"; &Header::closebox(); diff --git a/html/cgi-bin/mail.cgi b/html/cgi-bin/mail.cgi index 90af52633..8d00164c8 100644 --- a/html/cgi-bin/mail.cgi +++ b/html/cgi-bin/mail.cgi @@ -267,10 +267,10 @@ END sub checkmailsettings { #Check if mailserver is an ip address or a domain if ($cgiparams{'txt_mailserver'} =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/){ - if (! &General::validip($cgiparams{'txt_mailserver'})){ + if (! &Network::check_ip_address($cgiparams{'txt_mailserver'})){ $errormessage .= _('Invalid Mail Server IP Address') . "
"; } - }elsif(! &General::validfqdn($cgiparams{'txt_mailserver'})){ + }elsif(! &Network::check_fqdn($cgiparams{'txt_mailserver'})){ $errormessage .= _('Invalid Mail Server Fqdn') . "
"; } #Check valid mailserverport diff --git a/html/cgi-bin/media.cgi b/html/cgi-bin/media.cgi index 955a2c9d7..b210f1e3e 100644 --- a/html/cgi-bin/media.cgi +++ b/html/cgi-bin/media.cgi @@ -41,7 +41,7 @@ undef (@dummy); my %cgiparams=(); -my @devices = `ls -1 /sys/block | grep -E '^sd|^mmcblk|^nvme|^xvd|^vd|^md' | sort | uniq`; +my @devices = grep { m#/(sd|mmcblk|nvme|xvd|vd|md)[^/]*$# } glob("/sys/block/*"); &Header::showhttpheaders(); &Header::openpage(_('Media Information'), 1, ''); @@ -60,7 +60,7 @@ foreach (@devices) { &Header::openbox('100%', 'center', _('Disk Usage')); print "\n"; -open(DF,'/bin/df -P -B M -x rootfs|'); +open(DF,'/bin/df -P -B 1 -x rootfs|'); while(){ if ($_ =~ m/^Filesystem/ ){ print < @@ -134,18 +140,22 @@ END } } close DF; -my @iostat1 = qx(/usr/bin/iostat -dm -p | grep -v "Linux" | awk '{print \$1}'); -my @iostat2 = qx(/usr/bin/iostat -dm -p | grep -v "Linux" | awk '{print \$6}'); -my @iostat3 = qx(/usr/bin/iostat -dm -p | grep -v "Linux" | awk '{print \$7}'); +my @iostat = &General::system_output("/usr/bin/iostat", "-dk", "-p"); print ""; -my $i=0; +print ""; -for(my $i = 1; $i <= $#iostat1; $i++){ - if ( $i eq '1' ){ - print ""; - }else{ - print ""; - } +foreach my $line (@iostat) { + my ($device, $tps, $read_rate, $written_rate, $discarded_rate, $read, $written) = split(' ', $line); + + # Skip the headers and any empty lines + next if ($line =~ m/Linux/); + next unless ($read =~ m/^\d+/); + + # iostat reports kilobytes + $read = &General::format_bytes($read * 1024); + $written = &General::format_bytes($written * 1024); + + print ""; } print "
$device
 \n

@{[ _('Transfers') ]}

@{[ _('Device') ]}@{[ _('Read') ]}@{[ _('Written') ]}
@{[ _('Device') ]}@{[ _('MB Read') ]}@{[ _('MB Written') ]}
$iostat1[$i]$iostat2[$i]$iostat3[$i]
$device$read$written
\n"; &Header::closebox(); diff --git a/html/cgi-bin/memory.cgi b/html/cgi-bin/memory.cgi index a997b541e..53a56869c 100644 --- a/html/cgi-bin/memory.cgi +++ b/html/cgi-bin/memory.cgi @@ -60,8 +60,8 @@ my $buffers=0; my $cached=0; my $available=0; -# output format: kibibytes, wide mode (buffers and cache in two columns) -open(my $cmd_fh, "-|", '/usr/bin/free -k -w') or die $!; +# output format: bytes, wide mode (buffers and cache in two columns) +open(my $cmd_fh, "-|", '/usr/bin/free -b -w') or die $!; while(<$cmd_fh>){ if ($_ =~ m/^\s+total\s+used\s+free\s+shared\s+buffers\s+cache\s+available$/ ){ print <$size KiB - $used KiB - $free KiB + @{[ &General::format_bytes($size) ]} + @{[ &General::format_bytes($used) ]} + @{[ &General::format_bytes($free) ]} END ; @@ -115,10 +115,10 @@ END close($cmd_fh); print <
-@{[ _('Shared') ]}$shared KiB -@{[ _('Buffers') ]}$buffers KiB -@{[ _('Cached') ]}$cached KiB -@{[ _('Available') ]}$available KiB +@{[ _('Shared') ]}@{[ &General::format_bytes($shared) ]} +@{[ _('Buffers') ]}@{[ &General::format_bytes($buffers) ]} +@{[ _('Cached') ]}@{[ &General::format_bytes($cached) ]} +@{[ _('Available') ]}@{[ &General::format_bytes($available) ]} END ; diff --git a/html/cgi-bin/netinternal.cgi b/html/cgi-bin/netinternal.cgi index eb6eb714a..d44de2b90 100644 --- a/html/cgi-bin/netinternal.cgi +++ b/html/cgi-bin/netinternal.cgi @@ -45,13 +45,13 @@ my @wireless=(); &Header::openbigbox('100%', 'left'); push (@graphs, ($netsettings{'GREEN_DEV'})); -if (&Header::blue_used() && $netsettings{'BLUE_DEV'}) {push (@graphs, ($netsettings{'BLUE_DEV'})); } -if (&Header::orange_used() && $netsettings{'ORANGE_DEV'}) {push (@graphs, ($netsettings{'ORANGE_DEV'})); } +if (&Network::is_zone_available("blue") && $netsettings{'BLUE_DEV'}) {push (@graphs, ($netsettings{'BLUE_DEV'})); } +if (&Network::is_zone_available("orange") && $netsettings{'ORANGE_DEV'}) {push (@graphs, ($netsettings{'ORANGE_DEV'})); } -my @wirelessgraphs = `ls -dA /var/log/rrd/collectd/localhost/wireless* 2>/dev/null`; -foreach (@wirelessgraphs){ - $_ =~ /(.*)\/wireless-(.*)/; - push(@wireless,$2); +foreach (glob("/var/log/rrd/collectd/localhost/wireless-*")) { + if ($_ =~ /\/wireless-(.*)/) { + push(@wireless, $1); + } } foreach (@graphs) { diff --git a/html/cgi-bin/netother.cgi b/html/cgi-bin/netother.cgi index 319ed9e17..99128f898 100644 --- a/html/cgi-bin/netother.cgi +++ b/html/cgi-bin/netother.cgi @@ -41,10 +41,10 @@ my @pings=(); &Header::openpage(_('Network (others)'), 1, ''); &Header::openbigbox('100%', 'left'); -my @pinggraphs = `ls -dA /var/log/rrd/collectd/localhost/ping/ping-*`; -foreach (@pinggraphs){ - $_ =~ /(.*)\/ping\/ping-(.*)\.rrd/; - push(@pings,$2); +foreach (glob("/var/log/rrd/collectd/localhost/ping/ping-*.rrd")) { + if ($_ =~ /\/ping\/ping-(.*)\.rrd/) { + push(@pings, $1); + } } foreach (@pings) { diff --git a/html/cgi-bin/netovpnrw.cgi b/html/cgi-bin/netovpnrw.cgi index ef99d3d8f..9d11a4279 100644 --- a/html/cgi-bin/netovpnrw.cgi +++ b/html/cgi-bin/netovpnrw.cgi @@ -41,10 +41,12 @@ my @vpns=(); &Header::openpage(_('OpenVPN: Roadwarrior Statistics'), 1, ''); &Header::openbigbox('100%', 'left'); -my @vpngraphs = `find /var/log/rrd/collectd/localhost/openvpn-*/ -not -path *openvpn-UNDEF* -not -path *openvpn-*n2n* -name *.rrd 2>/dev/null|sort`; -foreach (@vpngraphs){ - if($_ =~ /(.*)\/openvpn-(.*)\/if_octets.rrd/){ - push(@vpns,$2); +foreach (glob("/var/log/rrd/collectd/localhost/openvpn-*/if_octets.rrd")) { + # Skip any undefined and all net-to-net connections + next if ($_ =~ /openvpn-UNDEF/ || $_ =~ /openvpn-.*n2n/); + + if ($_ =~ /\/openvpn-(.*)\/if_octets\.rrd/) { + push(@vpns, $1); } } if(@vpns){ diff --git a/html/cgi-bin/netovpnsrv.cgi b/html/cgi-bin/netovpnsrv.cgi index d657db21d..dcefbdbdb 100644 --- a/html/cgi-bin/netovpnsrv.cgi +++ b/html/cgi-bin/netovpnsrv.cgi @@ -53,10 +53,12 @@ foreach my $key (sort {$vpnsettings{$a}[1] <=> $vpnsettings{$b}[1]} keys %vpnset &Header::openpage(_('OpenVPN: Net-to-Net Statistics'), 1, ''); &Header::openbigbox('100%', 'left'); -my @vpngraphs = `find /var/log/rrd/collectd/localhost/openvpn-*-n2n/ -not -path *openvpn-UNDEF* -name *traffic.rrd 2>/dev/null|sort`; -foreach (@vpngraphs){ - if($_ =~ /(.*)\/openvpn-(.*)\/if_octets-traffic.rrd/){ - push(@vpns,$2); +foreach (glob("/var/log/rrd/collectd/localhost/openvpn-*-n2n/if_octets-traffic.rrd")) { + # Skip any undefined connections + next if ($_ =~ /openvpn-UNDEF/); + + if ($_ =~ /\/openvpn-(.*)\/if_octets-traffic\.rrd/) { + push(@vpns, $1); } } if (@vpns || %ipsecgraphs) { diff --git a/html/cgi-bin/optionsfw.cgi b/html/cgi-bin/optionsfw.cgi index 65cbd6f7f..fe8410747 100644 --- a/html/cgi-bin/optionsfw.cgi +++ b/html/cgi-bin/optionsfw.cgi @@ -191,7 +191,7 @@ print < END - if (&Header::orange_used()) { + if (&Network::is_zone_available("orange")) { print < @{[ _('Masquerade ORANGE') ]} @@ -205,7 +205,7 @@ END END } - if (&Header::blue_used()) { + if (&Network::is_zone_available("blue")) { print < @{[ _('Masquerade BLUE') ]} diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi index 2089c5895..35561f4e7 100644 --- a/html/cgi-bin/ovpnmain.cgi +++ b/html/cgi-bin/ovpnmain.cgi @@ -309,7 +309,7 @@ sub writeserverconf { foreach my $key (keys %ccdconfhash) { my $a=$ccdconfhash{$key}[1]; my ($b,$c) = split (/\//, $a); - print CONF "route $b ".&General::cidrtosub($c)."\n"; + print CONF "route $b ".&Network::convert_prefix2netmask($c)."\n"; } my %ccdroutehash=(); &General::readhasharray("${General::swroot}/ovpn/ccdroute", \%ccdroutehash); @@ -917,13 +917,13 @@ sub check_routes_push $_=~s/\s*$//g; my ($ip2,$cidr2) = split (/\//,"$_"); - my $val2=$ip2."/".&General::iporsubtodec($cidr2); + my $val2=$ip2."/".&Network::get_netmask("$ip2/$cidr2"); if($val eq $val2){ return 0; } #subnetcheck - if (&General::IpInSubnet ($ip,$ip2,&General::iporsubtodec($cidr2))){ + if (&Network::ip_address_in_network($ip, "$ip2/$cidr2")){ return 0; } }; @@ -941,12 +941,12 @@ sub check_ccdroute &General::readhasharray("${General::swroot}/ovpn/ccdroute", \%ccdroutehash); foreach my $key (keys %ccdroutehash) { foreach my $i (1 .. $#{$ccdroutehash{$key}}) { - if (&General::iporsubtodec($val) eq $ccdroutehash{$key}[$i] && $ccdroutehash{$key}[0] ne $cgiparams{'NAME'}){ + if ($val eq $ccdroutehash{$key}[$i] && $ccdroutehash{$key}[0] ne $cgiparams{'NAME'}){ return 0; } my ($ip2,$cidr2) = split (/\//,$ccdroutehash{$key}[$i]); #subnetcheck - if (&General::IpInSubnet ($ip,$ip2,$cidr2)&& $ccdroutehash{$key}[0] ne $cgiparams{'NAME'} ){ + if (&Network::ip_address_in_network($ip, "$ip2/$cidr2")&& $ccdroutehash{$key}[0] ne $cgiparams{'NAME'} ){ return 0; } } @@ -961,12 +961,12 @@ sub check_ccdconf #check for existing routes in ccdroute &General::readhasharray("${General::swroot}/ovpn/ccd.conf", \%ccdconfhash); foreach my $key (keys %ccdconfhash) { - if (&General::iporsubtocidr($val) eq $ccdconfhash{$key}[1]){ + if ("$ip/".&Network::get_prefix($val) eq $ccdconfhash{$key}[1]){ return 0; } my ($ip2,$cidr2) = split (/\//,$ccdconfhash{$key}[1]); #subnetcheck - if (&General::IpInSubnet ($ip,$ip2,&General::cidrtosub($cidr2))){ + if (&Network::ip_address_in_network($ip, "$ip2/$cidr2")){ return 0; } @@ -1121,7 +1121,7 @@ if ($cgiparams{'ACTION'} eq _('Save Advanced Settings')) { } # Check port - unless (&General::validport($cgiparams{'DDEST_PORT'})) { + unless (&Network::check_port($cgiparams{'DDEST_PORT'})) { $errormessage = _('Invalid port. Must be a valid port number.'); goto ADV_ERROR; } @@ -1150,7 +1150,7 @@ if ($cgiparams{'ACTION'} eq _('Save Advanced Settings')) { } if ($cgiparams{'DHCP_DOMAIN'} ne ''){ - unless (&General::validdomainname($cgiparams{'DHCP_DOMAIN'}) || &General::validip($cgiparams{'DHCP_DOMAIN'})) { + unless (&Network::check_domainname($cgiparams{'DHCP_DOMAIN'}) || &Network::check_ip_address($cgiparams{'DHCP_DOMAIN'})) { $errormessage = _('Invalid Input for DHCP Domain'); goto ADV_ERROR; } @@ -1160,7 +1160,7 @@ if ($cgiparams{'ACTION'} eq _('Save Advanced Settings')) { # Check if all DNS servers are valid foreach my $dns_server (@dns_servers) { - unless (&General::validfqdn($dns_server) || &General::validip($dns_server)) { + unless (&Network::check_fqdn($dns_server) || &Network::check_ip_address($dns_server)) { $errormessage = _('Invalid Input for DHCP DNS:') . " ${dns_server}"; goto ADV_ERROR; } @@ -1173,7 +1173,7 @@ if ($cgiparams{'ACTION'} eq _('Save Advanced Settings')) { # Check if all WINS servers are valid foreach my $wins_server (@wins_servers) { - unless (&General::validfqdn($wins_server) || &General::validip($wins_server)) { + unless (&Network::check_fqdn($wins_server) || &Network::check_ip_address($wins_server)) { $errormessage = _('Invalid Input for DHCP WINS:') . " ${wins_server}"; goto ADV_ERROR; } @@ -1435,38 +1435,34 @@ if ($cgiparams{'ACTION'} eq _('Save') && $cgiparams{'TYPE'} eq '' && $cgiparams{ #DAN do we really need (to to check) this value? Besides if we listen on blue and orange too, #DAN this value has to leave. if ($cgiparams{'ENABLED'} eq 'on'){ - unless (&General::validfqdn($cgiparams{'VPN_IP'}) || &General::validip($cgiparams{'VPN_IP'})) { + unless (&Network::check_fqdn($cgiparams{'VPN_IP'}) || &Network::check_ip_address($cgiparams{'VPN_IP'})) { $errormessage = _('Invalid input for hostname.'); goto SETTINGS_ERROR; } } - if (! &General::validipandmask($cgiparams{'DOVPN_SUBNET'})) { + if (! &Network::check_subnet($cgiparams{'DOVPN_SUBNET'})) { $errormessage = _('OpenVPN subnet is invalid.'); goto SETTINGS_ERROR; } my @tmpovpnsubnet = split("\/",$cgiparams{'DOVPN_SUBNET'}); - if (&General::IpInSubnet ( $Network::ethernet{'RED_ADDRESS'}, - $tmpovpnsubnet[0], $tmpovpnsubnet[1])) { + if (&Network::ip_address_in_network($Network::ethernet{'RED_ADDRESS'}, "$tmpovpnsubnet[0]/$tmpovpnsubnet[1]")) { $errormessage = "@{[ _('OpenVPN subnet overlaps with:') ]} IPFire RED Network $Network::ethernet{'RED_ADDRESS'}"; goto SETTINGS_ERROR; } - if (&General::IpInSubnet ( $Network::ethernet{'GREEN_ADDRESS'}, - $tmpovpnsubnet[0], $tmpovpnsubnet[1])) { + if (&Network::ip_address_in_network($Network::ethernet{'GREEN_ADDRESS'}, "$tmpovpnsubnet[0]/$tmpovpnsubnet[1]")) { $errormessage = "@{[ _('OpenVPN subnet overlaps with:') ]} IPFire Green Network $Network::ethernet{'GREEN_ADDRESS'}"; goto SETTINGS_ERROR; } - if (&General::IpInSubnet ( $Network::ethernet{'BLUE_ADDRESS'}, - $tmpovpnsubnet[0], $tmpovpnsubnet[1])) { + if (&Network::ip_address_in_network($Network::ethernet{'BLUE_ADDRESS'}, "$tmpovpnsubnet[0]/$tmpovpnsubnet[1]")) { $errormessage = "@{[ _('OpenVPN subnet overlaps with:') ]} IPFire Blue Network $Network::ethernet{'BLUE_ADDRESS'}"; goto SETTINGS_ERROR; } - if (&General::IpInSubnet ( $Network::ethernet{'ORANGE_ADDRESS'}, - $tmpovpnsubnet[0], $tmpovpnsubnet[1])) { + if (&Network::ip_address_in_network($Network::ethernet{'ORANGE_ADDRESS'}, "$tmpovpnsubnet[0]/$tmpovpnsubnet[1]")) { $errormessage = "@{[ _('OpenVPN subnet overlaps with:') ]} IPFire Orange Network $Network::ethernet{'ORANGE_ADDRESS'}"; goto SETTINGS_ERROR; } @@ -1476,8 +1472,7 @@ if ($cgiparams{'ACTION'} eq _('Save') && $cgiparams{'TYPE'} eq '' && $cgiparams{ chomp($_); my @tempalias = split(/\,/,$_); if ($tempalias[1] eq 'on') { - if (&General::IpInSubnet ($tempalias[0] , - $tmpovpnsubnet[0], $tmpovpnsubnet[1])) { + if (&Network::ip_address_in_network($tempalias[0], "$tmpovpnsubnet[0]/$tmpovpnsubnet[1]")) { $errormessage = "@{[ _('OpenVPN subnet overlaps with:') ]} IPFire alias entry $tempalias[0]"; } } @@ -2021,7 +2016,7 @@ END $errormessage = _('Hostname cannot be empty.'); goto ROOTCERT_ERROR; } - unless (&General::validfqdn($cgiparams{'ROOTCERT_HOSTNAME'}) || &General::validip($cgiparams{'ROOTCERT_HOSTNAME'})) { + unless (&Network::check_fqdn($cgiparams{'ROOTCERT_HOSTNAME'}) || &Network::check_ip_address($cgiparams{'ROOTCERT_HOSTNAME'})) { $errormessage = _('Invalid input for hostname.'); goto ROOTCERT_ERROR; } @@ -3151,8 +3146,8 @@ END @{[ _('Country') ]} @{[ _('Virtual Address') ]} @{[ _('Logged in At') ]} - @{[ _('Bytes Sent') ]} - @{[ _('Bytes Received') ]} + @{[ _('Sent') ]} + @{[ _('Received') ]} @{[ _('Last Activity') ]} END @@ -3183,8 +3178,8 @@ END $userlookup{$match[2]} = $uid; $users[$uid]{'CommonName'} = $match[1]; $users[$uid]{'RealAddress'} = $match[2]; - $users[$uid]{'BytesReceived'} = &General::formatBytes($match[3]); - $users[$uid]{'BytesSent'} = &General::formatBytes($match[4]); + $users[$uid]{'BytesReceived'} = &General::format_bytes($match[3]); + $users[$uid]{'BytesSent'} = &General::format_bytes($match[4]); $users[$uid]{'Since'} = $match[5]; my $address = (split ':', $users[$uid]{'RealAddress'})[1]; @@ -3762,46 +3757,46 @@ if ($cgiparams{'TYPE'} eq 'host') { goto VPNCONF_ERROR; } my ($ip1,$cidr1) = split (/\//, $val); - $ip1 = &General::getnetworkip($ip1,&General::iporsubtocidr($cidr1)); + $ip1 = &Network::get_netaddress("$ip1/$cidr1"); my ($ip2,$cidr2) = split (/\//, $ccdroutehash{$key}[$oldiroute]); - if (&General::IpInSubnet ($ip1,$ip2,$cidr2)){ + if (&Network::ip_address_in_network($ip1, "$ip2/$cidr2")){ $errormessage=$errormessage._('This route is already in use.'); goto VPNCONF_ERROR; } } } - if (!&General::validipandmask($val)){ + if (!&Network::check_subnet($val)){ $errormessage=$errormessage."Route "._('Invalid.')." ($val)"; goto VPNCONF_ERROR; }else{ ($ip,$cidr) = split(/\//,$val); - $ip=&General::getnetworkip($ip,&General::iporsubtocidr($cidr)); - $cidr=&General::iporsubtodec($cidr); + $ip=&Network::get_netaddress("$ip/$cidr"); + $cidr=&Network::get_netmask($val); $ccdroutehash{$keypoint}[$i] = $ip."/".$cidr; } #check for existing network IP's - if (&General::IpInSubnet ($ip,$Network::ethernet{GREEN_NETADDRESS},$Network::ethernet{GREEN_NETMASK}) && $Network::ethernet{GREEN_NETADDRESS} ne '0.0.0.0') + if (&Network::ip_address_in_network($ip, "$Network::ethernet{GREEN_NETADDRESS}/$Network::ethernet{GREEN_NETMASK}") && $Network::ethernet{GREEN_NETADDRESS} ne '0.0.0.0') { $errormessage=_('This is the GREEN subnet.'); goto VPNCONF_ERROR; - }elsif(&General::IpInSubnet ($ip,$Network::ethernet{RED_NETADDRESS},$Network::ethernet{RED_NETMASK}) && $Network::ethernet{RED_NETADDRESS} ne '0.0.0.0') + }elsif(&Network::ip_address_in_network($ip, "$Network::ethernet{RED_NETADDRESS}/$Network::ethernet{RED_NETMASK}") && $Network::ethernet{RED_NETADDRESS} ne '0.0.0.0') { $errormessage=_('This is the RED subnet.'); goto VPNCONF_ERROR; - }elsif(&General::IpInSubnet ($ip,$Network::ethernet{BLUE_NETADDRESS},$Network::ethernet{BLUE_NETMASK}) && $Network::ethernet{BLUE_NETADDRESS} ne '0.0.0.0' && $Network::ethernet{BLUE_NETADDRESS} gt '') + }elsif(&Network::ip_address_in_network($ip, "$Network::ethernet{BLUE_NETADDRESS}/$Network::ethernet{BLUE_NETMASK}") && $Network::ethernet{BLUE_NETADDRESS} ne '0.0.0.0' && $Network::ethernet{BLUE_NETADDRESS} gt '') { $errormessage=_('This is the BLUE subnet.'); goto VPNCONF_ERROR; - }elsif(&General::IpInSubnet ($ip,$Network::ethernet{ORANGE_NETADDRESS},$Network::ethernet{ORANGE_NETMASK}) && $Network::ethernet{ORANGE_NETADDRESS} ne '0.0.0.0' && $Network::ethernet{ORANGE_NETADDRESS} gt '' ) + }elsif(&Network::ip_address_in_network($ip, "$Network::ethernet{ORANGE_NETADDRESS}/$Network::ethernet{ORANGE_NETMASK}") && $Network::ethernet{ORANGE_NETADDRESS} ne '0.0.0.0' && $Network::ethernet{ORANGE_NETADDRESS} gt '' ) { $errormessage=_('This is the ORANGE subnet.'); goto VPNCONF_ERROR; } - if (&General::validipandmask($val)){ + if (&Network::check_subnet($val)){ $ccdroutehash{$keypoint}[$i] = $ip."/".$cidr; }else{ $errormessage=$errormessage."Route "._('Invalid.')." ($ip/$cidr)"; @@ -3862,8 +3857,8 @@ if ($cgiparams{'TYPE'} eq 'host') { if (! &check_routes_push($val)){$errormessage=$errormessage."Route $val "._('Already pushed from OpenVPN server.')." ($val)";goto VPNCONF_ERROR;} if (! &check_ccdroute($val)){$errormessage=$errormessage."
Route $val "._('Already used by another client.')." ($val)" ;goto VPNCONF_ERROR;} if (! &check_ccdconf($val)){$errormessage=$errormessage."
Route $val "._('Already used by OpenVPN server.')." ($val)";goto VPNCONF_ERROR;} - if (&General::validipandmask($val)){ - $val=$ip."/".&General::iporsubtodec($cidr); + if (&Network::check_subnet($val)){ + $val=$ip."/".&Network::get_netmask("$ip/$cidr"); $ccdroute2hash{$keypoint}[$i] = $val; }else{ $errormessage=$errormessage."Route "._('Invalid.')." ($val)"; @@ -3877,17 +3872,17 @@ if ($cgiparams{'TYPE'} eq 'host') { &General::writehasharray("${General::swroot}/ovpn/ccdroute2", \%ccdroute2hash); #check dns1 ip - if ($cgiparams{'CCD_DNS1'} ne '' && ! &General::validip($cgiparams{'CCD_DNS1'})) { + if ($cgiparams{'CCD_DNS1'} ne '' && ! &Network::check_ip_address($cgiparams{'CCD_DNS1'})) { $errormessage=$errormessage."
"._('Invalid Input for DHCP DNS')." 1"; goto VPNCONF_ERROR; } #check dns2 ip - if ($cgiparams{'CCD_DNS2'} ne '' && ! &General::validip($cgiparams{'CCD_DNS2'})) { + if ($cgiparams{'CCD_DNS2'} ne '' && ! &Network::check_ip_address($cgiparams{'CCD_DNS2'})) { $errormessage=$errormessage."
"._('Invalid Input for DHCP DNS')." 2"; goto VPNCONF_ERROR; } #check wins ip - if ($cgiparams{'CCD_WINS'} ne '' && ! &General::validip($cgiparams{'CCD_WINS'})) { + if ($cgiparams{'CCD_WINS'} ne '' && ! &Network::check_ip_address($cgiparams{'CCD_WINS'})) { $errormessage=$errormessage."
"._('Invalid Input for DHCP WINS'); goto VPNCONF_ERROR; } @@ -3955,7 +3950,7 @@ if ($cgiparams{'TYPE'} eq 'net') { } # Check if the input for the transfer net is valid. - if (!&General::validipandmask($cgiparams{'OVPN_SUBNET'})){ + if (!&Network::check_subnet($cgiparams{'OVPN_SUBNET'})){ $errormessage = _('Invalid IP address. Format: 192.168.0.0/24 or 192.168.0.0/255.255.255.0.'); unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!"; rmdir ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}") || die "Removing Directory fail: $!"; @@ -4058,9 +4053,9 @@ if ($cgiparams{'TYPE'} eq 'net') { # Check if a remote host/IP has been configured - the field can be empty on the server side. if ($cgiparams{'REMOTE'} ne '') { # Check if the given IP is valid - otherwise check if it is a valid domain. - if (! &General::validip($cgiparams{'REMOTE'})) { + if (! &Network::check_ip_address($cgiparams{'REMOTE'})) { # Check for a valid domain. - if (! &General::validfqdn ($cgiparams{'REMOTE'})) { + if (! &Network::check_fqdn ($cgiparams{'REMOTE'})) { $errormessage = _('Invalid input for remote host/ip.'); # Check if this is a N2N connection and drop temporary config. @@ -4074,7 +4069,7 @@ if ($cgiparams{'TYPE'} eq 'net') { } if ($cgiparams{'TYPE'} ne 'host') { - unless (&General::validipandmask($cgiparams{'LOCAL_SUBNET'})) { + unless (&Network::check_subnet($cgiparams{'LOCAL_SUBNET'})) { $errormessage = _('Local subnet is invalid.'); if ($cgiparams{'TYPE'} eq 'net') { unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!"; @@ -4093,7 +4088,7 @@ if ($cgiparams{'TYPE'} eq 'net') { } } } - if (($cgiparams{'TYPE'} eq 'net') && (! &General::validipandmask($cgiparams{'REMOTE_SUBNET'}))) { + if (($cgiparams{'TYPE'} eq 'net') && (! &Network::check_subnet($cgiparams{'REMOTE_SUBNET'}))) { $errormessage = _('Remote subnet is invalid.'); unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!"; rmdir ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}") || die "Removing Directory fail: $!"; @@ -5020,11 +5015,11 @@ END @temp=split(/\,/,$line); $temp[1] = '' unless defined $temp[1]; # not always populated my ($a,$b) = split(/\//,$temp[1]); - $temp[1] = $a."/".&General::iporsubtocidr($b); + $temp[1] = $a."/".&Network::get_prefix("$a/$b"); foreach my $key (keys %ccdroute2hash) { if($ccdroute2hash{$key}[0] eq $cgiparams{'NAME'}){ foreach my $i (1 .. $#{$ccdroute2hash{$key}}) { - if($ccdroute2hash{$key}[$i] eq $a."/".&General::iporsubtodec($b)){ + if($ccdroute2hash{$key}[$i] eq $a."/".&Network::get_netmask("$a/$b")){ $set=1; } } @@ -5066,24 +5061,24 @@ END if($ccdroute2hash{$key}[0] eq $cgiparams{'NAME'}){ $other=1; foreach my $i (1 .. $#{$ccdroute2hash{$key}}) { - if ($ccdroute2hash{$key}[$i] eq $Network::ethernet{'GREEN_NETADDRESS'}."/".&General::iporsubtodec($Network::ethernet{'GREEN_NETMASK'})){ + if ($ccdroute2hash{$key}[$i] eq "$Network::ethernet{'GREEN_NETADDRESS'}/$Network::ethernet{'GREEN_NETMASK'}"){ $selgreen=1; } - if (&Header::blue_used()){ - if( $ccdroute2hash{$key}[$i] eq $Network::ethernet{'BLUE_NETADDRESS'}."/".&General::iporsubtodec($Network::ethernet{'BLUE_NETMASK'})) { + if (&Network::is_zone_available("blue")){ + if( $ccdroute2hash{$key}[$i] eq "$Network::ethernet{'BLUE_NETADDRESS'}/$Network::ethernet{'BLUE_NETMASK'}") { $selblue=1; } } - if (&Header::orange_used()){ - if( $ccdroute2hash{$key}[$i] eq $Network::ethernet{'ORANGE_NETADDRESS'}."/".&General::iporsubtodec($Network::ethernet{'ORANGE_NETMASK'}) ) { + if (&Network::is_zone_available("orange")){ + if( $ccdroute2hash{$key}[$i] eq "$Network::ethernet{'ORANGE_NETADDRESS'}/$Network::ethernet{'ORANGE_NETMASK'}" ) { $selorange=1; } } } } } - if (&Header::blue_used() && $selblue == '1'){ print"";$selblue=0;}elsif(&Header::blue_used() && $selblue == '0'){print"";} - if (&Header::orange_used() && $selorange == '1'){ print"";$selorange=0;}elsif(&Header::orange_used() && $selorange == '0'){print"";} + if (&Network::is_zone_available("blue") && $selblue == '1'){ print"";$selblue=0;}elsif(&Network::is_zone_available("blue") && $selblue == '0'){print"";} + if (&Network::is_zone_available("orange") && $selorange == '1'){ print"";$selorange=0;}elsif(&Network::is_zone_available("orange") && $selorange == '0'){print"";} if ($selgreen == '1' || $other == '0'){ print"";$set=0;}else{print"";}; print</dev/null | sed -n '/pakfire:/{p;/Pakfire.*started/q}'`; + my @messages = (); + + my $log = File::ReadBackwards->new("/var/log/messages"); + if ($log) { + while (defined(my $line = $log->readline())) { + next unless ($line =~ /pakfire:/); + + push(@messages, $line); + + last if ($line =~ /Pakfire.*started/); + } + + $log->close(); + } # Test if the log contains an error message (fastest implementation, stops at first match) my $failure = any{ index($_, 'ERROR') != -1 } @messages; @@ -99,7 +113,7 @@ if($cgiparams{'ACTION'} eq 'json-getstatus') { print qq{\t"$key": "$value",\n}; } - # Print sanitized messages in reverse order to undo previous "tac" + # Print sanitized messages in reverse order as the log has been read backwards print qq{\t"messages": [\n}; for my $index (reverse (0 .. $#messages)) { my $line = $messages[$index]; @@ -860,11 +874,7 @@ sub _is_pakfire_busy { } # Check if a PID of a running pakfire instance is found - # (The system backpipe command is safe, because no user input is computed.) - my $pakfire_pid = `pidof -s /usr/local/bin/pakfire`; - chomp($pakfire_pid); - - if($pakfire_pid) { + if(&General::find_pids("pakfire")) { return 1; } diff --git a/html/cgi-bin/pppsetup.cgi b/html/cgi-bin/pppsetup.cgi index b2102e099..cb573ec5b 100644 --- a/html/cgi-bin/pppsetup.cgi +++ b/html/cgi-bin/pppsetup.cgi @@ -20,6 +20,7 @@ ############################################################################### use strict; +use POSIX (); # enable only the following on debugging purpose #use warnings; @@ -39,8 +40,7 @@ my @profilenames=(); my $errormessage = ''; my $maxprofiles = 5; -# This call is safe, because no user input will be processed. -my $kernel=`/bin/uname -r | /usr/bin/tr -d '\012'`; +my $kernel=(POSIX::uname())[2]; my %color = (); my %mainsettings = (); @@ -92,7 +92,7 @@ elsif ($pppsettings{'ACTION'} eq _('Save')) if ($pppsettings{'APN'} eq "") { $errormessage = _('Access Point Name is required'); goto ERROR; - } elsif (!&General::validdomainname($pppsettings{'APN'})) { + } elsif (!&Network::check_domainname($pppsettings{'APN'})) { $errormessage = _('Access Point Name is invalid'); goto ERROR; } @@ -163,21 +163,21 @@ elsif ($pppsettings{'ACTION'} eq _('Save')) if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'DHCP')) { if ($pppsettings{'DHCP_HOSTNAME'} ne '') { - if (! &General::validfqdn($pppsettings{'DHCP_HOSTNAME'})) { + if (! &Network::check_fqdn($pppsettings{'DHCP_HOSTNAME'})) { $errormessage = $errormessage.' '._('Hostname:').' '._('Invalid hostname.'); } } } if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'STATIC')) { $errormessage = ''; - if (! &General::validip($pppsettings{'IP'})) { + if (! &Network::check_ip_address($pppsettings{'IP'})) { $errormessage = _('Static IP').' '._('Invalid IP Address'); } - if (! &General::validip($pppsettings{'GATEWAY'})) { + if (! &Network::check_ip_address($pppsettings{'GATEWAY'})) { $errormessage = $errormessage.' '._('Gateway IP').' '._('Invalid IP Address'); } - if (! &General::validmask($pppsettings{'NETMASK'})) { + if (! (&Network::check_netmask($pppsettings{'NETMASK'}) || &Network::check_prefix($pppsettings{'NETMASK'}))) { $errormessage = $errormessage.' '._('Netmask').' '._('Invalid Netmask'); } if ($pppsettings{'BROADCAST'} ne '') { - if (! &General::validip($pppsettings{'BROADCAST'})) { + if (! &Network::check_ip_address($pppsettings{'BROADCAST'})) { $errormessage = $errormessage.' '._('Broadcast').' '._('Invalid Broadcast IP'); } } if ($errormessage ne '') {goto ERROR; } diff --git a/html/cgi-bin/proxy.cgi b/html/cgi-bin/proxy.cgi index 74600ee00..7186b140e 100644 --- a/html/cgi-bin/proxy.cgi +++ b/html/cgi-bin/proxy.cgi @@ -172,7 +172,7 @@ if (&Header::green_used() && $netsettings{'GREEN_DEV'}) { } my $blue_cidr = ""; -if (&Header::blue_used() && $netsettings{'BLUE_DEV'}) { +if (&Network::is_zone_available("blue") && $netsettings{'BLUE_DEV'}) { $blue_cidr = &Network::normalize_network("$netsettings{'BLUE_NETADDRESS'}\/$netsettings{'BLUE_NETMASK'}"); } @@ -342,12 +342,12 @@ if (($proxysettings{'ACTION'} eq _('Save')) || ($proxysettings{'ACTION'} eq _('S goto ERROR; } - if (!(&General::validport($proxysettings{'PROXY_PORT'}))) + if (!(&Network::check_port($proxysettings{'PROXY_PORT'}))) { $errormessage = _('Invalid Proxy Port'); goto ERROR; } - if (!(&General::validport($proxysettings{'TRANSPARENT_PORT'}))) + if (!(&Network::check_port($proxysettings{'TRANSPARENT_PORT'}))) { $errormessage = _('Invalid Proxy Port'); goto ERROR; @@ -359,9 +359,9 @@ if (($proxysettings{'ACTION'} eq _('Save')) || ($proxysettings{'ACTION'} eq _('S if (!($proxysettings{'UPSTREAM_PROXY'} eq '')) { my @temp = split(/:/,$proxysettings{'UPSTREAM_PROXY'}); - if (!(&General::validip($temp[0]))) + if (!(&Network::check_ip_address($temp[0]))) { - if (!(&General::validdomainname($temp[0]))) + if (!(&Network::check_domainname($temp[0]))) { $errormessage = _('Invalid Upstream Proxy IP/Hostname'); goto ERROR; @@ -506,15 +506,15 @@ if (($proxysettings{'ACTION'} eq _('Save')) || ($proxysettings{'ACTION'} eq _('S $errormessage = _('LDAP Base DN Required'); goto ERROR; } - if (!&General::validip($proxysettings{'LDAP_SERVER'})) + if (!&Network::check_ip_address($proxysettings{'LDAP_SERVER'})) { - if (!&General::validdomainname($proxysettings{'LDAP_SERVER'})) + if (!&Network::check_domainname($proxysettings{'LDAP_SERVER'})) { $errormessage = _('Invalid IP Address/Hostname for LDAP Server'); goto ERROR; } } - if (!&General::validport($proxysettings{'LDAP_PORT'})) + if (!&Network::check_port($proxysettings{'LDAP_PORT'})) { $errormessage = _('Invalid LDAP Port Number'); goto ERROR; @@ -530,12 +530,12 @@ if (($proxysettings{'ACTION'} eq _('Save')) || ($proxysettings{'ACTION'} eq _('S } if ($proxysettings{'AUTH_METHOD'} eq 'radius') { - if (!&General::validip($proxysettings{'RADIUS_SERVER'})) + if (!&Network::check_ip_address($proxysettings{'RADIUS_SERVER'})) { $errormessage = _('Invalid IP Address for RADIUS Server'); goto ERROR; } - if (!&General::validport($proxysettings{'RADIUS_PORT'})) + if (!&Network::check_port($proxysettings{'RADIUS_PORT'})) { $errormessage = _('Invalid RADIUS Port Number'); goto ERROR; @@ -1198,7 +1198,7 @@ if (!$proxysettings{'SRC_SUBNETS'}) print "$green_cidr\n"; } - if (&Header::blue_used()) { + if (&Network::is_zone_available("blue")) { print "$blue_cidr\n"; } } else { print $proxysettings{'SRC_SUBNETS'}; } @@ -1822,7 +1822,7 @@ if (!$proxysettings{'IDENT_HOSTS'}) { print "$green_cidr\n"; } - if (&Header::blue_used()) { + if (&Network::is_zone_available("blue")) { print "$blue_cidr\n"; } } else { @@ -2456,7 +2456,7 @@ sub check_acls s/#.*//g; s/\s+//g; if (/.*-.*-.*/) { $errormessage = _('Invalid Destination Port'); } @templist = split(/-/); - foreach (@templist) { unless (&General::validport($_)) { $errormessage = _('Invalid Destination Port'); } } + foreach (@templist) { unless (&Network::check_port($_)) { $errormessage = _('Invalid Destination Port'); } } $proxysettings{'PORTS_SAFE'} .= $line."\n"; } } @@ -2472,7 +2472,7 @@ sub check_acls s/#.*//g; s/\s+//g; if (/.*-.*-.*/) { $errormessage = _('Invalid Destination Port'); } @templist = split(/-/); - foreach (@templist) { unless (&General::validport($_)) { $errormessage = _('Invalid Destination Port'); } } + foreach (@templist) { unless (&Network::check_port($_)) { $errormessage = _('Invalid Destination Port'); } } $proxysettings{'PORTS_SSL'} .= $line."\n"; } } @@ -2486,7 +2486,7 @@ sub check_acls if ($_) { if (/^\./) { $_ = '*'.$_; } - unless (&General::validwildcarddomainname($_)) { $errormessage = _('Invalid URL:') . " " . &Header::escape($_); } + unless (&Network::check_wildcard_domainname($_)) { $errormessage = _('Invalid URL:') . " " . &Header::escape($_); } $proxysettings{'DST_NOCACHE'} .= $_."\n"; } } @@ -2510,7 +2510,7 @@ sub check_acls s/^\s+//g; s/\s+$//g; if ($_) { - unless (&General::validipormask($_)) { $errormessage = _('Invalid IP Address or Network Mask'); } + unless ((&Network::check_ip_address($_) || &Network::check_subnet($_))) { $errormessage = _('Invalid IP Address or Network Mask'); } $proxysettings{'SRC_BANNED_IP'} .= $_."\n"; } } @@ -2522,7 +2522,7 @@ sub check_acls s/^\s+//g; s/\s+$//g; s/-/:/g; if ($_) { - unless (&General::validmac($_)) { $errormessage = _('Invalid MAC Address'); } + unless (&Network::valid_mac($_)) { $errormessage = _('Invalid MAC Address'); } $proxysettings{'SRC_BANNED_MAC'} .= $_."\n"; } } @@ -2534,7 +2534,7 @@ sub check_acls s/^\s+//g; s/\s+$//g; if ($_) { - unless (&General::validipormask($_)) { $errormessage = _('Invalid IP Address or Network Mask'); } + unless ((&Network::check_ip_address($_) || &Network::check_subnet($_))) { $errormessage = _('Invalid IP Address or Network Mask'); } $proxysettings{'SRC_UNRESTRICTED_IP'} .= $_."\n"; } } @@ -2546,7 +2546,7 @@ sub check_acls s/^\s+//g; s/\s+$//g; s/-/:/g; if ($_) { - unless (&General::validmac($_)) { $errormessage = _('Invalid MAC Address'); } + unless (&Network::valid_mac($_)) { $errormessage = _('Invalid MAC Address'); } $proxysettings{'SRC_UNRESTRICTED_MAC'} .= $_."\n"; } } @@ -2571,7 +2571,7 @@ sub check_acls s/^\s+//g; s/\s+$//g; if ($_) { - unless (&General::validipormask($_)) { $errormessage = _('WPAD: Invalid IP or subnet for excluded IP subnet'); } + unless ((&Network::check_ip_address($_) || &Network::check_subnet($_))) { $errormessage = _('WPAD: Invalid IP or subnet for excluded IP subnet'); } $proxysettings{'DST_NOPROXY_IP'} .= $_."\n"; } } @@ -2585,7 +2585,7 @@ sub check_acls if ($_) { if (/^\./) { $_ = '*'.$_; } - unless (&General::validwildcarddomainname($_)) { $errormessage = _('Invalid URL:') . " " . &Header::escape($_); } + unless (&Network::check_wildcard_domainname($_)) { $errormessage = _('Invalid URL:') . " " . &Header::escape($_); } $proxysettings{'DST_NOPROXY_URL'} .= $_."\n"; } } @@ -2669,7 +2669,7 @@ sub check_acls s/^\s+//g; s/\s+$//g; if ($_) { - unless (&General::validipormask($_)) { $errormessage = _('Invalid IP Address or Network Mask'); } + unless ((&Network::check_ip_address($_) || &Network::check_subnet($_))) { $errormessage = _('Invalid IP Address or Network Mask'); } $proxysettings{'IDENT_HOSTS'} .= $_."\n"; } } @@ -2681,7 +2681,7 @@ sub check_acls s/^\s+//g; s/\s+$//g; if ($_) { - unless (&General::validipormask($_)) { $errormessage = _('Invalid IP Address or Network Mask'); } + unless ((&Network::check_ip_address($_) || &Network::check_subnet($_))) { $errormessage = _('Invalid IP Address or Network Mask'); } $proxysettings{'CRE_SVHOSTS'} .= $_."\n"; } } @@ -2699,7 +2699,7 @@ sub write_acls print FILE "$green_cidr\n"; } - if (&Header::blue_used()) { + if (&Network::is_zone_available("blue")) { print FILE "$blue_cidr\n"; } } else { print FILE $proxysettings{'SRC_SUBNETS'}; } @@ -2760,7 +2760,7 @@ sub write_acls print FILE "$_\n"; close(FILE); } - elsif (&General::validipormask($_)) + elsif ((&Network::check_ip_address($_) || &Network::check_subnet($_))) { open(FILE, ">>$acl_dst_noauth_net"); flock(FILE, 2); @@ -2809,7 +2809,7 @@ sub write_acls print FILE "$_\n"; close(FILE); } - elsif (&General::validipormask($_)) + elsif ((&Network::check_ip_address($_) || &Network::check_subnet($_))) { open(FILE, ">>$acl_dst_nocache_net"); flock(FILE, 2); @@ -2918,11 +2918,11 @@ END print FILE " (isInNet(host, \"$netsettings{'GREEN_NETADDRESS'}\", \"$netsettings{'GREEN_NETMASK'}\")) ||\n"; } - if (&Header::blue_used() && $netsettings{'BLUE_DEV'}) { + if (&Network::is_zone_available("blue") && $netsettings{'BLUE_DEV'}) { print FILE " (isInNet(host, \"$netsettings{'BLUE_NETADDRESS'}\", \"$netsettings{'BLUE_NETMASK'}\")) ||\n"; } - if (&Header::orange_used() && $netsettings{'ORANGE_DEV'}) { + if (&Network::is_zone_available("orange") && $netsettings{'ORANGE_DEV'}) { print FILE " (isInNet(host, \"$netsettings{'ORANGE_NETADDRESS'}\", \"$netsettings{'ORANGE_NETMASK'}\")) ||\n"; } diff --git a/html/cgi-bin/qos.cgi b/html/cgi-bin/qos.cgi index 370a41b37..7973b4700 100644 --- a/html/cgi-bin/qos.cgi +++ b/html/cgi-bin/qos.cgi @@ -121,7 +121,7 @@ my %CAKE_PROFILES = ( &General::readhash("${General::swroot}/qos/settings", \%qossettings); &Header::getcgihash(\%qossettings); -$qossettings{'RED_DEV'} = &General::get_red_interface(); +$qossettings{'RED_DEV'} = &Network::get_red_interface(); my %color = (); my %mainsettings = (); @@ -211,13 +211,13 @@ elsif ($qossettings{'DOCLASS'} eq _('Delete')) if ($qossettings{'DOLEVEL7'} eq _('Save')) { if ( $qossettings{'QIP'} ne '' ) { - if ((!&General::validipandmask($qossettings{'QIP'})) && (!&General::validip($qossettings{'QIP'}))) { + if ((!&Network::check_subnet($qossettings{'QIP'})) && (!&Network::check_ip_address($qossettings{'QIP'}))) { $qossettings{'VALID'} = 'no'; $message = _('The source IP address is invalid.'); } } if ( $qossettings{'DIP'} ne '' ) { - if ((!&General::validipandmask($qossettings{'DIP'})) && (!&General::validip($qossettings{'DIP'}))) { + if ((!&Network::check_subnet($qossettings{'DIP'})) && (!&Network::check_ip_address($qossettings{'DIP'}))) { $qossettings{'VALID'} = 'no'; $message = _('The destination IP address is invalid.'); } @@ -286,13 +286,13 @@ END if ($qossettings{'DOPORT'} eq _('Save')) { if ( $qossettings{'QIP'} ne '' ) { - if ((!&General::validipandmask($qossettings{'QIP'})) && (!&General::validip($qossettings{'QIP'}))) { + if ((!&Network::check_subnet($qossettings{'QIP'})) && (!&Network::check_ip_address($qossettings{'QIP'}))) { $qossettings{'VALID'} = 'no'; $message = _('The source IP address is invalid.'); } } if ( $qossettings{'DIP'} ne '' ) { - if ((!&General::validipandmask($qossettings{'DIP'})) && (!&General::validip($qossettings{'DIP'}))) { + if ((!&Network::check_subnet($qossettings{'DIP'})) && (!&Network::check_ip_address($qossettings{'DIP'}))) { $qossettings{'VALID'} = 'no'; $message = _('The destination IP address is invalid.'); } diff --git a/html/cgi-bin/remote.cgi b/html/cgi-bin/remote.cgi index d702b8ecf..c67e147fa 100644 --- a/html/cgi-bin/remote.cgi +++ b/html/cgi-bin/remote.cgi @@ -91,7 +91,7 @@ if ( $remotesettings{'ACTION'} eq _('Stop SSH Daemon in 15 Minutes') || $remotes if ( $remotesettings{'ACTION'} eq _('Stop SSH Daemon in 15 Minutes') ) { $counter = 900;} elsif ( $remotesettings{'ACTION'} eq _('Stop SSH Daemon in 30 Minutes') ) { $counter = 1800;} - system("/usr/local/bin/sshctrl tempstart $counter >/dev/null"); + &General::system("/usr/local/bin/sshctrl", "tempstart", $counter); } else { system('/usr/local/bin/sshctrl') == 0 diff --git a/html/cgi-bin/routing.cgi b/html/cgi-bin/routing.cgi index 5f797d873..5bed4326c 100644 --- a/html/cgi-bin/routing.cgi +++ b/html/cgi-bin/routing.cgi @@ -119,13 +119,13 @@ if ($settings{'ACTION'} eq _('Enable or Disable')) { if ($settings{'ACTION'} eq _('Add')) { # Validate inputs - if (!&General::validipandmask($settings{'IP'})){ + if (!&Network::check_subnet($settings{'IP'})){ $errormessage = _('Invalid IP Address')." / "._('Invalid Netmask'); }else{ #set networkip if not already correctly defined my($ip,$cidr) = split(/\//,$settings{'IP'}); - $cidr = &General::iporsubtocidr($cidr); - my $netip=&General::getnetworkip($ip,$cidr); + $cidr = &Network::get_prefix($settings{'IP'}); + my $netip=&Network::get_netaddress("$ip/$cidr"); $settings{'IP'} = "$netip/$cidr"; } @@ -133,7 +133,7 @@ if ($settings{'ACTION'} eq _('Add')) { $errormessage = _('Invalid IP Address')." - 0.0.0.0"; } - if( !&General::validip($settings{'GATEWAY'}) ) { + if( !&Network::check_ip_address($settings{'GATEWAY'}) ) { $errormessage = _('Invalid IP Address'). " - "._('Gateway IP'); } @@ -142,7 +142,7 @@ if ($settings{'ACTION'} eq _('Add')) { #set networkip if not already correctly defined my($ip,$cidr) = split(/\//,$settings{'IP'}); - my $netip=&General::getnetworkip($ip,$cidr); + my $netip=&Network::get_netaddress("$ip/$cidr"); $settings{'IP'} = "$netip/$cidr"; #Check for already existing routing entry diff --git a/html/cgi-bin/samba.cgi b/html/cgi-bin/samba.cgi index ee96c79c0..268a0b9b1 100644 --- a/html/cgi-bin/samba.cgi +++ b/html/cgi-bin/samba.cgi @@ -672,35 +672,28 @@ END sub config { my $file = shift; -my @allarray = `grep -n '^\\[' $file`; -my @linesarray = (); -my @namearray = (); my %hash = (); -my $options = (); -my $EOF = qx(cat $file | wc -l); -foreach my $allarrayentry (@allarray) - { - my @allarrayline = split( /\:/, $allarrayentry ); - push(@linesarray,$allarrayline[0]);$allarrayline[1]=~s/\[//g;$allarrayline[1]=~s/\]//g;push(@namearray,$allarrayline[1]); - } - for(my $i = 0; $i <= $#namearray; $i++) +my $name; + +open(my $fh, "<", $file) or return %hash; +while (my $line = <$fh>) + { + # A new section starts here + if ( $line =~ /^\[/ ) { - chomp $namearray[$i]; - $namearray[$i]=~s/\[//g;$namearray[$i]=~s/\]//g; - if ( $i eq $#namearray ) - { - my $lineend = $EOF-$linesarray[$i]+1; - $options=qx(tail -$lineend $file); - } - else - { - my $linestart = $EOF-$linesarray[$i]+1; - my $lineend = $linesarray[$i+1]-$linesarray[$i]; - $options=qx(tail -$linestart $file | head -$lineend); - } - $hash{$namearray[$i]} = "$options"; - #print"
$namearray[$i]\n$options\n
"; # enable only for debuging + ($name) = split( /\:/, $line ); + chomp $name; + $name=~s/\[//g;$name=~s/\]//g; + $hash{$name} = ""; } + + # Skip anything before the first section + next unless ( defined $name ); + + $hash{$name} .= $line; + } +close($fh); + return(%hash); } diff --git a/html/cgi-bin/services.cgi b/html/cgi-bin/services.cgi index b03164841..a4aaa5e43 100644 --- a/html/cgi-bin/services.cgi +++ b/html/cgi-bin/services.cgi @@ -235,7 +235,7 @@ sub isrunningaddon (@) { my $memory = &General::get_memory_consumption(@pid); # Format memory - $memory = &General::formatBytes($memory); + $memory = &General::format_bytes($memory); $status .="$memory"; }else{ diff --git a/html/cgi-bin/time.cgi b/html/cgi-bin/time.cgi index 79dec10e1..316b3439c 100644 --- a/html/cgi-bin/time.cgi +++ b/html/cgi-bin/time.cgi @@ -52,8 +52,8 @@ if ($timesettings{'ACTION'} eq _('Save')) { if ($timesettings{'ENABLENTP'} eq 'on') { - if ( ! ( &General::validfqdn($timesettings{'NTP_ADDR_1'}) || - &General::validip ($timesettings{'NTP_ADDR_1'}))) + if ( ! ( &Network::check_fqdn($timesettings{'NTP_ADDR_1'}) || + &Network::check_ip_address ($timesettings{'NTP_ADDR_1'}))) { $errormessage = _('Invalid Primary NTP Server Address'); goto ERROR; @@ -61,8 +61,8 @@ if ($timesettings{'ACTION'} eq _('Save')) } if ($timesettings{'NTP_ADDR_2'}) { - if ( ! ( &General::validfqdn($timesettings{'NTP_ADDR_2'}) || - &General::validip ($timesettings{'NTP_ADDR_2'}))) + if ( ! ( &Network::check_fqdn($timesettings{'NTP_ADDR_2'}) || + &Network::check_ip_address ($timesettings{'NTP_ADDR_2'}))) { $errormessage = _('Invalid Secondary NTP Server Address'); goto ERROR; diff --git a/html/cgi-bin/tor.cgi b/html/cgi-bin/tor.cgi index dacdcc1c8..de20b709c 100644 --- a/html/cgi-bin/tor.cgi +++ b/html/cgi-bin/tor.cgi @@ -104,7 +104,7 @@ $settings{'TOR_USE_EXIT_NODES'} = ''; $settings{'TOR_GUARD_COUNTRY'} = ''; $settings{'TOR_USE_GUARD_NODES'} = ''; $settings{'TOR_ALLOWED_SUBNETS'} = "$netsettings{'GREEN_NETADDRESS'}\/$netsettings{'GREEN_NETMASK'}"; -if (&Header::blue_used()) { +if (&Network::is_zone_available("blue")) { $settings{'TOR_ALLOWED_SUBNETS'} .= ",$netsettings{'BLUE_NETADDRESS'}\/$netsettings{'BLUE_NETMASK'}"; } @@ -141,21 +141,21 @@ if ($settings{'ACTION'} eq _('Save')) { } } - if (!&General::validport($settings{'TOR_SOCKS_PORT'})) { + if (!&Network::check_port($settings{'TOR_SOCKS_PORT'})) { $errormessage = "@{[ _('Invalid SOCKS Port:') ]} $settings{'TOR_SOCKS_PORT'}"; } - if (!&General::validport($settings{'TOR_RELAY_PORT'})) { + if (!&Network::check_port($settings{'TOR_RELAY_PORT'})) { $errormessage = "@{[ _('Invalid Relay Port:') ]} $settings{'TOR_RELAY_PORT'}"; } if ($settings{'TOR_RELAY_DIRPORT'} ne '0') { - if (!&General::validport($settings{'TOR_RELAY_DIRPORT'})) { + if (!&Network::check_port($settings{'TOR_RELAY_DIRPORT'})) { $errormessage = "@{[ _('Invalid Directory Port:') ]} $settings{'TOR_RELAY_DIRPORT'}"; } } if ($settings{'TOR_RELAY_ADDRESS'} ne '') { - if ((!&General::validfqdn($settings{'TOR_RELAY_ADDRESS'})) && (!&General::validip($settings{'TOR_RELAY_ADDRESS'}))) { + if ((!&Network::check_fqdn($settings{'TOR_RELAY_ADDRESS'})) && (!&Network::check_ip_address($settings{'TOR_RELAY_ADDRESS'}))) { $errormessage = "@{[ _('Invalid Relay Address:') ]} $settings{'TOR_RELAY_ADDRESS'}"; } } @@ -169,7 +169,7 @@ if ($settings{'ACTION'} eq _('Save')) { foreach (@temp) { s/^\s+//g; s/\s+$//g; if ($_) { - unless (&General::validipandmask($_)) { + unless (&Network::check_subnet($_)) { $errormessage = "@{[ _('Invalid IP Subnet:') ]} $_"; } $settings{'TOR_ALLOWED_SUBNETS'} .= $_.","; @@ -599,7 +599,7 @@ END @{[ _('Total Traffic (read/written):') ]} END - print "" . &FormatBytes($traffic[0]) ."/". &FormatBytes($traffic[1]) . ""; + print "" . &General::format_bytes($traffic[0]) ."/". &General::format_bytes($traffic[1]) . ""; print < @@ -645,8 +645,8 @@ END END - print &FormatBytes($accounting->{'bytes_read'}) . "/" . &FormatBytes($accounting->{'bytes_written'}); - print " (" . &FormatBytes($accounting->{'bytes-left_read'}) . "/" . &FormatBytes($accounting->{'bytes-left_written'}); + print &General::format_bytes($accounting->{'bytes_read'}) . "/" . &General::format_bytes($accounting->{'bytes_written'}); + print " (" . &General::format_bytes($accounting->{'bytes-left_read'}) . "/" . &General::format_bytes($accounting->{'bytes-left_written'}); print " @{[ _('Left') ]})"; print <= 1024)) { - $units_index++; - $bytes /= 1024; - } - - return sprintf("%.2f %s", $bytes, $units[$units_index]); -} - sub FormatBitsPerSecond() { my $bits = shift; diff --git a/html/cgi-bin/traffic.cgi b/html/cgi-bin/traffic.cgi index bb5d783fe..9118ca292 100644 --- a/html/cgi-bin/traffic.cgi +++ b/html/cgi-bin/traffic.cgi @@ -57,7 +57,7 @@ display_vnstat($netsettings{'GREEN_DEV'}); # and dont display if RED_DEV=GREEN_DEV (green only mode) if ($netsettings{'RED_DEV'} ne $netsettings{'GREEN_DEV'}) { # Omit the red interface name. - my $red_iface = &General::get_red_interface(); + my $red_iface = &Network::get_red_interface(); # Display the red stats if a device could be grabbed. display_vnstat($red_iface) if ($red_iface); @@ -81,7 +81,9 @@ sub display_vnstat { my $device = $_[0]; - my $testdata = `/usr/bin/vnstat -i $device`; + open(my $vnstat, "-|", "/usr/bin/vnstat", "-i", $device); + my $testdata = join("", <$vnstat>); + close($vnstat); if ( $testdata =~ 'enough') { print"No data for $device !
"; diff --git a/html/cgi-bin/updatexlrator.cgi b/html/cgi-bin/updatexlrator.cgi index 90e30c399..d0a000a22 100644 --- a/html/cgi-bin/updatexlrator.cgi +++ b/html/cgi-bin/updatexlrator.cgi @@ -536,8 +536,7 @@ END else { print "\n"; } - $filesize = $size_updatefile; - 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/; + $filesize = &General::format_bytes($size_updatefile); my ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($mtime); $DAYdt = sprintf ("%.02d",$DAYdt); @@ -567,8 +566,7 @@ END $shortname = substr($updatefile,rindex($updatefile,"/")+1); $shortname =~ s/(.*)_[\da-f]*(\.(exe|cab|psf)$)/$1_*$2/i; - $filesize = $dlinfo{'REMOTESIZE'}; - 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/; + $filesize = &General::format_bytes($dlinfo{'REMOTESIZE'}); $dlinfo{'VENDORID'} = ucfirst $vendorid; print <) } } +# Reset as this has been used for the list of the pending downloads +$filesize = 0; + @vendors=(); foreach (@sources) { @@ -709,8 +710,8 @@ foreach (@sources) if ($numfiles) { $efficiency = sprintf("%.1f", $cachehits / $numfiles); } -1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/; -1 while $cachedtraffic =~ s/^(-?\d+)(\d{3})/$1.$2/; +$filesize = &General::format_bytes($filesize); +$cachedtraffic = &General::format_bytes($cachedtraffic); # ---------------------------------------------------- # Show statistics @@ -738,7 +739,7 @@ print <; close DF; shift(@dfdata); @@ -775,14 +776,14 @@ if ($numfiles) @{[ _('Total Files in Cache:') ]} $numfiles - @{[ _('Total Cache Size (bytes):') ]} + @{[ _('Total Cache Size:') ]} $filesize @{[ _('Cache Efficiency Index:') ]} $efficiency - @{[ _('Total Data Delivered From Cache (bytes):') ]} + @{[ _('Total Data Delivered From Cache:') ]} $cachedtraffic @@ -797,9 +798,9 @@ if ($numfiles)   @{[ _('Files') ]}   - @{[ _('Cache Size (bytes)') ]} + @{[ _('Cache Size') ]}   - @{[ _('Data From Cache (bytes)') ]} + @{[ _('Data From Cache') ]}     @@ -884,16 +885,14 @@ foreach (@vendors) printf "%5d", $vendorstats{$vendorid."_files"}; print " \n"; - unless ($vendorstats{$vendorid."_filesize"}) { $vendorstats{$vendorid."_filesize"} = '0'; } - 1 while $vendorstats{$vendorid."_filesize"} =~ s/^(-?\d+)(\d{3})/$1.$2/; - print ""; - printf "%15s", $vendorstats{$vendorid."_filesize"}; + print ""; + print &General::format_bytes($vendorstats{$vendorid."_filesize"} || 0); + print ""; print " \n"; - unless ($vendorstats{$vendorid."_cachehits"}) { $vendorstats{$vendorid."_cachehits"} = '0'; } - 1 while $vendorstats{$vendorid."_cachehits"} =~ s/^(-?\d+)(\d{3})/$1.$2/; - print ""; - printf "%15s", $vendorstats{$vendorid."_cachehits"}; + print ""; + print &General::format_bytes($vendorstats{$vendorid."_cachehits"} || 0); + print ""; print " \n"; print ""; @@ -1034,7 +1033,7 @@ print <; close DF; shift(@dfdata); @@ -1166,8 +1165,7 @@ END else { print "\n"; } - $filesize = $size_updatefile; - 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/; + $filesize = &General::format_bytes($size_updatefile); my ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($mtime); $DAYdt = sprintf ("%.02d",$DAYdt); @@ -1558,11 +1556,23 @@ sub getmtime sub getPID { my $pid=''; - my @psdata=`ps ax --no-heading`; - foreach (@psdata) + # Find all processes + opendir(PROC, "/proc") or return $pid; + my @pids = sort { $a <=> $b } grep { /^\d+$/ } readdir(PROC); + closedir(PROC); + + foreach my $p (@pids) { - if (/$_[0]/) { ($pid)=/^\s*(\d+)/; } + # Read the command line which has its arguments separated by NUL + open(CMDLINE, "/proc/$p/cmdline") or next; + my $cmdline = join('', ); + close(CMDLINE); + + $cmdline =~ s/\0+$//; + $cmdline =~ tr/\0/ /; + + if ("$p $cmdline" =~ /$_[0]/) { $pid = $p; } } return $pid; diff --git a/html/cgi-bin/urlfilter.cgi b/html/cgi-bin/urlfilter.cgi index af5e0e657..73ad85bfd 100644 --- a/html/cgi-bin/urlfilter.cgi +++ b/html/cgi-bin/urlfilter.cgi @@ -167,7 +167,7 @@ if (($filtersettings{'ACTION'} eq _('Save')) || s/^\s+//g; s/\s+$//g; s/\s+-\s+/-/g; s/\s+/ /g; s/\n//g; if (/.*-.*-.*/) { $errormessage = _('Invalid IP Address or Network Mask'); } @temp = split(/-/); - foreach (@temp) { unless ((&General::validipormask($_)) || (&General::validipandmask($_))) { $errormessage = _('Invalid IP Address or Network Mask'); } } + foreach (@temp) { unless (&Network::check_ip_address($_) || &Network::check_subnet($_)) { $errormessage = _('Invalid IP Address or Network Mask'); } } } @clients = split(/\n/,$filtersettings{'BANNED_CLIENTS'}); foreach (@clients) @@ -175,7 +175,7 @@ if (($filtersettings{'ACTION'} eq _('Save')) || s/^\s+//g; s/\s+$//g; s/\s+-\s+/-/g; s/\s+/ /g; s/\n//g; if (/.*-.*-.*/) { $errormessage = _('Invalid IP Address or Network Mask'); } @temp = split(/-/); - foreach (@temp) { unless ((&General::validipormask($_)) || (&General::validipandmask($_))) { $errormessage = _('Invalid IP Address or Network Mask'); } } + foreach (@temp) { unless (&Network::check_ip_address($_) || &Network::check_subnet($_)) { $errormessage = _('Invalid IP Address or Network Mask'); } } } if ($errormessage) { goto ERROR; } @@ -247,8 +247,7 @@ if (($filtersettings{'ACTION'} eq _('Save')) || { $errormessage = _('File is not a squidGuard compatible blacklist'); } else { - # XXX Uses globbing - system("cp -r ${General::swroot}/urlfilter/update/blacklists/* $dbdir"); + &General::system("cp", "-r", glob("${General::swroot}/urlfilter/update/blacklists/*"), $dbdir); &readblockcategories; &readcustomlists; @@ -316,8 +315,7 @@ if (($filtersettings{'ACTION'} eq _('Save')) || { $errormessage = _('File is not a valid URL filter backup file'); } else { - # XXX uses globbing - system("cp -rp ${General::swroot}/urlfilter/restore/* ${General::swroot}/urlfilter/"); + &General::system("cp", "-rp", glob("${General::swroot}/urlfilter/restore/*"), "${General::swroot}/urlfilter/"); &readblockcategories; &readcustomlists; &writeconfigfile; @@ -935,16 +933,18 @@ if (($besettings{'ACTION'} eq _('Install Blacklist')) && ($besettings{'MODE'} = print FILE "}\n"; close FILE; - # XXX uses globbing if(!($besettings{'BE_NAME'} =~ /^[a-zA-Z0-9-_]+$/)) { $errormessage = 'Invalid blacklist name (use only alphanumeric characters plus hyphens or underscores)'; goto ERROR; } - system("rm -f $dbdir/$besettings{'BE_NAME'}/*.db"); + unlink(glob("$dbdir/$besettings{'BE_NAME'}/*.db")); &General::system("/usr/bin/squidGuard", "-c", "$editdir/install.conf", "-C", "all"); - # XXX uses globbing - system("chmod a+w $dbdir/$besettings{'BE_NAME'}/*.db"); + foreach my $db (glob("$dbdir/$besettings{'BE_NAME'}/*.db")) + { + # Make the database writable for everybody + chmod((stat($db))[2] & 07777 | 0222, $db); + } &readblockcategories; &readcustomlists; @@ -1731,8 +1731,7 @@ END print "\n"; } else { print "\n"; } - $filesize = (-s "$repository/$line"); - 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/; + $filesize = &General::format_bytes(-s "$repository/$line"); print <   $line @@ -2718,14 +2717,13 @@ sub setpermissions foreach $category (<$bldir/*>) { if (-d $category){ - &General::system("chmod", "755", "$category"); + chmod(0755, $category); foreach $blacklist (<$category/*>) { - if (-f $blacklist) { &General::system("chmod", "644", "$blacklist"); } - if (-d $blacklist) { &General::system("chmod", "755", "$blacklist"); } + if (-f $blacklist) { chmod(0644, $blacklist); } + if (-d $blacklist) { chmod(0755, $blacklist); } } - # XXX uses globbing - system("chmod 666 $category/*.db &> /dev/null"); + chmod(0666, glob("$category/*.db")); &setpermissions ($category); } } @@ -2930,7 +2928,7 @@ sub writeconfigfile print FILE "src network-$idx {\n"; @clients = split(/ /,$tc[12]); @temp = split(/-/,$clients[0]); - if ( (&General::validipormask($temp[0])) || (&General::validipandmask($temp[0]))) + if (&Network::check_ip_address($temp[0]) || &Network::check_subnet($temp[0])) { print FILE " ip $tc[12]\n"; } else { diff --git a/html/cgi-bin/vpnmain.cgi b/html/cgi-bin/vpnmain.cgi index 51d9d9e36..9b3158e48 100644 --- a/html/cgi-bin/vpnmain.cgi +++ b/html/cgi-bin/vpnmain.cgi @@ -74,7 +74,7 @@ my %INACTIVITY_TIMEOUTS = ( # Load aliases my %aliases; -&General::get_aliases(\%aliases); +&Network::get_aliases(\%aliases); my $col=""; @@ -547,12 +547,12 @@ if ($ENV{"REMOTE_ADDR"} eq "") { if ($cgiparams{'ACTION'} eq _('Save') && $cgiparams{'TYPE'} eq '' && $cgiparams{'KEY'} eq '') { &General::readhash("${General::swroot}/vpn/settings", \%vpnsettings); - if ($cgiparams{'RW_ENDPOINT'} ne '' && !&General::validip($cgiparams{'RW_ENDPOINT'}) && !&General::validfqdn($cgiparams{'RW_ENDPOINT'})) { + if ($cgiparams{'RW_ENDPOINT'} ne '' && !&Network::check_ip_address($cgiparams{'RW_ENDPOINT'}) && !&Network::check_fqdn($cgiparams{'RW_ENDPOINT'})) { $errormessage = _('Invalid IP address or FQDN for Host-to-Net Endpoint'); goto SAVE_ERROR; } - if ( $cgiparams{'RW_NET'} ne '' and !&General::validipandmask($cgiparams{'RW_NET'}) ) { + if ( $cgiparams{'RW_NET'} ne '' and !&Network::check_subnet($cgiparams{'RW_NET'}) ) { $errormessage = _('Invalid IP Address or Network Mask'); goto SAVE_ERROR; } @@ -1002,7 +1002,7 @@ END $errormessage = _('Hostname cannot be empty.'); goto ROOTCERT_ERROR; } - unless (&General::validfqdn($cgiparams{'ROOTCERT_HOSTNAME'}) || &General::validip($cgiparams{'ROOTCERT_HOSTNAME'})) { + unless (&Network::check_fqdn($cgiparams{'ROOTCERT_HOSTNAME'}) || &Network::check_ip_address($cgiparams{'ROOTCERT_HOSTNAME'})) { $errormessage = _('Invalid input for hostname.'); goto ROOTCERT_ERROR; } @@ -1761,15 +1761,15 @@ END } if ($cgiparams{'LOCAL'}) { - if (($cgiparams{'LOCAL'} ne "") && (!&General::validip($cgiparams{'LOCAL'}))) { + if (($cgiparams{'LOCAL'} ne "") && (!&Network::check_ip_address($cgiparams{'LOCAL'}))) { $errormessage = _('Invalid Input for Local IP Address'); goto VPNCONF_ERROR; } } if ($cgiparams{'REMOTE'}) { - if (($cgiparams{'REMOTE'} ne '%any') && (! &General::validip($cgiparams{'REMOTE'}))) { - if (! &General::validfqdn ($cgiparams{'REMOTE'})) { + if (($cgiparams{'REMOTE'} ne '%any') && (! &Network::check_ip_address($cgiparams{'REMOTE'}))) { + if (! &Network::check_fqdn ($cgiparams{'REMOTE'})) { $errormessage = _('Invalid input for remote host/ip.'); goto VPNCONF_ERROR; } else { diff --git a/html/cgi-bin/wakeonlan.cgi b/html/cgi-bin/wakeonlan.cgi index 03342357c..f0613c23d 100644 --- a/html/cgi-bin/wakeonlan.cgi +++ b/html/cgi-bin/wakeonlan.cgi @@ -84,7 +84,7 @@ if ( $cgiparams{'ACTION'} eq 'add' ) $cgiparams{'CLIENT_MAC'} =~ tr/-/:/; - unless( &General::validmac($cgiparams{'CLIENT_MAC'}) ) + unless( &Network::valid_mac($cgiparams{'CLIENT_MAC'}) ) { $errormessage = _('Invalid MAC Address'); goto ADDEXIT; @@ -120,7 +120,7 @@ if ( $cgiparams{'ACTION'} eq 'update' ) $cgiparams{'CLIENT_MAC'} =~ tr/-/:/; - unless( &General::validmac($cgiparams{'CLIENT_MAC'}) ) + unless( &Network::valid_mac($cgiparams{'CLIENT_MAC'}) ) { $errormessage = _('Invalid MAC Address'); goto UPDATEEXIT; @@ -406,7 +406,7 @@ sub ReadConfig chomp($line); # remove newline my @temp = split(/\,/,$line,5); if ( $temp[1] eq '' ) { next; } - unless(&General::validmac($temp[1])) { next; } + unless(&Network::valid_mac($temp[1])) { next; } push @wol_devices, { ID => $temp[0], MAC => $temp[1], IFace => $temp[2], Comment => $temp[4] }; } @@ -424,7 +424,7 @@ sub WriteConfig for $i ( 0 .. $#wol_devices ) { - unless(&General::validmac($wol_devices[$i]{'MAC'})) { next; } + unless(&Network::valid_mac($wol_devices[$i]{'MAC'})) { next; } unshift (@tmp_clients, uc($wol_devices[$i]{'MAC'}).",$wol_devices[$i]{'IFace'},,$wol_devices[$i]{'Comment'}"); } diff --git a/html/cgi-bin/wio.cgi b/html/cgi-bin/wio.cgi index 9089ad317..b368e26be 100755 --- a/html/cgi-bin/wio.cgi +++ b/html/cgi-bin/wio.cgi @@ -82,7 +82,7 @@ my $dhcpfile = "/var/ipfire/dhcp/fixleases"; my $imgstatic = "/images/wio"; my $rrddir = "/var/log/rrd/wio"; my $refreshbox = ''; -my $sortstring = '^IPADR|^HOST'; +my $sortstring = '^(IPADR|HOST)\z'; my $ovpnaddon = "/var/ipfire/ovpn"; my $ovpnpid = "/var/run/openvpn-rw.pid"; my $vpnpid = "/var/run/charon.pid"; @@ -186,7 +186,7 @@ foreach (@devs_color) { ## save wio settings if ( $wiosettings{'ACTION'} eq _('Save').'1' ) { - unless ( `ps -A | grep wio.pl` ) { + unless ( &General::find_pids("wio.pl") ) { $cgiparams{'SORT'} = $wiosettings{'SORT'}; $cgiparams{'CRON'} = $wiosettings{'CRON'}; $cgiparams{'OVPNCRON'} = $wiosettings{'OVPNCRON'}; @@ -215,7 +215,7 @@ if ( $wiosettings{'ACTION'} eq _('Save').'1' ) { ## save imported clients if ( $wiosettings{'ACTION'} eq _('Save').'2' ) { - unless ( `ps -A | grep wio.pl` ) { + unless ( &General::find_pids("wio.pl") ) { while ( $count < $wiosettings{'COUNT'} ) { if ( defined($wiosettings{"USE$count"}) && $wiosettings{"USE$count"} eq 'on' ) { $wiosettings{'CLIENTID'} = $wiosettings{"CLIENTID$count"}; @@ -260,7 +260,7 @@ if ( $wiosettings{'ACTION'} eq _('Save').'2' ) { ## add or update client if ( $wiosettings{'ACTION'} eq _('Use Settings') ) { - unless ( `ps -A | grep wio.pl` ) { + unless ( &General::find_pids("wio.pl") ) { &validSave(); unless ($errormessage) { @@ -285,7 +285,7 @@ if ( $wiosettings{'ACTION'} eq _('Use Settings') ) { ## show / hide arptable if ( $wiosettings{'WIOGUISHOWARPTABLE'} eq 'arptable' ) { - unless ( `ps -A | grep wio.pl` ) { + unless ( &General::find_pids("wio.pl") ) { if ( $wiosettings{'ACTION'} eq _('Hide Table') ) { $wiosettings{'WIOGUISHOWARPTABLE'} = 'off'; $arpbuttontext = _('Show Table'); @@ -303,7 +303,7 @@ if ( $wiosettings{'WIOGUISHOWARPTABLE'} eq 'arptable' ) { ## show / hide clientimporttable if ( $wiosettings{'WIOGUISHOWCLIENTIMPORTTABLE'} eq 'clientimport' ) { - unless ( `ps -A | grep wio.pl` ) { + unless ( &General::find_pids("wio.pl") ) { if ( $wiosettings{'ACTION'} eq _('Hide Table') ) { $wiosettings{'WIOGUISHOWCLIENTIMPORTTABLE'} = 'off'; $clientimportbuttontext = _('Show Table'); @@ -321,7 +321,7 @@ if ( $wiosettings{'WIOGUISHOWCLIENTIMPORTTABLE'} eq 'clientimport' ) { ## show / hide networksearchtable if ( $wiosettings{'WIOGUISHOWNETWORKSEARCHTABLE'} eq 'networksearch' ) { - unless ( `ps -A | grep wio.pl` ) { + unless ( &General::find_pids("wio.pl") ) { if ( $wiosettings{'ACTION'} eq _('Hide Table') ) { $wiosettings{'WIOGUISHOWNETWORKSEARCHTABLE'} = 'off'; $networksearchbuttontext = _('Show Table'); @@ -339,7 +339,7 @@ if ( $wiosettings{'WIOGUISHOWNETWORKSEARCHTABLE'} eq 'networksearch' ) { ## add arp client if ( $wiosettings{'ACTION'} eq _('Add Client:') ) { - unless ( `ps -A | grep wio.pl` ) { + unless ( &General::find_pids("wio.pl") ) { open(FILE, "$logdir/.arpcache"); @arpadd = ; close (FILE); @@ -376,7 +376,7 @@ if ( $wiosettings{'ACTION'} eq _('Enable or Disable Offline Email') ) { $wmoff = if (( $wiosettings{'ACTION'} eq _('Send Ping to IP Enabled (click to enable FQDN)') ) || ( $wiosettings{'ACTION'} eq _('Send Ping to FQDN Enabled (click to enable IP)') )) { $ipfqdn = 'on'; } if ( defined($edc) || defined($edd) || defined($wmon) || defined($wmoff) || defined($ipfqdn) ) { - unless ( `ps -A | grep wio.pl` ) { + unless ( &General::find_pids("wio.pl") ) { chomp(@current[$wiosettings{'ID'}]); @temp = split (/\,/, @current[$wiosettings{'ID'}]); @@ -407,7 +407,7 @@ if ( defined($edc) || defined($edd) || defined($wmon) || defined($wmoff) || defi if ( $wiosettings{'ACTION'} eq _('Update All Clients Now') || $wiosettings{'ACTION'} eq _('Update Client Now') ) { -unless ( `ps -A | grep wio.pl` ) { +unless ( &General::find_pids("wio.pl") ) { if ( $wiosettings{'ACTION'} eq _('Update Client Now') ) { open(FILE, "> $onoffip"); @@ -448,7 +448,7 @@ else { ## refresh dyndns ip if ( $wiosettings{'ACTION'} eq _('DynDNS Host IP Update') ) { - unless ( `ps -A | grep wio.pl` ) { + unless ( &General::find_pids("wio.pl") ) { chomp(@current[$wiosettings{'ID'}]); @temp = split (/\,/, @current[$wiosettings{'ID'}]); @@ -468,7 +468,7 @@ if ( $wiosettings{'ACTION'} eq _('DynDNS Host IP Update') ) { ## edit client if ( $wiosettings{'ACTION'} eq _('Edit') ) { - unless ( `ps -A | grep wio.pl` ) { + unless ( &General::find_pids("wio.pl") ) { chomp(@current[$wiosettings{'ID'}]); @temp = split (/\,/, @current[$wiosettings{'ID'}]); @@ -494,7 +494,7 @@ if ( $wiosettings{'ACTION'} eq _('Edit') ) { ## remove client if ( $wiosettings{'ACTION'} eq _('Remove Client') ) { - unless ( `ps -A | grep wio.pl` ) { + unless ( &General::find_pids("wio.pl") ) { chomp(@current[$wiosettings{'ID'}]); @temp = split (/\,/, @current[$wiosettings{'ID'}]); @@ -516,7 +516,7 @@ if ( $wiosettings{'ACTION'} eq _('Remove Client') ) { ## remove all clients if ( $wiosettings{'ACTION'} eq _('Remove All Clients') ) { - unless ( `ps -A | grep wio.pl` ) { + unless ( &General::find_pids("wio.pl") ) { &WIO::clearfile($ipadrfile); unlink glob "$rrddir/*"; undef(@current); @@ -546,7 +546,7 @@ if ( $wiosettings{'ACTION'} eq _('Importing').'1' || $wiosettings{'ACTION'} eq _('Importing').'3' || defined($wioscan) || defined($importmessage) ) { -unless ( `ps -A | grep wio.pl` ) { +unless ( &General::find_pids("wio.pl") ) { if ( $wiosettings{'ACTION'} eq _('Importing').'1' && $importmessage eq '' ) { &Header::getcgihash(\%wiosettings, {'wantfile' => 1, 'filevar' => 'CSVFILE'}); @@ -617,7 +617,7 @@ elsif ( $wioscan eq 'on' ) { &Header::closebox(); &Header::closebigbox(); - open(FILE, "/usr/local/bin/wioscan -wsa $dev $iprange |" ); + open(FILE, "-|", "/usr/local/bin/wioscan", "-wsa", $dev, $iprange); } @@ -848,7 +848,11 @@ if ($ENV{'QUERY_STRING'} =~ /$sortstring/ ) { $string.=$Rev; } - system("/bin/sed -i 's#$wiosettings{'SORT'}#$string#g' $wiosettings"); + # Only change how the clients are being sorted + my %savedsettings = (); + &General::readhash($wiosettings, \%savedsettings); + $savedsettings{'SORT'} = $string; + &General::writehash($wiosettings, \%savedsettings); $wiosettings{'SORT'} = $string; map ($wiosettings{$_} = '' ,@nosaved); @@ -1164,7 +1168,7 @@ close (FILE); @temp = split (/\,/, $_); if ( $temp[7] eq "on" ) { - $bgcolor = ( &General::DyndnsServiceSync (&HTTPClient::GetDyndnsRedIP,$temp[1],$temp[2]) ? "$Header::colourgreen" : "$Header::colourred" ); + $bgcolor = ( &HTTPClient::DyndnsServiceSync (&HTTPClient::GetDyndnsRedIP,$temp[1],$temp[2]) ? "$Header::colourgreen" : "$Header::colourred" ); } else { $bgcolor = "blue"; @@ -1291,7 +1295,11 @@ print""; if ( -e "$ovpnpid" ) { -@ovpnstatus = `cat /var/run/openvpn-rw.log`; +if ( -r "/var/run/openvpn-rw.log" ) { + open(FILE, "/var/run/openvpn-rw.log"); + @ovpnstatus = ; + close (FILE); +} print" @@ -1537,7 +1545,7 @@ my $dotip = length($ipaddresses[$a]) - rindex($ipaddresses[$a],'.'); foreach $interface (@devs_net) { next if ( $netsettings{"$ic"."_DEV"} eq 'red0' && $netsettings{"RED_TYPE"} eq 'PPPOE'); if ( $netsettings{"$ic"."_DEV"} eq $interface ) { - if ( &General::IpInSubnet($ipaddresses[$a], $netsettings{"$ic"."_NETADDRESS"}, $netsettings{"$ic"."_NETMASK"}) ) { + if ( &Network::ip_address_in_network($ipaddresses[$a], $netsettings{"$ic"."_NETADDRESS"} . "/" . $netsettings{"$ic"."_NETMASK"}) ) { if ( $netsettings{"$ic"."_DEV"} eq 'red0' ) { print""; } @@ -1572,7 +1580,7 @@ my $dotip = length($ipaddresses[$a]) - rindex($ipaddresses[$a],'.'); if ( $ovpnsettings{'DOVPN_SUBNET'} ne '' ) { @match = split ("/", $ovpnsettings{'DOVPN_SUBNET'}); - if ( &General::IpInSubnet($ipaddresses[$a], $match[0], $match[1]) ) { + if ( &Network::ip_address_in_network($ipaddresses[$a], "$match[0]/$match[1]") ) { print""; last SWITCH; } @@ -1894,7 +1902,7 @@ SWITCH: { next if ( $netsettings{"$ic"."_DEV"} eq 'red0' && ($netsettings{"RED_TYPE"} eq 'DHCP' || $netsettings{"RED_TYPE"} eq 'PPPOE')); if ($netsettings{"$ic"."_DEV"} eq $interface) { - if ( &General::IpInSubnet($line[1], $netsettings{"$ic"."_NETADDRESS"}, $netsettings{"$ic"."_NETMASK"}) ) { + if ( &Network::ip_address_in_network($line[1], $netsettings{"$ic"."_NETADDRESS"} . "/" . $netsettings{"$ic"."_NETMASK"}) ) { print""; last SWITCH; } @@ -1908,10 +1916,10 @@ SWITCH: { my $redipadr = qx'ip addr | grep red0 | grep inet | awk "{print \$2}"'; my @rednet = split ("/", $redipadr); chomp ($rednet[1]); - my $red_netmask = General::iporsubtodec($rednet[1]); + my $red_netmask = Network::get_netmask("$rednet[0]/$rednet[1]"); my $red_netaddress = Network::get_netaddress("$rednet[0]/$red_netmask"); - if ( &General::IpInSubnet($line[1], $red_netaddress, $red_netmask) ) { + if ( &Network::ip_address_in_network($line[1], "$red_netaddress/$red_netmask") ) { print""; last SWITCH; } @@ -2211,7 +2219,7 @@ sub validSave { $errormessage = _('No IP address was registered!'); } - if ( $wiosettings{'IPADR'} ne '' && (! &General::validip($wiosettings{'IPADR'})) ) { + if ( $wiosettings{'IPADR'} ne '' && (! &Network::check_ip_address($wiosettings{'IPADR'})) ) { $errormessage = _('Invalid IP address.'); } @@ -2219,12 +2227,12 @@ sub validSave { $errormessage = _('No hostname was registered!'); } - if ( $wiosettings{'HOST'} ne '' && (! &General::validdomainname($wiosettings{'HOST'})) ) { + if ( $wiosettings{'HOST'} ne '' && (! &Network::check_domainname($wiosettings{'HOST'})) ) { $errormessage = _('Invalid hostname.'); } if ( $wiosettings{'DYNDNS'} eq 'on' && (! defined($errormessage)) ) { - unless(&General::validfqdn($wiosettings{'HOST'})) { $errormessage = _('Invalid Fully Qualified Domain Name (FQDN)! Please do not use special characters or blanks in the FQDN.'); } + unless(&Network::check_fqdn($wiosettings{'HOST'})) { $errormessage = _('Invalid Fully Qualified Domain Name (FQDN)! Please do not use special characters or blanks in the FQDN.'); } ( $wiosettings{'IPADR'}, $infomessage ) = &WIO::getdyndnsip($wiosettings{'IPADR'}, $wiosettings{'HOST'}); $wiosettings{'PINGMETHODE'} = 'fqdn'; } diff --git a/html/cgi-bin/wireguard.cgi b/html/cgi-bin/wireguard.cgi index 5541b5a8b..f3ad1278b 100644 --- a/html/cgi-bin/wireguard.cgi +++ b/html/cgi-bin/wireguard.cgi @@ -52,14 +52,14 @@ if ($cgiparams{"ACTION"} eq _('Save')) { } # Check endpoint - if (&General::validfqdn($cgiparams{'ENDPOINT'}) || &Network::check_ip_address($cgiparams{'ENDPOINT'}) || ($cgiparams{'ENDPOINT'} eq '')) { + if (&Network::check_fqdn($cgiparams{'ENDPOINT'}) || &Network::check_ip_address($cgiparams{'ENDPOINT'}) || ($cgiparams{'ENDPOINT'} eq '')) { $Wireguard::settings{'ENDPOINT'} = $cgiparams{'ENDPOINT'}; } else { push(@errormessages, _('Invalid Endpoint')); } # Check port - if (&General::validport($cgiparams{'PORT'})) { + if (&Network::check_port($cgiparams{'PORT'})) { $Wireguard::settings{'PORT'} = $cgiparams{'PORT'}; } else { push(@errormessages, _('Invalid port. Must be a valid port number.')); @@ -257,7 +257,7 @@ if ($cgiparams{"ACTION"} eq _('Save')) { # Check the endpoint address if ($cgiparams{'ENDPOINT_ADDRESS'} eq '') { # The endpoint address may be empty - } elsif (&General::validfqdn($cgiparams{'ENDPOINT_ADDRESS'})) { + } elsif (&Network::check_fqdn($cgiparams{'ENDPOINT_ADDRESS'})) { # The endpoint is a valid FQDN } elsif (&Network::check_ip_address($cgiparams{'ENDPOINT_ADDRESS'})) { # The endpoint is a valid IP address @@ -439,14 +439,14 @@ END $cgiparams{'PORT'} = &Wireguard::get_free_port(); # If a port was given we check that it is valid - } elsif (!&General::validport($cgiparams{'PORT'})) { + } elsif (!&Network::check_port($cgiparams{'PORT'})) { push(@errormessages, $LANG::tr{'invalid port'}); } # Check the endpoint address if ($cgiparams{'ENDPOINT_ADDRESS'} eq '') { # The endpoint address may be empty - } elsif (&General::validfqdn($cgiparams{'ENDPOINT_ADDRESS'})) { + } elsif (&Network::check_fqdn($cgiparams{'ENDPOINT_ADDRESS'})) { # The endpoint is a valid FQDN } elsif (&Network::check_ip_address($cgiparams{'ENDPOINT_ADDRESS'})) { # The endpoint is a valid IP address @@ -455,7 +455,7 @@ END } # Check the endpoint port - unless (&General::validport($cgiparams{'ENDPOINT_PORT'})) { + unless (&Network::check_port($cgiparams{'ENDPOINT_PORT'})) { push(@errormessages, _('Invalid Endpoint Port')); } diff --git a/html/cgi-bin/wireless.cgi b/html/cgi-bin/wireless.cgi index 3a3b89697..922efd35d 100644 --- a/html/cgi-bin/wireless.cgi +++ b/html/cgi-bin/wireless.cgi @@ -92,7 +92,7 @@ if ($cgiparams{'ACTION'} eq 'add') { $cgiparams{'SOURCE_IP'} = 'NONE'; } else { - unless(&General::validipormask($cgiparams{'SOURCE_IP'})) + unless((&Network::check_ip_address($cgiparams{'SOURCE_IP'}) || &Network::check_subnet($cgiparams{'SOURCE_IP'}))) { $errormessage = _('Invalid Fixed IP Address'); goto ADDERROR; @@ -102,7 +102,7 @@ if ($cgiparams{'ACTION'} eq 'add') { $cgiparams{'SOURCE_MAC'} = 'NONE'; } else { - unless(&General::validmac($cgiparams{'SOURCE_MAC'})) + unless(&Network::valid_mac($cgiparams{'SOURCE_MAC'})) { $errormessage = _('Invalid Fixed MAC Address'); } @@ -447,9 +447,7 @@ END $hostname =~ s/\"//g; } elsif ($line eq "}") { # Select records in Blue subnet - if ( &General::IpInSubnet ( $ip, - $netsettings{"BLUE_NETADDRESS"}, - $netsettings{"BLUE_NETMASK"} ) ) { + if ( &Network::ip_address_in_network($ip, $netsettings{"BLUE_NETADDRESS"} . "/" . $netsettings{"BLUE_NETMASK"}) ) { @record = ('IPADDR',$ip,'ENDTIME',$endtime,'ETHER',$ether,'HOSTNAME',$hostname); $record = {}; # create a reference to empty hash %{$record} = @record; # populate that hash with @record diff --git a/html/cgi-bin/wlanap.cgi b/html/cgi-bin/wlanap.cgi index bca8795fd..6b8dd3466 100644 --- a/html/cgi-bin/wlanap.cgi +++ b/html/cgi-bin/wlanap.cgi @@ -460,7 +460,9 @@ END if ($INTF) { &Header::opensection(); - my @status = `iw dev $INTF info`; + open(my $iw, "-|", "iw", "dev", $INTF, "info"); + my @status = <$iw>; + close($iw); if (@status) { print <; + close($iw); if (@status) { print <) { # Skip everything we are not interested in diff --git a/lfs/guardian b/lfs/guardian index bc6b50410..14071b8a9 100644 --- a/lfs/guardian +++ b/lfs/guardian @@ -35,7 +35,7 @@ DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = guardian -PAK_VER = 30 +PAK_VER = 31 DEPS = perl-inotify2 perl-Net-IP diff --git a/lfs/perl-File-ReadBackwards b/lfs/perl-File-ReadBackwards index 454fa14ec..fe48f31dc 100644 --- a/lfs/perl-File-ReadBackwards +++ b/lfs/perl-File-ReadBackwards @@ -33,12 +33,6 @@ DL_FILE = $(THISAPP).tar.gz DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) -PROG = perl-File-ReadBackwards -PAK_VER = 5 - -DEPS = - -SERVICES = ############################################################################### # Top-level Rules diff --git a/lfs/proxy-accounting b/lfs/proxy-accounting index c2d248fc4..a430c5e7f 100644 --- a/lfs/proxy-accounting +++ b/lfs/proxy-accounting @@ -34,7 +34,7 @@ TARGET = $(DIR_INFO)/$(THISAPP) PROG = proxy-accounting PAK_VER = 16 -DEPS = perl-File-ReadBackwards +DEPS = SERVICES = diff --git a/lfs/tor b/lfs/tor index 74ed1bd9a..31372fd8f 100644 --- a/lfs/tor +++ b/lfs/tor @@ -34,7 +34,7 @@ DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = tor -PAK_VER = 96 +PAK_VER = 97 DEPS = diff --git a/lfs/wio b/lfs/wio index 5b15e1a98..10f60fffa 100644 --- a/lfs/wio +++ b/lfs/wio @@ -32,7 +32,7 @@ THISAPP = wio-$(VER) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = wio -PAK_VER = 20 +PAK_VER = 21 DEPS = diff --git a/po/de.po b/po/de.po index e6ee8d6e6..e1bb5082b 100644 --- a/po/de.po +++ b/po/de.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: IPFire\n" "Report-Msgid-Bugs-To: https://bugzilla.ipfire.org/\n" -"POT-Creation-Date: 2026-10-06 16:18+0000\n" +"POT-Creation-Date: 2026-10-08 16:03+0000\n" "Language-Team: German\n" "Language: de\n" "MIME-Version: 1.0\n" @@ -1240,13 +1240,13 @@ msgstr "Backup von %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s KB, date %s" -msgstr "Backup von %s Größe %s KB Datum %s" +msgid "Backup from %s, size %s" +msgstr "Backup von %s Größe %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s MB" -msgstr "Backup von %s Größe %s MB" +msgid "Backup from %s, size %s, date %s" +msgstr "Backup von %s Größe %s Datum %s" #: html/cgi-bin/backup.cgi msgid "Backups" @@ -4660,11 +4660,11 @@ msgstr "Getrennt" msgid "Duration" msgstr "Dauer" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Received" msgstr "Empfangen" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Sent" msgstr "Gesendet" @@ -4949,14 +4949,6 @@ msgstr "Frei" msgid "Index-Nodes" msgstr "Index Nodes" -#: html/cgi-bin/media.cgi -msgid "MB Read" -msgstr "MB gelesen" - -#: html/cgi-bin/media.cgi -msgid "MB Written" -msgstr "MB geschrieben" - #: html/cgi-bin/media.cgi msgid "Media Information" msgstr "Laufwerksinformationen" @@ -4965,6 +4957,10 @@ msgstr "Laufwerksinformationen" msgid "Mounted On" msgstr "Mounted auf" +#: html/cgi-bin/media.cgi +msgid "Read" +msgstr "Gelesen" + #: html/cgi-bin/media.cgi msgid "S.M.A.R.T. Information" msgstr "SMART-Informationen" @@ -4977,6 +4973,10 @@ msgstr "seit" msgid "Transfers" msgstr "Datenübertragungen" +#: html/cgi-bin/media.cgi +msgid "Written" +msgstr "Geschrieben" + #: html/cgi-bin/memory.cgi msgid "Available" msgstr "verfügbar" @@ -5436,14 +5436,6 @@ msgstr "Bit" msgid "Broken Pipe" msgstr "Zerbrochene Pipe" -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Received" -msgstr "Bytes empfangen" - -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Sent" -msgstr "Bytes gesendet" - #: html/cgi-bin/ovpnmain.cgi html/cgi-bin/vpnmain.cgi msgid "CA Certificate:" msgstr "CA-Zertifikat:" @@ -8333,8 +8325,8 @@ msgid "Cache Maintenance" msgstr "Cache-Wartung" #: html/cgi-bin/updatexlrator.cgi -msgid "Cache Size (bytes)" -msgstr "Cachegröße (Bytes)" +msgid "Cache Size" +msgstr "Cachegröße" #: html/cgi-bin/updatexlrator.cgi msgid "Cache Statistics" @@ -8349,8 +8341,8 @@ msgid "Current Files in Local Cache" msgstr "Aktuelle Dateien im lokalen Cache" #: html/cgi-bin/updatexlrator.cgi -msgid "Data From Cache (bytes)" -msgstr "Daten vom Cache (Bytes)" +msgid "Data From Cache" +msgstr "Daten vom Cache" #: html/cgi-bin/updatexlrator.cgi src/squid-accounting/accounting.cgi #: src/squid-accounting/acct-lib.pl @@ -8486,12 +8478,12 @@ msgid "Three Months" msgstr "drei Monaten" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Cache Size (bytes):" -msgstr "Gesamtgröße des Cache (Bytes):" +msgid "Total Cache Size:" +msgstr "Gesamtgröße des Cache:" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Data Delivered From Cache (bytes):" -msgstr "Daten insgesamt vom Cache ausgeliefert (Bytes):" +msgid "Total Data Delivered From Cache:" +msgstr "Daten insgesamt vom Cache ausgeliefert:" #: html/cgi-bin/updatexlrator.cgi msgid "Total Files in Cache:" @@ -11172,3 +11164,9 @@ msgstr "Summe" #: src/squid-accounting/acct-lib.pl msgid "VAT" msgstr "USt." + +#~ msgid "Bytes Received" +#~ msgstr "Bytes empfangen" + +#~ msgid "Bytes Sent" +#~ msgstr "Bytes gesendet" diff --git a/po/es.po b/po/es.po index 442766ad2..5b9b4c8d0 100644 --- a/po/es.po +++ b/po/es.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: IPFire\n" "Report-Msgid-Bugs-To: https://bugzilla.ipfire.org/\n" -"POT-Creation-Date: 2026-10-06 16:18+0000\n" +"POT-Creation-Date: 2026-10-08 16:03+0000\n" "Language-Team: Spanish\n" "Language: es\n" "MIME-Version: 1.0\n" @@ -1243,13 +1243,13 @@ msgstr "Respaldar %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s KB, date %s" -msgstr "Respaldar %s Tamaño %s KB Fecha %s" +msgid "Backup from %s, size %s" +msgstr "Respaldar %s Tamaño %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s MB" -msgstr "Respaldar %s Tamaño %s MB" +msgid "Backup from %s, size %s, date %s" +msgstr "Respaldar %s Tamaño %s Fecha %s" #: html/cgi-bin/backup.cgi msgid "Backups" @@ -4646,11 +4646,11 @@ msgstr "Desconectado" msgid "Duration" msgstr "Duración" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Received" msgstr "Recibido" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Sent" msgstr "Enviado" @@ -4935,14 +4935,6 @@ msgstr "Libre" msgid "Index-Nodes" msgstr "índice-Nodos" -#: html/cgi-bin/media.cgi -msgid "MB Read" -msgstr "MB leidos" - -#: html/cgi-bin/media.cgi -msgid "MB Written" -msgstr "MB escritos" - #: html/cgi-bin/media.cgi msgid "Media Information" msgstr "información de medios" @@ -4951,6 +4943,10 @@ msgstr "información de medios" msgid "Mounted On" msgstr "Montado en" +#: html/cgi-bin/media.cgi +msgid "Read" +msgstr "Leidos" + #: html/cgi-bin/media.cgi msgid "S.M.A.R.T. Information" msgstr "Información S.M.A.R.T." @@ -4963,6 +4959,10 @@ msgstr "desde" msgid "Transfers" msgstr "Transferencias" +#: html/cgi-bin/media.cgi +msgid "Written" +msgstr "Escritos" + #: html/cgi-bin/memory.cgi msgid "Available" msgstr "Disponible" @@ -5424,14 +5424,6 @@ msgstr "bit" msgid "Broken Pipe" msgstr "Broken Pipe" -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Received" -msgstr "Bytes recibidos" - -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Sent" -msgstr "Bytes enviados" - #: html/cgi-bin/ovpnmain.cgi html/cgi-bin/vpnmain.cgi msgid "CA Certificate:" msgstr "Certificado CA:" @@ -8313,8 +8305,8 @@ msgid "Cache Maintenance" msgstr "Mantenimiento del caché" #: html/cgi-bin/updatexlrator.cgi -msgid "Cache Size (bytes)" -msgstr "Tamaño del caché (bytes)" +msgid "Cache Size" +msgstr "Tamaño del caché" #: html/cgi-bin/updatexlrator.cgi msgid "Cache Statistics" @@ -8329,8 +8321,8 @@ msgid "Current Files in Local Cache" msgstr "Archivos actualmente en el caché" #: html/cgi-bin/updatexlrator.cgi -msgid "Data From Cache (bytes)" -msgstr "Datos del caché (bytes)" +msgid "Data From Cache" +msgstr "Datos del caché" #: html/cgi-bin/updatexlrator.cgi src/squid-accounting/accounting.cgi #: src/squid-accounting/acct-lib.pl @@ -8466,12 +8458,12 @@ msgid "Three Months" msgstr "tres meses" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Cache Size (bytes):" -msgstr "Tamaño total del caché (bytes):" +msgid "Total Cache Size:" +msgstr "Tamaño total del caché:" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Data Delivered From Cache (bytes):" -msgstr "Datos totales enviados por el caché (bytes):" +msgid "Total Data Delivered From Cache:" +msgstr "Datos totales enviados por el caché:" #: html/cgi-bin/updatexlrator.cgi msgid "Total Files in Cache:" @@ -11139,3 +11131,9 @@ msgstr "" #: src/squid-accounting/acct-lib.pl msgid "VAT" msgstr "" + +#~ msgid "Bytes Received" +#~ msgstr "Bytes recibidos" + +#~ msgid "Bytes Sent" +#~ msgstr "Bytes enviados" diff --git a/po/fr.po b/po/fr.po index 1e8fca210..29a1dce80 100644 --- a/po/fr.po +++ b/po/fr.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: IPFire\n" "Report-Msgid-Bugs-To: https://bugzilla.ipfire.org/\n" -"POT-Creation-Date: 2026-10-06 16:18+0000\n" +"POT-Creation-Date: 2026-10-08 16:03+0000\n" "Language-Team: French\n" "Language: fr\n" "MIME-Version: 1.0\n" @@ -1245,13 +1245,13 @@ msgstr "Sauvegarder depuis %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s KB, date %s" -msgstr "Sauvegarder depuis %s Taille %s KB Date %s" +msgid "Backup from %s, size %s" +msgstr "Sauvegarder depuis %s Taille %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s MB" -msgstr "Sauvegarder depuis %s Taille %s MB" +msgid "Backup from %s, size %s, date %s" +msgstr "Sauvegarder depuis %s Taille %s Date %s" #: html/cgi-bin/backup.cgi msgid "Backups" @@ -4655,11 +4655,11 @@ msgstr "Déconnecté" msgid "Duration" msgstr "Durée" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Received" msgstr "Reçu" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Sent" msgstr "Envoyé" @@ -4944,14 +4944,6 @@ msgstr "Libre" msgid "Index-Nodes" msgstr "Nœuds-Index" -#: html/cgi-bin/media.cgi -msgid "MB Read" -msgstr "Mo lus" - -#: html/cgi-bin/media.cgi -msgid "MB Written" -msgstr "Mo écrits" - #: html/cgi-bin/media.cgi msgid "Media Information" msgstr "Informations du stockage" @@ -4960,6 +4952,10 @@ msgstr "Informations du stockage" msgid "Mounted On" msgstr "Monté en tant que" +#: html/cgi-bin/media.cgi +msgid "Read" +msgstr "Lus" + #: html/cgi-bin/media.cgi msgid "S.M.A.R.T. Information" msgstr "Informations S.M.A.R.T." @@ -4972,6 +4968,10 @@ msgstr "depuis" msgid "Transfers" msgstr "Transferts" +#: html/cgi-bin/media.cgi +msgid "Written" +msgstr "Écrits" + #: html/cgi-bin/memory.cgi msgid "Available" msgstr "disponible" @@ -5430,14 +5430,6 @@ msgstr "bit" msgid "Broken Pipe" msgstr "Lien rompu" -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Received" -msgstr "Octets reçus" - -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Sent" -msgstr "Octets envoyés" - #: html/cgi-bin/ovpnmain.cgi html/cgi-bin/vpnmain.cgi msgid "CA Certificate:" msgstr "Certificat CA :" @@ -8332,8 +8324,8 @@ msgid "Cache Maintenance" msgstr "Maintenance du cache" #: html/cgi-bin/updatexlrator.cgi -msgid "Cache Size (bytes)" -msgstr "Taille du cache (octets)" +msgid "Cache Size" +msgstr "Taille du cache" #: html/cgi-bin/updatexlrator.cgi msgid "Cache Statistics" @@ -8348,8 +8340,8 @@ msgid "Current Files in Local Cache" msgstr "Les fichiers suivants sont dans le cache local" #: html/cgi-bin/updatexlrator.cgi -msgid "Data From Cache (bytes)" -msgstr "Taille fournie (octets)" +msgid "Data From Cache" +msgstr "Taille fournie" #: html/cgi-bin/updatexlrator.cgi src/squid-accounting/accounting.cgi #: src/squid-accounting/acct-lib.pl @@ -8487,12 +8479,12 @@ msgid "Three Months" msgstr "trois mois" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Cache Size (bytes):" -msgstr "Taille totale du cache (octets) :" +msgid "Total Cache Size:" +msgstr "Taille totale du cache :" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Data Delivered From Cache (bytes):" -msgstr "Taille totale fournie par le cache (octets) :" +msgid "Total Data Delivered From Cache:" +msgstr "Taille totale fournie par le cache :" #: html/cgi-bin/updatexlrator.cgi msgid "Total Files in Cache:" @@ -11166,3 +11158,9 @@ msgstr "Sous-total" #: src/squid-accounting/acct-lib.pl msgid "VAT" msgstr "TVA" + +#~ msgid "Bytes Received" +#~ msgstr "Octets reçus" + +#~ msgid "Bytes Sent" +#~ msgstr "Octets envoyés" diff --git a/po/ipfire.pot b/po/ipfire.pot index 5d3d356c6..c01069d2f 100644 --- a/po/ipfire.pot +++ b/po/ipfire.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: IPFire\n" "Report-Msgid-Bugs-To: https://bugzilla.ipfire.org/\n" -"POT-Creation-Date: 2026-10-06 16:18+0000\n" +"POT-Creation-Date: 2026-10-08 16:03+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1243,7 +1243,7 @@ msgstr "" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s MB" +msgid "Backup from %s, size %s" msgstr "" #: html/cgi-bin/backup.cgi html/cgi-bin/updatexlrator.cgi @@ -1264,7 +1264,7 @@ msgstr "" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s KB, date %s" +msgid "Backup from %s, size %s, date %s" msgstr "" #: html/cgi-bin/backup.cgi @@ -4588,11 +4588,11 @@ msgstr "" msgid "Duration" msgstr "" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Received" msgstr "" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Sent" msgstr "" @@ -4875,11 +4875,11 @@ msgid "Transfers" msgstr "" #: html/cgi-bin/media.cgi -msgid "MB Read" +msgid "Read" msgstr "" #: html/cgi-bin/media.cgi -msgid "MB Written" +msgid "Written" msgstr "" #: html/cgi-bin/media.cgi html/cgi-bin/pakfire.cgi @@ -5704,14 +5704,6 @@ msgstr "" msgid "Logged in At" msgstr "" -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Sent" -msgstr "" - -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Received" -msgstr "" - #: html/cgi-bin/ovpnmain.cgi msgid "Last Activity" msgstr "" @@ -8254,7 +8246,7 @@ msgid "Total Files in Cache:" msgstr "" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Cache Size (bytes):" +msgid "Total Cache Size:" msgstr "" #: html/cgi-bin/updatexlrator.cgi @@ -8262,7 +8254,7 @@ msgid "Cache Efficiency Index:" msgstr "" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Data Delivered From Cache (bytes):" +msgid "Total Data Delivered From Cache:" msgstr "" #: html/cgi-bin/updatexlrator.cgi @@ -8274,11 +8266,11 @@ msgid "Files" msgstr "" #: html/cgi-bin/updatexlrator.cgi -msgid "Cache Size (bytes)" +msgid "Cache Size" msgstr "" #: html/cgi-bin/updatexlrator.cgi -msgid "Data From Cache (bytes)" +msgid "Data From Cache" msgstr "" #: html/cgi-bin/updatexlrator.cgi diff --git a/po/it.po b/po/it.po index fb216078e..c930ae845 100644 --- a/po/it.po +++ b/po/it.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: IPFire\n" "Report-Msgid-Bugs-To: https://bugzilla.ipfire.org/\n" -"POT-Creation-Date: 2026-10-06 16:18+0000\n" +"POT-Creation-Date: 2026-10-08 16:03+0000\n" "Language-Team: Italian\n" "Language: it\n" "MIME-Version: 1.0\n" @@ -1236,13 +1236,13 @@ msgstr "Backup del %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s KB, date %s" -msgstr "Backup del %s grandezza %s KB Date %s" +msgid "Backup from %s, size %s" +msgstr "Backup del %s grandezza %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s MB" -msgstr "Backup del %s grandezza %s MB" +msgid "Backup from %s, size %s, date %s" +msgstr "Backup del %s grandezza %s Date %s" #: html/cgi-bin/backup.cgi msgid "Backups" @@ -4611,11 +4611,11 @@ msgstr "Disconnesso" msgid "Duration" msgstr "" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Received" msgstr "" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Sent" msgstr "" @@ -4901,14 +4901,6 @@ msgstr "Libero" msgid "Index-Nodes" msgstr "" -#: html/cgi-bin/media.cgi -msgid "MB Read" -msgstr "MB Letti" - -#: html/cgi-bin/media.cgi -msgid "MB Written" -msgstr "MB Scritti" - #: html/cgi-bin/media.cgi msgid "Media Information" msgstr "Informazioni Media" @@ -4917,6 +4909,10 @@ msgstr "Informazioni Media" msgid "Mounted On" msgstr "Montato su" +#: html/cgi-bin/media.cgi +msgid "Read" +msgstr "Letti" + #: html/cgi-bin/media.cgi msgid "S.M.A.R.T. Information" msgstr "Informazione S.M.A.R.T." @@ -4929,6 +4925,10 @@ msgstr "since" msgid "Transfers" msgstr "" +#: html/cgi-bin/media.cgi +msgid "Written" +msgstr "Scritti" + #: html/cgi-bin/memory.cgi msgid "Available" msgstr "" @@ -5381,14 +5381,6 @@ msgstr "Bit" msgid "Broken Pipe" msgstr "Broken pipe" -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Received" -msgstr "Bytes Received" - -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Sent" -msgstr "Bytes Sent" - #: html/cgi-bin/ovpnmain.cgi html/cgi-bin/vpnmain.cgi msgid "CA Certificate:" msgstr "CA Certificate:" @@ -8238,8 +8230,8 @@ msgid "Cache Maintenance" msgstr "Cache maintenance" #: html/cgi-bin/updatexlrator.cgi -msgid "Cache Size (bytes)" -msgstr "Cache size (bytes)" +msgid "Cache Size" +msgstr "Cache size" #: html/cgi-bin/updatexlrator.cgi msgid "Cache Statistics" @@ -8254,8 +8246,8 @@ msgid "Current Files in Local Cache" msgstr "Current files in local cache" #: html/cgi-bin/updatexlrator.cgi -msgid "Data From Cache (bytes)" -msgstr "Data from cache (bytes)" +msgid "Data From Cache" +msgstr "Data from cache" #: html/cgi-bin/updatexlrator.cgi src/squid-accounting/accounting.cgi #: src/squid-accounting/acct-lib.pl @@ -8391,12 +8383,12 @@ msgid "Three Months" msgstr "three months" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Cache Size (bytes):" -msgstr "Total cache size (bytes):" +msgid "Total Cache Size:" +msgstr "Total cache size:" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Data Delivered From Cache (bytes):" -msgstr "Total data delivered from cache (bytes):" +msgid "Total Data Delivered From Cache:" +msgstr "Total data delivered from cache:" #: html/cgi-bin/updatexlrator.cgi msgid "Total Files in Cache:" @@ -11033,3 +11025,9 @@ msgstr "" #: src/squid-accounting/acct-lib.pl msgid "VAT" msgstr "" + +#~ msgid "Bytes Received" +#~ msgstr "Bytes Received" + +#~ msgid "Bytes Sent" +#~ msgstr "Bytes Sent" diff --git a/po/nl.po b/po/nl.po index 0a89f6f1a..d556c3f8d 100644 --- a/po/nl.po +++ b/po/nl.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: IPFire\n" "Report-Msgid-Bugs-To: https://bugzilla.ipfire.org/\n" -"POT-Creation-Date: 2026-10-06 16:18+0000\n" +"POT-Creation-Date: 2026-10-08 16:03+0000\n" "Language-Team: Dutch\n" "Language: nl\n" "MIME-Version: 1.0\n" @@ -1237,13 +1237,13 @@ msgstr "Back-up van %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s KB, date %s" -msgstr "Back-up van %s Grootte %s KB Datum %s" +msgid "Backup from %s, size %s" +msgstr "Back-up van %s Grootte %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s MB" -msgstr "Back-up van %s Grootte %s MB" +msgid "Backup from %s, size %s, date %s" +msgstr "Back-up van %s Grootte %s Datum %s" #: html/cgi-bin/backup.cgi msgid "Backups" @@ -4621,11 +4621,11 @@ msgstr "Verbroken" msgid "Duration" msgstr "" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Received" msgstr "" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Sent" msgstr "" @@ -4911,14 +4911,6 @@ msgstr "Beschikbaar" msgid "Index-Nodes" msgstr "" -#: html/cgi-bin/media.cgi -msgid "MB Read" -msgstr "MB gelezen" - -#: html/cgi-bin/media.cgi -msgid "MB Written" -msgstr "MB geschreven" - #: html/cgi-bin/media.cgi msgid "Media Information" msgstr "media-informatie" @@ -4927,6 +4919,10 @@ msgstr "media-informatie" msgid "Mounted On" msgstr "Gekoppeld op" +#: html/cgi-bin/media.cgi +msgid "Read" +msgstr "Gelezen" + #: html/cgi-bin/media.cgi msgid "S.M.A.R.T. Information" msgstr "S.M.A.R.T. informatie" @@ -4939,6 +4935,10 @@ msgstr "sinds" msgid "Transfers" msgstr "" +#: html/cgi-bin/media.cgi +msgid "Written" +msgstr "Geschreven" + #: html/cgi-bin/memory.cgi msgid "Available" msgstr "" @@ -5390,14 +5390,6 @@ msgstr "Bit" msgid "Broken Pipe" msgstr "Broken pipe" -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Received" -msgstr "Bytes ontvangen" - -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Sent" -msgstr "Bytes verzonden" - #: html/cgi-bin/ovpnmain.cgi html/cgi-bin/vpnmain.cgi msgid "CA Certificate:" msgstr "CA Certificaat:" @@ -8255,8 +8247,8 @@ msgid "Cache Maintenance" msgstr "Cache onderhoud" #: html/cgi-bin/updatexlrator.cgi -msgid "Cache Size (bytes)" -msgstr "Cache grootte (bytes)" +msgid "Cache Size" +msgstr "Cache grootte" #: html/cgi-bin/updatexlrator.cgi msgid "Cache Statistics" @@ -8271,8 +8263,8 @@ msgid "Current Files in Local Cache" msgstr "Huidige bestanden in de lokale cache" #: html/cgi-bin/updatexlrator.cgi -msgid "Data From Cache (bytes)" -msgstr "Data van cache (bytes)" +msgid "Data From Cache" +msgstr "Data van cache" #: html/cgi-bin/updatexlrator.cgi src/squid-accounting/accounting.cgi #: src/squid-accounting/acct-lib.pl @@ -8408,12 +8400,12 @@ msgid "Three Months" msgstr "drie maanden" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Cache Size (bytes):" -msgstr "Totale cachegrootte (bytes):" +msgid "Total Cache Size:" +msgstr "Totale cachegrootte:" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Data Delivered From Cache (bytes):" -msgstr "Totale hoeveelheid data geleverd uit cache (bytes):" +msgid "Total Data Delivered From Cache:" +msgstr "Totale hoeveelheid data geleverd uit cache:" #: html/cgi-bin/updatexlrator.cgi msgid "Total Files in Cache:" @@ -11060,3 +11052,9 @@ msgstr "" #: src/squid-accounting/acct-lib.pl msgid "VAT" msgstr "" + +#~ msgid "Bytes Received" +#~ msgstr "Bytes ontvangen" + +#~ msgid "Bytes Sent" +#~ msgstr "Bytes verzonden" diff --git a/po/pl.po b/po/pl.po index 9695d5cde..d1eafd010 100644 --- a/po/pl.po +++ b/po/pl.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: IPFire\n" "Report-Msgid-Bugs-To: https://bugzilla.ipfire.org/\n" -"POT-Creation-Date: 2026-10-06 16:18+0000\n" +"POT-Creation-Date: 2026-10-08 16:03+0000\n" "Language-Team: Polish\n" "Language: pl\n" "MIME-Version: 1.0\n" @@ -1235,13 +1235,13 @@ msgstr "Backup z %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s KB, date %s" -msgstr "Backup z %s Rozmiar %s KB Data %s" +msgid "Backup from %s, size %s" +msgstr "Backup z %s Rozmiar %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s MB" -msgstr "Backup z %s Rozmiar %s MB" +msgid "Backup from %s, size %s, date %s" +msgstr "Backup z %s Rozmiar %s Data %s" #: html/cgi-bin/backup.cgi msgid "Backups" @@ -4590,11 +4590,11 @@ msgstr "" msgid "Duration" msgstr "" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Received" msgstr "" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Sent" msgstr "" @@ -4879,14 +4879,6 @@ msgstr "Wolne" msgid "Index-Nodes" msgstr "" -#: html/cgi-bin/media.cgi -msgid "MB Read" -msgstr "" - -#: html/cgi-bin/media.cgi -msgid "MB Written" -msgstr "" - #: html/cgi-bin/media.cgi msgid "Media Information" msgstr "Informacje o nośnikach" @@ -4895,6 +4887,10 @@ msgstr "Informacje o nośnikach" msgid "Mounted On" msgstr "Zamontowany w" +#: html/cgi-bin/media.cgi +msgid "Read" +msgstr "" + #: html/cgi-bin/media.cgi msgid "S.M.A.R.T. Information" msgstr "Informacje S.M.A.R.T." @@ -4907,6 +4903,10 @@ msgstr "od" msgid "Transfers" msgstr "" +#: html/cgi-bin/media.cgi +msgid "Written" +msgstr "Zapisano" + #: html/cgi-bin/memory.cgi msgid "Available" msgstr "" @@ -5353,14 +5353,6 @@ msgstr "" msgid "Broken Pipe" msgstr "Broken pipe" -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Received" -msgstr "Bajtów odebranych" - -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Sent" -msgstr "Bajtów wysłanych" - #: html/cgi-bin/ovpnmain.cgi html/cgi-bin/vpnmain.cgi msgid "CA Certificate:" msgstr "Certyfikat CA:" @@ -8208,8 +8200,8 @@ msgid "Cache Maintenance" msgstr "Utrzymanie Cache" #: html/cgi-bin/updatexlrator.cgi -msgid "Cache Size (bytes)" -msgstr "Rozmiar Cache (w bajtach)" +msgid "Cache Size" +msgstr "Rozmiar Cache" #: html/cgi-bin/updatexlrator.cgi msgid "Cache Statistics" @@ -8224,8 +8216,8 @@ msgid "Current Files in Local Cache" msgstr "Pliki znajdujące się w lokalnej pamięci cache" #: html/cgi-bin/updatexlrator.cgi -msgid "Data From Cache (bytes)" -msgstr "Danych z pamięci cache (w bajtach)" +msgid "Data From Cache" +msgstr "Danych z pamięci cache" #: html/cgi-bin/updatexlrator.cgi src/squid-accounting/accounting.cgi #: src/squid-accounting/acct-lib.pl @@ -8361,12 +8353,12 @@ msgid "Three Months" msgstr "trzech miesiący" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Cache Size (bytes):" -msgstr "Całkowity rozmiar cache (w bajtach):" +msgid "Total Cache Size:" +msgstr "Całkowity rozmiar cache:" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Data Delivered From Cache (bytes):" -msgstr "Danych dostarczonych z cache (w bajtach):" +msgid "Total Data Delivered From Cache:" +msgstr "Danych dostarczonych z cache:" #: html/cgi-bin/updatexlrator.cgi msgid "Total Files in Cache:" @@ -11005,3 +10997,9 @@ msgstr "" #: src/squid-accounting/acct-lib.pl msgid "VAT" msgstr "" + +#~ msgid "Bytes Received" +#~ msgstr "Bajtów odebranych" + +#~ msgid "Bytes Sent" +#~ msgstr "Bajtów wysłanych" diff --git a/po/ru.po b/po/ru.po index 175f367cb..1250a9473 100644 --- a/po/ru.po +++ b/po/ru.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: IPFire\n" "Report-Msgid-Bugs-To: https://bugzilla.ipfire.org/\n" -"POT-Creation-Date: 2026-10-06 16:18+0000\n" +"POT-Creation-Date: 2026-10-08 16:03+0000\n" "Language-Team: Russian\n" "Language: ru\n" "MIME-Version: 1.0\n" @@ -1231,13 +1231,13 @@ msgstr "Восстановить из %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s KB, date %s" -msgstr "Восстановить из %s Размер %s KB Дата %s" +msgid "Backup from %s, size %s" +msgstr "Восстановить из %s Размер %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s MB" -msgstr "Восстановить из %s Размер %s MB" +msgid "Backup from %s, size %s, date %s" +msgstr "Восстановить из %s Размер %s Дата %s" #: html/cgi-bin/backup.cgi msgid "Backups" @@ -4588,11 +4588,11 @@ msgstr "" msgid "Duration" msgstr "" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Received" msgstr "" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Sent" msgstr "" @@ -4876,14 +4876,6 @@ msgstr "Свободно" msgid "Index-Nodes" msgstr "" -#: html/cgi-bin/media.cgi -msgid "MB Read" -msgstr "" - -#: html/cgi-bin/media.cgi -msgid "MB Written" -msgstr "" - #: html/cgi-bin/media.cgi msgid "Media Information" msgstr "media information" @@ -4892,6 +4884,10 @@ msgstr "media information" msgid "Mounted On" msgstr "Смонтирован на" +#: html/cgi-bin/media.cgi +msgid "Read" +msgstr "" + #: html/cgi-bin/media.cgi msgid "S.M.A.R.T. Information" msgstr "Информация S.M.A.R.T." @@ -4904,6 +4900,10 @@ msgstr "с" msgid "Transfers" msgstr "" +#: html/cgi-bin/media.cgi +msgid "Written" +msgstr "" + #: html/cgi-bin/memory.cgi msgid "Available" msgstr "" @@ -5350,14 +5350,6 @@ msgstr "" msgid "Broken Pipe" msgstr "Broken pipe" -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Received" -msgstr "Bytes Received" - -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Sent" -msgstr "Bytes Sent" - #: html/cgi-bin/ovpnmain.cgi html/cgi-bin/vpnmain.cgi msgid "CA Certificate:" msgstr "CA Certificate:" @@ -8201,8 +8193,8 @@ msgid "Cache Maintenance" msgstr "Управление Кэшем" #: html/cgi-bin/updatexlrator.cgi -msgid "Cache Size (bytes)" -msgstr "Cache size (bytes)" +msgid "Cache Size" +msgstr "Cache size" #: html/cgi-bin/updatexlrator.cgi msgid "Cache Statistics" @@ -8217,8 +8209,8 @@ msgid "Current Files in Local Cache" msgstr "Текущие файлы в кэше" #: html/cgi-bin/updatexlrator.cgi -msgid "Data From Cache (bytes)" -msgstr "Данные кэша (байты)" +msgid "Data From Cache" +msgstr "Данные кэша" #: html/cgi-bin/updatexlrator.cgi src/squid-accounting/accounting.cgi #: src/squid-accounting/acct-lib.pl @@ -8354,12 +8346,12 @@ msgid "Three Months" msgstr "three months" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Cache Size (bytes):" -msgstr "Общий объём кэша (bytes):" +msgid "Total Cache Size:" +msgstr "Общий объём кэша:" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Data Delivered From Cache (bytes):" -msgstr "Общий объём использованных данных кэша (bytes):" +msgid "Total Data Delivered From Cache:" +msgstr "Общий объём использованных данных кэша:" #: html/cgi-bin/updatexlrator.cgi msgid "Total Files in Cache:" @@ -10996,3 +10988,9 @@ msgstr "" #: src/squid-accounting/acct-lib.pl msgid "VAT" msgstr "" + +#~ msgid "Bytes Received" +#~ msgstr "Bytes Received" + +#~ msgid "Bytes Sent" +#~ msgstr "Bytes Sent" diff --git a/po/tr.po b/po/tr.po index c30cfce28..2f70dc48e 100644 --- a/po/tr.po +++ b/po/tr.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: IPFire\n" "Report-Msgid-Bugs-To: https://bugzilla.ipfire.org/\n" -"POT-Creation-Date: 2026-10-06 16:18+0000\n" +"POT-Creation-Date: 2026-10-08 16:03+0000\n" "Language-Team: Turkish\n" "Language: tr\n" "MIME-Version: 1.0\n" @@ -1242,13 +1242,13 @@ msgstr "Yedek %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s KB, date %s" -msgstr "Yedek %s Boyut %s KB Tarih %s" +msgid "Backup from %s, size %s" +msgstr "Yedek %s Boyut %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s MB" -msgstr "Yedek %s Boyut %s MB" +msgid "Backup from %s, size %s, date %s" +msgstr "Yedek %s Boyut %s Tarih %s" #: html/cgi-bin/backup.cgi msgid "Backups" @@ -4626,11 +4626,11 @@ msgstr "Bağlantı kesildi" msgid "Duration" msgstr "" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Received" msgstr "" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Sent" msgstr "" @@ -4915,14 +4915,6 @@ msgstr "Boş" msgid "Index-Nodes" msgstr "" -#: html/cgi-bin/media.cgi -msgid "MB Read" -msgstr "Okunan MB" - -#: html/cgi-bin/media.cgi -msgid "MB Written" -msgstr "Yazılan MB" - #: html/cgi-bin/media.cgi msgid "Media Information" msgstr "Medya bilgisi" @@ -4931,6 +4923,10 @@ msgstr "Medya bilgisi" msgid "Mounted On" msgstr "Bağlı" +#: html/cgi-bin/media.cgi +msgid "Read" +msgstr "Okunan" + #: html/cgi-bin/media.cgi msgid "S.M.A.R.T. Information" msgstr "S.M.A.R.T. Bilgisi" @@ -4943,6 +4939,10 @@ msgstr "since" msgid "Transfers" msgstr "" +#: html/cgi-bin/media.cgi +msgid "Written" +msgstr "Yazılan" + #: html/cgi-bin/memory.cgi msgid "Available" msgstr "" @@ -5397,14 +5397,6 @@ msgstr "Bit" msgid "Broken Pipe" msgstr "Bozuk veri yolu" -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Received" -msgstr "Alınan Bayt" - -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Sent" -msgstr "Gönderilen Bayt" - #: html/cgi-bin/ovpnmain.cgi html/cgi-bin/vpnmain.cgi msgid "CA Certificate:" msgstr "CA Sertifika:" @@ -8262,8 +8254,8 @@ msgid "Cache Maintenance" msgstr "Önbellek bakımı" #: html/cgi-bin/updatexlrator.cgi -msgid "Cache Size (bytes)" -msgstr "Önbellek boyutu (bayt)" +msgid "Cache Size" +msgstr "Önbellek boyutu" #: html/cgi-bin/updatexlrator.cgi msgid "Cache Statistics" @@ -8278,8 +8270,8 @@ msgid "Current Files in Local Cache" msgstr "Yerel önbellekteki mevcut dosyalar" #: html/cgi-bin/updatexlrator.cgi -msgid "Data From Cache (bytes)" -msgstr "Önbellek verileri (bayt)" +msgid "Data From Cache" +msgstr "Önbellek verileri" #: html/cgi-bin/updatexlrator.cgi src/squid-accounting/accounting.cgi #: src/squid-accounting/acct-lib.pl @@ -8415,12 +8407,12 @@ msgid "Three Months" msgstr "üç ay" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Cache Size (bytes):" -msgstr "Toplam önbellek boyutu (bayt):" +msgid "Total Cache Size:" +msgstr "Toplam önbellek boyutu:" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Data Delivered From Cache (bytes):" -msgstr "Önbellekten teslim edilen toplam veri (bayt):" +msgid "Total Data Delivered From Cache:" +msgstr "Önbellekten teslim edilen toplam veri:" #: html/cgi-bin/updatexlrator.cgi msgid "Total Files in Cache:" @@ -11081,3 +11073,9 @@ msgstr "Toplam" #: src/squid-accounting/acct-lib.pl msgid "VAT" msgstr "KDV" + +#~ msgid "Bytes Received" +#~ msgstr "Alınan Bayt" + +#~ msgid "Bytes Sent" +#~ msgstr "Gönderilen Bayt" diff --git a/po/zh_CN.po b/po/zh_CN.po index 90136093c..198f880ab 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: IPFire\n" "Report-Msgid-Bugs-To: https://bugzilla.ipfire.org/\n" -"POT-Creation-Date: 2026-10-06 16:18+0000\n" +"POT-Creation-Date: 2026-10-08 16:03+0000\n" "Language-Team: Chinese (Simplified)\n" "Language: zh_CN\n" "MIME-Version: 1.0\n" @@ -1231,13 +1231,13 @@ msgstr "备份于 %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s KB, date %s" -msgstr "备份于 %s 大小 %s KB 日期 %s" +msgid "Backup from %s, size %s" +msgstr "备份于 %s 大小 %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s MB" -msgstr "备份于 %s 大小 %s MB" +msgid "Backup from %s, size %s, date %s" +msgstr "备份于 %s 大小 %s 日期 %s" #: html/cgi-bin/backup.cgi msgid "Backups" @@ -4583,11 +4583,11 @@ msgstr "已断开" msgid "Duration" msgstr "期间" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Received" msgstr "已收到" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Sent" msgstr "发送" @@ -4867,14 +4867,6 @@ msgstr "剩余" msgid "Index-Nodes" msgstr "索引节点" -#: html/cgi-bin/media.cgi -msgid "MB Read" -msgstr "读(MB)" - -#: html/cgi-bin/media.cgi -msgid "MB Written" -msgstr "写(MB)" - #: html/cgi-bin/media.cgi msgid "Media Information" msgstr "硬盘信息" @@ -4883,6 +4875,10 @@ msgstr "硬盘信息" msgid "Mounted On" msgstr "挂载" +#: html/cgi-bin/media.cgi +msgid "Read" +msgstr "读" + #: html/cgi-bin/media.cgi msgid "S.M.A.R.T. Information" msgstr "S.M.A.R.T. 信息" @@ -4895,6 +4891,10 @@ msgstr "耗时" msgid "Transfers" msgstr "传输" +#: html/cgi-bin/media.cgi +msgid "Written" +msgstr "写" + #: html/cgi-bin/memory.cgi msgid "Available" msgstr "可用" @@ -5344,14 +5344,6 @@ msgstr "bit" msgid "Broken Pipe" msgstr "Broken管道" -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Received" -msgstr "接收字节数" - -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Sent" -msgstr "发送字节数" - #: html/cgi-bin/ovpnmain.cgi html/cgi-bin/vpnmain.cgi msgid "CA Certificate:" msgstr "CA证书:" @@ -8175,8 +8167,8 @@ msgid "Cache Maintenance" msgstr "缓存维护" #: html/cgi-bin/updatexlrator.cgi -msgid "Cache Size (bytes)" -msgstr "缓存大小(bytes)" +msgid "Cache Size" +msgstr "缓存大小" #: html/cgi-bin/updatexlrator.cgi msgid "Cache Statistics" @@ -8191,8 +8183,8 @@ msgid "Current Files in Local Cache" msgstr "本地缓存中的当前文件" #: html/cgi-bin/updatexlrator.cgi -msgid "Data From Cache (bytes)" -msgstr "缓存中的数据(字节)" +msgid "Data From Cache" +msgstr "缓存中的数据" #: html/cgi-bin/updatexlrator.cgi src/squid-accounting/accounting.cgi #: src/squid-accounting/acct-lib.pl @@ -8328,12 +8320,12 @@ msgid "Three Months" msgstr "3个月" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Cache Size (bytes):" -msgstr "总缓存大小(bytes):" +msgid "Total Cache Size:" +msgstr "总缓存大小:" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Data Delivered From Cache (bytes):" -msgstr "从缓存传递的总数据(字节):" +msgid "Total Data Delivered From Cache:" +msgstr "从缓存传递的总数据:" #: html/cgi-bin/updatexlrator.cgi msgid "Total Files in Cache:" @@ -10951,3 +10943,9 @@ msgstr "" #: src/squid-accounting/acct-lib.pl msgid "VAT" msgstr "" + +#~ msgid "Bytes Received" +#~ msgstr "接收字节数" + +#~ msgid "Bytes Sent" +#~ msgstr "发送字节数" diff --git a/po/zh_TW.po b/po/zh_TW.po index b661cb074..6f0f12ec5 100644 --- a/po/zh_TW.po +++ b/po/zh_TW.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: IPFire\n" "Report-Msgid-Bugs-To: https://bugzilla.ipfire.org/\n" -"POT-Creation-Date: 2026-10-06 16:18+0000\n" +"POT-Creation-Date: 2026-10-08 16:03+0000\n" "Language-Team: Chinese (Traditional)\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" @@ -1231,13 +1231,13 @@ msgstr "備份於 %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s KB, date %s" -msgstr "備份於 %s 大小 %s KB 日期 %s" +msgid "Backup from %s, size %s" +msgstr "備份於 %s 大小 %s" #: html/cgi-bin/backup.cgi #, perl-format -msgid "Backup from %s, size %s MB" -msgstr "備份於 %s 大小 %s MB" +msgid "Backup from %s, size %s, date %s" +msgstr "備份於 %s 大小 %s 日期 %s" #: html/cgi-bin/backup.cgi msgid "Backups" @@ -4583,11 +4583,11 @@ msgstr "已斷開" msgid "Duration" msgstr "期間" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Received" msgstr "已收到" -#: html/cgi-bin/logs.cgi/ovpnclients.dat +#: html/cgi-bin/logs.cgi/ovpnclients.dat html/cgi-bin/ovpnmain.cgi msgid "Sent" msgstr "發送" @@ -4867,14 +4867,6 @@ msgstr "剩餘" msgid "Index-Nodes" msgstr "索引節點" -#: html/cgi-bin/media.cgi -msgid "MB Read" -msgstr "讀(MB)" - -#: html/cgi-bin/media.cgi -msgid "MB Written" -msgstr "寫(MB)" - #: html/cgi-bin/media.cgi msgid "Media Information" msgstr "硬碟信息" @@ -4883,6 +4875,10 @@ msgstr "硬碟信息" msgid "Mounted On" msgstr "掛載" +#: html/cgi-bin/media.cgi +msgid "Read" +msgstr "讀" + #: html/cgi-bin/media.cgi msgid "S.M.A.R.T. Information" msgstr "S.M.A.R.T. 信息" @@ -4895,6 +4891,10 @@ msgstr "耗時" msgid "Transfers" msgstr "傳輸" +#: html/cgi-bin/media.cgi +msgid "Written" +msgstr "寫" + #: html/cgi-bin/memory.cgi msgid "Available" msgstr "可用" @@ -5344,14 +5344,6 @@ msgstr "bit" msgid "Broken Pipe" msgstr "Broken管道" -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Received" -msgstr "接收字節數" - -#: html/cgi-bin/ovpnmain.cgi -msgid "Bytes Sent" -msgstr "發送字節數" - #: html/cgi-bin/ovpnmain.cgi html/cgi-bin/vpnmain.cgi msgid "CA Certificate:" msgstr "CA證書:" @@ -8175,8 +8167,8 @@ msgid "Cache Maintenance" msgstr "緩存維護" #: html/cgi-bin/updatexlrator.cgi -msgid "Cache Size (bytes)" -msgstr "緩存大小(bytes)" +msgid "Cache Size" +msgstr "緩存大小" #: html/cgi-bin/updatexlrator.cgi msgid "Cache Statistics" @@ -8191,8 +8183,8 @@ msgid "Current Files in Local Cache" msgstr "本地緩存中的當前文件" #: html/cgi-bin/updatexlrator.cgi -msgid "Data From Cache (bytes)" -msgstr "緩存中的數據(字節)" +msgid "Data From Cache" +msgstr "緩存中的數據" #: html/cgi-bin/updatexlrator.cgi src/squid-accounting/accounting.cgi #: src/squid-accounting/acct-lib.pl @@ -8328,12 +8320,12 @@ msgid "Three Months" msgstr "3個月" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Cache Size (bytes):" -msgstr "總緩存大小(bytes):" +msgid "Total Cache Size:" +msgstr "總緩存大小:" #: html/cgi-bin/updatexlrator.cgi -msgid "Total Data Delivered From Cache (bytes):" -msgstr "從緩存傳遞的總數據(字節):" +msgid "Total Data Delivered From Cache:" +msgstr "從緩存傳遞的總數據:" #: html/cgi-bin/updatexlrator.cgi msgid "Total Files in Cache:" @@ -10951,3 +10943,9 @@ msgstr "" #: src/squid-accounting/acct-lib.pl msgid "VAT" msgstr "" + +#~ msgid "Bytes Received" +#~ msgstr "接收字節數" + +#~ msgid "Bytes Sent" +#~ msgstr "發送字節數" diff --git a/src/squid-accounting/accounting.cgi b/src/squid-accounting/accounting.cgi index e9df4a485..7cd03163e 100755 --- a/src/squid-accounting/accounting.cgi +++ b/src/squid-accounting/accounting.cgi @@ -38,7 +38,7 @@ require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; require "${General::swroot}/accounting/acct-lib.pl"; -unless (-e "${General::swroot}/accounting/settings.conf") { system("touch ${General::swroot}/accounting/settings.conf"); } +unless (-e "${General::swroot}/accounting/settings.conf") { open(FILE, ">>${General::swroot}/accounting/settings.conf"); close(FILE); } my $settingsfile="${General::swroot}/accounting/settings.conf"; my $proxyenabled="${General::swroot}/proxy/enable"; @@ -722,11 +722,11 @@ sub expertsite{ #Get size of Databasefile my $sizedb= -s "/var/ipfire/accounting/acct.db"; - $sizedb = sprintf"%.2f", $sizedb/(1024*1024); + $sizedb = &General::format_bytes($sizedb); #Get size of Directory, where all bills are stored my $sizerrd = 0; find(sub { $sizerrd += -s if -f $_ }, "${General::swroot}/accounting/bill"); - $sizerrd = sprintf"%.2f", $sizerrd/(1024*1024); + $sizerrd = &General::format_bytes($sizerrd); &ACCT::connectdb; #Get latest and earliest entry of DB @@ -743,11 +743,11 @@ sub expertsite{ - + - + hooks/post-receive -- IPFire 2.x development tree
@{[ _(OpenVPN$devs_alt[$in]@{[ _(
@{[ _('Database Size') ]}$sizedb MB$sizedb
@{[ _('Size of Bill Directory') ]}$sizerrd MB$sizerrd
@{[ _('Fist DB Entry') ]}