Since we have both userid and username in the schema and
both have a minimum length of 4, creating a user named 'foo'
was previously possible because the 'username' property was
not checked. Loading the file back in then failed because at
load time, the username 'foo' was too short.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
my ($entry) = @_;
my $errors = {};
+ my $userid = $entry->{userid};
+ if (defined(my $username = $entry->{username})) {
+ if ($userid !~ /^\Q$username\E\@/) {
+ $errors->{'username'} = 'invalid username for userid';
+ }
+ } else {
+ # make sure the username's length is checked
+ $entry->{username} = ($userid =~ s/\@.*$//r);
+ }
PVE::JSONSchema::check_prop($entry, $schema, '', $errors);
if (scalar(%$errors)) {
raise "verify entry failed\n", errors => $errors;