From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH access-control 1/1] implement version checks for tfa
Date: Wed, 10 Nov 2021 15:11:45 +0100 [thread overview]
Message-ID: <20211110141146.210803-2-w.bumiller@proxmox.com> (raw)
In-Reply-To: <20211110141146.210803-1-w.bumiller@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
---
src/PVE/AccessControl.pm | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/src/PVE/AccessControl.pm b/src/PVE/AccessControl.pm
index cbf643d..f39ac9c 100644
--- a/src/PVE/AccessControl.pm
+++ b/src/PVE/AccessControl.pm
@@ -1581,8 +1581,8 @@ sub parse_priv_tfa_config {
sub write_priv_tfa_config {
my ($filename, $cfg) = @_;
- # FIXME: Only allow this if the complete cluster has been upgraded to understand the json
- # config format.
+ assert_new_tfa_config_available();
+
return $cfg->write();
}
@@ -1765,7 +1765,31 @@ my $USER_CONTROLLED_TFA_TYPES = {
};
sub assert_new_tfa_config_available() {
- # FIXME: Assert cluster-wide new-tfa-config support!
+ PVE::Cluster::cfs_update();
+ my $version_info = PVE::Cluster::get_node_kv('version-info');
+ die "cannot update tfa config, please make sure all cluster nodes are up to date\n"
+ if !$version_info;
+ my $members = PVE::Cluster::get_members();
+ my $old = '';
+ foreach my $node (keys $members->%*) {
+ my $info = $version_info->{$node};
+ if (!$info) {
+ $old .= "cluster node '$node' is too old, did not broadcast its version info\n";
+ next;
+ }
+ $info = from_json($info);
+ my $ver = $info->{version};
+ if ($ver !~ /^(\d+\.\d+)-(\d+)$/) {
+ $old .= "cluster node '$node' provided an invalid version string: '$ver'\n";
+ next;
+ }
+ my ($maj, $rel) = ($1, $2);
+ if (!($maj > 7.0 || ($maj == 7.0 && $rel >= 15))) {
+ $old .= "cluster node '$node' is too old\n";
+ next;
+ }
+ }
+ die $old if length($old);
}
sub user_remove_tfa : prototype($) {
--
2.30.2
next prev parent reply other threads:[~2021-11-10 14:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-10 14:11 [pve-devel] [PATCH access-control + manager] version check for tfa.cfg update Wolfgang Bumiller
2021-11-10 14:11 ` Wolfgang Bumiller [this message]
2021-11-11 16:00 ` [pve-devel] applied: [PATCH access-control 1/1] implement version checks for tfa Thomas Lamprecht
2021-11-10 14:11 ` [pve-devel] [PATCH manager] pvestatd: broadcast version info Wolfgang Bumiller
2021-11-10 20:46 ` [pve-devel] applied: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211110141146.210803-2-w.bumiller@proxmox.com \
--to=w.bumiller@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.