Default failure with Group for Mailbox users / Group for Unix user

This is a continuaiton from bug #25 -
Script domain_setup.cgi - problem with

If user selects a custom Unix User Name then that will also be used for Mailgroup and Unix Group. The problem is located at the "if ($in{'mgroup_def'})". The default condition of mgroup_def == 1 invokes the "$group = $user" statement, however it should really use the same logic as the "if ($in{'vuser_def'})"

My guess is the fix for the TRUE condition of "if ($in{'mgroup_def'})" would be something like-

($user_mg, $try1, $try2) = &unixuser_name($in{'dom'});
$user_mg || &error(&text('setup_eauto', $try1, $try2));
$group = $user_mg;

SNIP of original domain_setup.cgi***
if ($in{'vuser_def'}) {
($user, $try1, $try2) = &unixuser_name($in{'dom'});
$user || &error(&text('setup_eauto', $try1, $try2));
}
else {
$in{'vuser'} = lc($in{'vuser'});
$user = $in{'vuser'};
$user =~ /^[^\t :]+$/ || &error($text{'setup_euser2'});
defined(getpwnam($user)) && &error($text{'setup_euser'});
}
if ($in{'mgroup_def'}) {
$group = $user;
}
else {
$in{'mgroup'} = lc($in{'mgroup'});
$group = $in{'mgroup'};
$group =~ /^[^\t :]+$/ || &error($text{'setup_egroup2'});
}
if (!$in{'group_def'} && &can_choose_ugroup()) {
$in{'group'} = lc($in{'group'});
$in{'group'} eq $group && &error(&text('setup_egroup3', $group));
local ($sg) = &get_domain_by("group", $in{'group'});
$sg && &error(&text('setup_egroup4', $sg->{'dom'}));
}
*** SNIP

This seems like the right fix, however maybe there's a more elegant way. I got stumped on exactly how to fix the same issue with the group_def section.

I hope this helps., Mark.

Status: 
Closed (fixed)