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 293E46B67F for ; Wed, 17 Mar 2021 11:02:21 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1BCC12BD17 for ; Wed, 17 Mar 2021 11:02:21 +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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 1B44A2BCF9 for ; Wed, 17 Mar 2021 11:02:20 +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 D9ECF4038F for ; Wed, 17 Mar 2021 11:02:19 +0100 (CET) From: Wolfgang Bumiller To: pmg-devel@lists.proxmox.com Date: Wed, 17 Mar 2021 11:02:14 +0100 Message-Id: <20210317100216.8008-3-w.bumiller@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210317100216.8008-1-w.bumiller@proxmox.com> References: <20210317100216.8008-1-w.bumiller@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.029 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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: [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:02:21 -0000 Signed-off-by: Wolfgang Bumiller --- src/PMG/API2/ACME.pm | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) 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; + } 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 ({ -- 2.20.1