#!/usr/local/bin/perl # user_chooser.cgi # This CGI generated the HTML for choosing a user or list of users. BEGIN { push(@INC, ".."); }; use WebminCore; $trust_unknown_referers = 1; &init_config(); if (&get_product_name() eq 'usermin') { &switch_to_remote_user(); } &ReadParse(undef, undef, 2); %access = &get_module_acl(); if ($in{'multi'}) { # selecting multiple users. if ($in{'frame'} == 0) { # base frame &PrintHeader(); print "\n"; print "$text{'users_title1'}\n"; print "\n"; print "\n"; print "\n"; print " \n"; print " \n"; print "\n"; print "\n"; } elsif ($in{'frame'} == 1) { # list of all users to choose from &popup_header(); print "\n"; print "$text{'users_all'}\n"; print "\n"; foreach $u (&get_users_list()) { if ($in{'user'} eq $u->[0]) { print "\n"; } else { print "\n"; } $u->[6] =~ s/'/'/g; print "\n"; print "\n"; } print "
$u->[0]$u->[6]
\n"; &popup_footer(); } elsif ($in{'frame'} == 2) { # show chosen users &popup_header(); print "$text{'users_sel'}\n"; print <<'EOF';
EOF &popup_footer(); } elsif ($in{'frame'} == 3) { # output OK and Cancel buttons &popup_header(); print "\n"; print "
\n"; print "\n"; print "\n"; print "  \n"; print "
\n"; &popup_footer(); } } else { # selecting just one user .. display a list of all users to choose from &popup_header($text{'users_title2'}); print "\n"; print "\n"; foreach $u (&get_users_list()) { if ($in{'user'} eq $u->[0]) { print "\n"; } else { print "\n"; } print "\n"; print "\n"; } print "
$u->[0]$u->[6]
\n"; &popup_footer(); } sub get_users_list { local(@uinfo, @users, %ucan, %found); if ($access{'uedit_mode'} == 2 || $access{'uedit_mode'} == 3) { map { $ucan{$_}++ } split(/\s+/, $access{'uedit'}); } setpwent(); while(@uinfo = getpwent()) { if ($access{'uedit_mode'} == 5 && $access{'uedit'} !~ /^\d+$/) { # Get group for matching by group name @ginfo = getgrgid($uinfo[3]); } if ($access{'uedit_mode'} == 0 || $access{'uedit_mode'} == 2 && $ucan{$uinfo[0]} || $access{'uedit_mode'} == 3 && !$ucan{$uinfo[0]} || $access{'uedit_mode'} == 4 && (!$access{'uedit'} || $uinfo[2] >= $access{'uedit'}) && (!$access{'uedit2'} || $uinfo[2] <= $access{'uedit2'}) || $access{'uedit_mode'} == 5 && ($access{'uedit'} =~ /^\d+$/ && $uinfo[3] == $access{'uedit'} || $ginfo[0] eq $access{'uedit'})) { push(@users, [ @uinfo ]) if (!$found{$uinfo[0]}++); } } endpwent() if ($gconfig{'os_type'} ne 'hpux'); return sort { $a->[0] cmp $b->[0] } @users; }