From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 4307BC6A1 for ; Fri, 7 Jul 2023 18:55:12 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2BC4E2BB25 for ; Fri, 7 Jul 2023 18:54:42 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 7 Jul 2023 18:54:40 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9815E40D28 for ; Fri, 7 Jul 2023 18:54:40 +0200 (CEST) From: Stoiko Ivanov To: pmg-devel@lists.proxmox.com Date: Fri, 7 Jul 2023 18:54:27 +0200 Message-Id: <20230707165428.94777-4-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230707165428.94777-1-s.ivanov@proxmox.com> References: <20230707165428.94777-1-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.094 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [report.pm] Subject: [pmg-devel] [PATCH pmg-api 3/4] report: skip irrelevant files in /etc/pmg/templates X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Jul 2023 16:55:12 -0000 This patch removes: * templates which have no changes to the ones in /var/lib/pmg/templates * files generated by ucf from the report. Unmodified files are reported, so that the user can remove them. This should make providing support a bit easier - as currenlty I'd copy each template from the report to `diff` it with the version in the package, for finding out if there is something relevant. the new dump_template sub was copied from dir_to_text, in order to explicitly write which files are skipped. Signed-off-by: Stoiko Ivanov --- src/PMG/Report.pm | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/PMG/Report.pm b/src/PMG/Report.pm index 027c882..b3a554c 100644 --- a/src/PMG/Report.pm +++ b/src/PMG/Report.pm @@ -5,6 +5,8 @@ use warnings; use PVE::Tools; use Mail::SpamAssassin::DnsResolver; +use PMG::Utils; + $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin'; my $cmd_timeout = 10; # generous timeout @@ -46,7 +48,7 @@ my $report_def = { 'pmgconfig dump', sub { dir2text('/etc/pmg/','(?:domains|mynetworks|tls_policy|transport)' ) }, sub { dir2text('/etc/postfix/','(?:clientaccess|senderaccess|rcptaccess)' ) }, - sub { dir2text('/etc/pmg/templates/', '[^.].*' ) }, + sub { dump_templates() }, 'pmgdb dump', ], }; @@ -135,4 +137,26 @@ sub check_dns_resolution { $report .= $answertext . "\n"; } +sub dump_templates { + + my $unmodified = PMG::Utils::find_unmodified_templates(); + my $unmodified_re; + if ($unmodified) { + $report .= "\n unmodified templates:\n "; + $report .= join("\n ", $unmodified->@*); + $unmodified_re = '(?:'.join('|', $unmodified->@*) .')'; + } + + my $template_dir = '/etc/pmg/templates/'; + PVE::Tools::dir_glob_foreach($template_dir, '[^.].*', sub { + my ($file) = @_; + if ($file =~ /\.ucf-(?:dist|new|old)/) { + $report .= "\n skipping $file"; + } elsif (!defined($unmodified_re) || $file !~ qr/$unmodified_re$/) { + $report .= "\n# cat $template_dir$file\n"; + $report .= PVE::Tools::file_get_contents($template_dir.$file)."\n"; + } + }); +} + 1; -- 2.39.2