Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 8509 - additional machine account not created on cluster when copy-paste domain config file #8512

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions lib/pf/UnifiedApi/Controller/Config/Domains.pm
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ sub create {
$real_computer_name = $s[0];
}

if (length($real_computer_name) > 19) {
return $self->render_error(422, "Invalid machine account length, maximum 20 characters (including ending\$ sign)")
}

my $ad_server_host = "";
my $ad_server_ip = "";

Expand Down Expand Up @@ -193,9 +197,12 @@ sub create {
}

if (!is_nt_hash_pattern($computer_password)) {
my @real_computer_names =($real_computer_name);
if ($additional_machine_accounts +0 > 0) {
for my $i (0..$additional_machine_accounts) {
my @real_computer_names = ($real_computer_name);
if ($additional_machine_accounts + 0 > 0) {
for my $i (0 .. $additional_machine_accounts - 1) {
if (length("$real_computer_name-$i") > 19) {
return $self->render_error(422, "In order to create additional machine accounts, the base computer account is limited to maximum 16 characters. currently using '$real_computer_name', " + length($real_computer_name), " characters.")
}
push(@real_computer_names, "$real_computer_name-$i");
}
}
Expand Down Expand Up @@ -282,6 +289,10 @@ sub update {
$real_computer_name = $s[0];
}

if (length($real_computer_name) > 19) {
return $self->render_error(422, "Invalid machine account length, maximum 20 characters (including ending\$ sign)")
}

my $ad_server_host = "";
my $ad_server_ip = "";

Expand Down Expand Up @@ -312,14 +323,17 @@ sub update {

my @real_computer_names = ($real_computer_name);

if ($additional_machine_accounts +0 > 0) {
for my $i (0..$additional_machine_accounts) {
if ($additional_machine_accounts + 0 > 0) {
for my $i (0 .. $additional_machine_accounts - 1) {
if (length("$real_computer_name-$i") > 19) {
return $self->render_error(422, "In order to create additional machine accounts, the base computer account is limited to maximum 16 characters. currently using '$real_computer_name', " + length($real_computer_name), " characters.")
}
push(@real_computer_names, "$real_computer_name-$i");
}
}
for (my $i = 0; $i < @real_computer_names; $i++) {
$real_computer_name = $real_computer_names[$i];
if (!is_nt_hash_pattern($new_data->{machine_account_password}) && ($new_data->{machine_account_password} ne $old_item->{machine_account_password})) {
if (!is_nt_hash_pattern($new_data->{machine_account_password})) {
my ($add_status, $add_result) = pf::domain::add_computer("-delete", $real_computer_name, $computer_password, $ad_server_ip, $ad_server_host, $dns_name, $workgroup, $ou, $bind_dn, $bind_pass);
if ($add_status == $FALSE) {
unless ($add_result =~ /Account (.+) not found in/) {
Expand All @@ -342,7 +356,6 @@ sub update {
}
}


$new_data->{server_name} = $computer_name;
delete $new_data->{id};
delete $new_data->{bind_dn};
Expand Down