mirror of
https://github.com/Cacti/cacti.git
synced 2026-11-30 04:09:20 +09:00
* fix(scripts): fail closed in data input scripts and keep cactigetOIDs secrets private Rejected arguments now return U instead of an unfiltered count, the Motorola script is executable and reports errors on stderr, and cactigetOIDs reads credentials from a private defaults file. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix(service): make cactid's environment file optional and widen the fail2ban dates The unit failed on systems without /etc/sysconfig/cactid, and the fail2ban filter only parsed the default Y-m-d log date. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix: guard log/.htaccess file rules for Apache 2.4 and trim the release archive Bare Order/Deny blocks returned 500 without mod_access_compat, and git archive shipped dev-only configuration. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * hardening(scripts): validate arguments and bound remote input in data input scripts The Motorola script accepts only a bare host and port, refuses redirects, caps response size and time and passes through only numeric values; diskfree.sh and the PO validator end option parsing before their arguments. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * hardening(contrib): skip invalid agent hostnames in cactigetOIDs Hosts whose name starts with '-' or contains whitespace are skipped with a warning, and snmpget now receives '--' before the agent and OID. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * docs(changelog): add fragment for #8447 Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix(scripts): fail closed on an invalid loadavg.pl selector An argument that is not a number left the selector undefined, so the script printed all three averages with exit 0 and warned three times on stderr. Print U and exit 1 instead, as the other data input scripts do. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix: enforce the modem fetch deadline during blocked reads Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> --------- Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
41 lines
952 B
Perl
41 lines
952 B
Perl
#!/usr/bin/env perl
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
delete @ENV{qw(PATH)};
|
|
$ENV{PATH} = '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin';
|
|
|
|
|
|
my $path = $ARGV[0] // '';
|
|
if ($path ne '') {
|
|
# A path that fails validation must not fall through to listing every
|
|
# filesystem. A leading '-' would also be read by df as an option.
|
|
($path) = $path =~ /^([\w.\/][\w.\/-]*)$/;
|
|
if (!defined $path) {
|
|
print 'megabytes:U percent:U';
|
|
exit 1;
|
|
}
|
|
}
|
|
|
|
# POSIX df: -k with -P reports 1024-byte blocks on GNU, BSD, macOS and
|
|
# busybox alike, matching the GNU-only --block-size=1024 used before.
|
|
my @dfcmd = ('df', '-k', '-P');
|
|
|
|
if ($path ne '') {
|
|
push @dfcmd, $path;
|
|
}
|
|
|
|
open(my $process, '-|', @dfcmd) or exit 1;
|
|
while (my $line = <$process>) {
|
|
chomp($line);
|
|
next if $line =~ /^Filesystem\s+/;
|
|
if ($line =~ /^(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)%\s+(\S+)/) {
|
|
print "megabytes:$4 percent:$5";
|
|
if ($path ne '') {
|
|
last;
|
|
}
|
|
}
|
|
}
|
|
close($process);
|