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 0BDFC6972A for ; Tue, 19 Jan 2021 10:10:41 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EEF191BAB7 for ; Tue, 19 Jan 2021 10:10:10 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id D47CA1BAA7 for ; Tue, 19 Jan 2021 10:10:09 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A0B4446071 for ; Tue, 19 Jan 2021 10:10:09 +0100 (CET) To: Stoiko Ivanov Cc: pmg-devel@lists.proxmox.com References: <20201230171539.7644-1-s.ivanov@proxmox.com> <20201230171539.7644-3-s.ivanov@proxmox.com> <5c086b1d-86f6-77e2-1f44-302656162535@proxmox.com> <20210118204756.2ac6db0e@rosa.proxmox.com> From: Thomas Lamprecht Message-ID: Date: Tue, 19 Jan 2021 10:10:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:85.0) Gecko/20100101 Thunderbird/85.0 MIME-Version: 1.0 In-Reply-To: <20210118204756.2ac6db0e@rosa.proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.067 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.001 Looks like a legit reply (A) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pmg-devel] [PATCH pmg-api v2 2/4] api: spamassassin: read local channels 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: Tue, 19 Jan 2021 09:10:41 -0000 On 18.01.21 20:47, Stoiko Ivanov wrote: >>> + my $check_channel = sub { >>> + my ($channel) = @_; >>> + >>> + # see sa-update source: >>> + my $channel_file_base = $channel; >>> + $channel_file_base =~ s/[^A-Za-z0-9-]+/_/g; >>> + my $channelfile = "${sa_update_dir}${channel_file_base}.cf"; >>> + >>> + my $mtime = -1; >>> + my $version = -1; > $version gets initialized to -1 here... >>> + my $newversion = -1; >>> + >>> + if (-f $channelfile) { >>> + # stat metadata cf file >>> + $mtime = (stat($channelfile))[9]; # 9 is mtime >>> + >>> + # parse version from metadata cf file >>> + my $metadata = PVE::Tools::file_read_firstline($channelfile); >>> + if ($metadata =~ m/\s([0-9]+)$/) { >>> + $version = $1; >>> + } else { >>> + warn "invalid metadata in '$channelfile'\n"; >> I know it was already there, but this mayresults in a undef comparison >> when checking `if ($newversion > $version) {` below. >> I'd do a separate followup with that being fixed, e.g., by either prepending the >> if check with a `!defined($version) || ...` check or setting it to -1000 or so. > so it should not be undefined if the metadata is not matching? > (I quickly tested in on my system - and if I drop the -1 I get a undef > comparison in the logs - but it works as is) > or am I missing something? > Ok, my bad then - sorry!