if (defined $gid_file){
open GIDFILE, “<$gid_file” or die $!;
while (<GIDFILE>){
my $line = $_;
if ($line =~ /(\S+)\s+(\S+)\s*/){
my $gid = $1;
my $group = $2;
while($ent = getgrent()){
my $ent_name = $ent->name;
my $ent_gid = $ent->gid;
if ($ent_gid == $gid){
if ($ent_name ne $group){
print “### Error, Group in
gid_file file ($group, GID: $gid)”;
print “ conflicts with group
on system ($ent_name, GID: $ent_gid)\n”;
print “### Exiting program,
please fix and rerun\n”;
exit 2;
}
}
}
endgrent();
}
}
close GIDFILE;
}
if (defined $uid_file){
open UIDFILE, “<$uid_file” or die $!;
while (<UIDFILE>){
my $line = $_;
if ($line =~ /(\S+)\s+(\S+)\s*/){
my $uid = $1;
my $name = $2;
while($ent = getpwent()){
my $ent_name = $ent->name;
my $ent_uid = $ent->uid;
if ($ent_uid == $uid){
if ($ent_name ne $name){
print “### Error, User in
uid_file file ($name, UID: $uid)”;
print “conflicts with user on
system ($ent_name, UID: $ent_uid)\n”;
print “### Exiting program,
please fix and rerun\n”;
exit 2;
}
}
}
endpwent();
}
}
close UIDFILE;
}
if (defined $gid_file){ print “\n### Commands to update Groups
###\n\n”;
open GIDFILE, “<$gid_file” or die $!;
while (<GIDFILE>){
my $line = $_;
chomp($line);
if ($line =~ /(\S+)\s+(\S+)\s*/){
my $newgid = $1;
my $group = $2; my $return = system(“lsgroup $group
>/dev/null 2>&1”);
if ($return == 0) {
my $oldgid = `lsgroup -a id
$group | cut -f 2 -d =`;
chomp($oldgid);if ($oldgid != $newgid){
print “chgroup id=$newgid
$group\n”;
while($ent = getpwent()){
my $ent_user = $ent->name;
my $ent_gid = $ent->gid; if ($ent_gid == $oldgid){
print “chuser pgrp=$group $ent_user \n”;
}
}
endpwent();
print “find / -group $oldgid
-exec chgrp -h $group {} \\;\n”;
}
}
}
}
close GIDFILE;
}
if (defined $uid_file){
print “\n### Commands to update Users
###\n\n”;
open UIDFILE, “<$uid_file” or die $!;
while (<UIDFILE>){
my $line = $_;
chomp($line);
if ($line =~ /(\S+)\s+(\S+)\s*/){
my $newuid = $1;
my $user = $2;
my $return = system(“lsuser $user
>/dev/null 2>&1”);
if ($return == 0) {
my $olduid = `lsuser -a id $user
| cut -f 2 -d =`;
chomp($olduid);