| … | |
… | |
| 281 | # in demo mode, the group is set to the user's primary group |
281 | # in demo mode, the group is set to the user's primary group |
| 282 | $groupName = $userGroupName; |
282 | $groupName = $userGroupName; |
| 283 | } else { |
283 | } else { |
| 284 | # in working mode, we get to chose |
284 | # in working mode, we get to chose |
| 285 | page($GROUP_TEXT); |
285 | page($GROUP_TEXT); |
| 286 | my $validGroup = 0; |
|
|
| 287 | while(1) { |
286 | while(1) { |
| 288 | $groupName = questionString("What is the admin group name?", $DEFAULT_ADMIN_GROUP); |
287 | $groupName = questionString("What is the admin group name?", $DEFAULT_ADMIN_GROUP); |
|
|
288 | my @group = getgrnam $groupName; |
|
|
289 | unless(@group) { |
|
|
290 | print "$groupName does not exist.\n"; |
|
|
291 | next; |
|
|
292 | } |
| 289 | my @members = split / /, (getgrnam $groupName)[3]; |
293 | my @members = split / /, $group[3]; |
| 290 | if($groupName eq $userGroupName) { |
294 | if($groupName eq $userGroupName) { |
| 291 | print "$groupName is ${userName}'s primary group. Good.\n"; |
295 | print "$groupName is ${userName}'s primary group. Good.\n"; |
|
|
296 | last; |
| 292 | } elsif(grep /$userName/, @members) { |
297 | } elsif(grep { $_ eq $userName } @members) { |
| 293 | print "$userName is a member of $groupName. Good.\n"; |
298 | print "$userName is a member of $groupName. Good.\n"; |
| 294 | last; |
299 | last; |
| 295 | } elsif($< == 0) { # we're root! |
300 | } elsif($< == 0) { # we're root! |
| 296 | print "$userName isn't a member of $groupName, but you're root, so who cares?\n"; |
301 | print "$userName isn't a member of $groupName, but you're root, so who cares?\n"; |
| 297 | last; |
302 | last; |
| 298 | } else { |
303 | } else { |
| 299 | print "That group is not valid. Please make sure the group exists and you are a member.\n"; |
304 | print "$groupName is not a valid group. Please make sure the group exists and $userName are a member.\n"; |
| 300 | } |
305 | } |
| 301 | } |
306 | } |
| 302 | } |
307 | } |
| 303 | } |
308 | } |
| 304 | print "Admin group is: $groupName\n"; |
309 | print "Admin group is: $groupName\n"; |