diff options
| author | Johannes Truschnigg <johannes@truschnigg.info> | 2025-09-30 20:06:16 +0200 |
|---|---|---|
| committer | Florian Westphal <fw@strlen.de> | 2025-09-30 20:49:28 +0200 |
| commit | a7202b6caf9e96755152699c134b1a0ccc37c187 (patch) | |
| tree | f4a3d99d9684975b9ca095bbb23fa269451f0c1d | |
| parent | 87328a728b5a83e3ac17cdb0bcf2c390f959f2f8 (diff) | |
Also use a sane timestamp format (ISO 8601) in the output.
Signed-off-by: Johannes Truschnigg <johannes@truschnigg.info>
Signed-off-by: Florian Westphal <fw@strlen.de>
| -rw-r--r-- | ebtables-save.in | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/ebtables-save.in b/ebtables-save.in index 17924a2..4438050 100644 --- a/ebtables-save.in +++ b/ebtables-save.in @@ -7,11 +7,14 @@ # It can be used to store active configuration to /etc/sysconfig/ebtables use strict; +use POSIX qw(strftime); my $table; my $ebtables = "@sbindir@/ebtables"; my $cnt = ""; -my $version = "1.0"; +my $version = "1.1"; my $table_name; +my $modulesfh; +my @tables; # ======================================================== # Process filter table @@ -50,11 +53,21 @@ sub process_table { # ======================================================== unless (-x $ebtables) { exit -1 }; -print "# Generated by ebtables-save v$version (legacy) on " . `date`; + +open $modulesfh, '<', '/proc/modules' or die "Failed to open /proc/modules: $!"; +while( my $line = <$modulesfh>) { + if($line =~ /^ebtable_([^ ]+)/) { + push @tables, $1; + } +} +close $modulesfh; + +printf("# Generated by ebtables-save v$version (legacy) on %s\n", strftime("%a %FT%TZ", gmtime)); if (defined($ENV{'EBTABLES_SAVE_COUNTER'}) && $ENV{'EBTABLES_SAVE_COUNTER'} eq "yes") { $cnt = "--Lc"; } -foreach $table_name (split("\n", `grep -E '^ebtable_' /proc/modules | cut -f1 -d' ' | sed s/ebtable_//`)) { + +foreach $table_name (@tables) { $table =`$ebtables -t $table_name -L $cnt`; unless ($? == 0) { print $table; exit -1 }; &process_table($table); |
