From: Shannon Sterz <s.sterz@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [PATCH pmg-api 1/2] pam/pmg realm: use yescrypt for new password hashes
Date: Wed, 21 Oct 2026 13:37:04 +0200 [thread overview]
Message-ID: <20261021113704.232095-3-s.sterz@proxmox.com> (raw)
In-Reply-To: <20261021113704.232095-2-s.sterz@proxmox.com>
and in the case of the pmg realm, update old stored hashes on
authentication. this should improve the security of passwords.
yescrypt is the default in Debian since the Bullseye release [1].
[1]: Section 5.1.4,
https://www.debian.org/releases/bullseye/amd64/release-notes.en.txt
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
Notes:
note that the change for pam also means that previously if a new
password for a pam user was set via the PVE API, the hash function
used for that password would effectively have been downgraded.
src/PMG/API2/Users.pm | 2 +-
src/PMG/AccessControl.pm | 2 +-
src/PMG/UserConfig.pm | 9 ++++++++-
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/PMG/API2/Users.pm b/src/PMG/API2/Users.pm
index e638ae8..a973653 100644
--- a/src/PMG/API2/Users.pm
+++ b/src/PMG/API2/Users.pm
@@ -118,7 +118,7 @@ __PACKAGE__->register_method({
foreach my $k (keys %$param) {
my $v = $param->{$k};
if ($k eq 'password') {
- $entry->{crypt_pass} = PVE::Tools::encrypt_pw($v);
+ $entry->{crypt_pass} = PVE::Tools::encrypt_pw($v, "y");
} else {
$entry->{$k} = $v;
}
diff --git a/src/PMG/AccessControl.pm b/src/PMG/AccessControl.pm
index f4ac743..6fa89de 100644
--- a/src/PMG/AccessControl.pm
+++ b/src/PMG/AccessControl.pm
@@ -103,7 +103,7 @@ sub set_user_password {
my $cmd = ['usermod'];
- my $epw = PVE::Tools::encrypt_pw($password);
+ my $epw = PVE::Tools::encrypt_pw($password, "y");
push @$cmd, '-p', $epw, $ruid;
diff --git a/src/PMG/UserConfig.pm b/src/PMG/UserConfig.pm
index 5ee7333..b2ef417 100644
--- a/src/PMG/UserConfig.pm
+++ b/src/PMG/UserConfig.pm
@@ -19,6 +19,7 @@ my $config_filename = '/etc/pmg/user.conf';
my $tfa_inotify_file_id = 'pmg-tfa.json';
my $tfa_config_filename = '/etc/pmg/tfa.json';
+my $hash_prefix = "y";
sub new {
my ($type) = @_;
@@ -351,6 +352,12 @@ sub authenticate_user {
if ($data->{crypt_pass}) {
my $encpw = crypt($password, $data->{crypt_pass});
die "invalid credentials\n" if ($encpw ne $data->{crypt_pass});
+
+ # If the password was stored with a different hash function than the currently configured
+ # one, update it here.
+ if ($data->{crypt_pass} !~ m/^\$${hash_prefix}\$/) {
+ store_password($class, $config, $realm, $username, $password);
+ }
} else {
die "no password set\n";
}
@@ -364,7 +371,7 @@ sub set_user_password {
lock_config(sub {
my $cfg = $class->new();
my $data = $cfg->lookup_user_data($username); # user exists
- my $epw = PVE::Tools::encrypt_pw($password);
+ my $epw = PVE::Tools::encrypt_pw($password, $hash_prefix);
$data->{crypt_pass} = $epw;
$cfg->write();
});
--
2.47.3
next prev parent reply other threads:[~2026-10-21 11:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 11:37 [PATCH docs/pmg-api 0/2] Update default password hash function to yescrypt Shannon Sterz
2026-10-21 11:37 ` Shannon Sterz [this message]
2026-10-21 11:37 ` [PATCH docs 2/2] pmgconfig: document that the pmg realm now uses yescrypt Shannon Sterz
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=20261021113704.232095-3-s.sterz@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=pmg-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.