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 D01836B745 for ; Wed, 17 Mar 2021 11:33:58 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C16DF2C2A6 for ; Wed, 17 Mar 2021 11:33:58 +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 416CA2C299 for ; Wed, 17 Mar 2021 11:33:58 +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 123644273E for ; Wed, 17 Mar 2021 11:33:58 +0100 (CET) Message-ID: <47566280-fade-6a5c-6ad8-a6b1b3bdb4ce@proxmox.com> Date: Wed, 17 Mar 2021 11:33:57 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:87.0) Gecko/20100101 Thunderbird/87.0 Content-Language: en-US To: Wolfgang Bumiller , pmg-devel@lists.proxmox.com References: <20210317100216.8008-1-w.bumiller@proxmox.com> <20210317100216.8008-3-w.bumiller@proxmox.com> From: Thomas Lamprecht In-Reply-To: <20210317100216.8008-3-w.bumiller@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.046 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [acme.pm] Subject: Re: [pmg-devel] [PATCH api 2/4] support forced account deactivation 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: Wed, 17 Mar 2021 10:33:58 -0000 On 17.03.21 11:02, Wolfgang Bumiller wrote: > Signed-off-by: Wolfgang Bumiller > --- > src/PMG/API2/ACME.pm | 27 ++++++++++++++++++++++----- > 1 file changed, 22 insertions(+), 5 deletions(-) > applied, thanks - squashed one change into it though. > diff --git a/src/PMG/API2/ACME.pm b/src/PMG/API2/ACME.pm > index 60b5986..d6dbf2f 100644 > --- a/src/PMG/API2/ACME.pm > +++ b/src/PMG/API2/ACME.pm > @@ -173,7 +173,7 @@ __PACKAGE__->register_method ({ > }}); > > my $update_account = sub { > - my ($param, $msg, %info) = @_; > + my ($param, $msg, $force_deactivate, %info) = @_; > > my ($account_name, $account_file) = extract_account_name($param); > > @@ -190,7 +190,15 @@ my $update_account = sub { > if ! -e $account_file; > > my $acme = PMG::RS::Acme->load($account_file); > - $acme->update_account(\%info); > + eval { > + $acme->update_account(\%info); > + }; > + my $err = $@; > + if ($force_deactivate) { > + warn $err if $err; > + } else { > + die $2; fixed up above typo and logic > + } > if ($info{status} && $info{status} eq 'deactivated') { > my $deactivated_name; > for my $i (0..100) { > @@ -239,9 +247,9 @@ __PACKAGE__->register_method ({ > > my $contact = $account_contact_from_param->($param); > if (scalar @$contact) { > - return $update_account->($param, 'update', contact => $contact); > + return $update_account->($param, 'update', 0, contact => $contact); > } else { > - return $update_account->($param, 'refresh'); > + return $update_account->($param, 'refresh', 0); > } > }}); > > @@ -311,6 +319,13 @@ __PACKAGE__->register_method ({ > additionalProperties => 0, > properties => { > name => get_standard_option('pmg-acme-account-name'), > + force => { > + type => 'boolean', > + description => > + 'Delete account data even if the server refuses to deactivate the account.', > + optional => 1, > + default => 0, > + }, > }, > }, > returns => { > @@ -319,7 +334,9 @@ __PACKAGE__->register_method ({ > code => sub { > my ($param) = @_; > > - return $update_account->($param, 'deactivate', status => 'deactivated'); > + my $force_deactivate = extract_param($param, 'force'); > + > + return $update_account->($param, 'deactivate', $force_deactivate, status => 'deactivated'); > }}); > > __PACKAGE__->register_method ({ >