#!/usr/local/bin/perl # edit_unix.cgi # Map Unix users that do not have Webmin accounts to a Webmin user whose # access rights and authentication method will be used for their logins. use strict; use warnings; no warnings 'redefine'; no warnings 'uninitialized'; require './acl-lib.pl'; ## no critic our (%in, %text, %config, %access); $access{'unix'} && $access{'create'} && $access{'delete'} || &error($text{'unix_ecannot'}); &ui_print_header(undef, $text{'unix_title'}, ""); print "$text{'unix_desc'}
\n";
my %miniserv;
&get_miniserv_config(\%miniserv);
print &ui_form_start("save_unix.cgi", "post");
print &ui_table_start($text{'unix_header'}, undef, 2);
# Configure Unix login mappings
my @unixauth = &get_unixauth(\%miniserv);
my $utable = "";
$utable .= &ui_radio("unix_def", @unixauth ? 0 : 1,
[ [ 1, $text{'unix_def'} ], [ 0, $text{'unix_sel'} ] ])."
\n";
$utable .= &ui_columns_start([ $text{'unix_mode'}, $text{'unix_who'},
$text{'unix_to'} ]);
my $i = 0;
my @webmins = map {
my $auth = $_->{'pass'} eq 'x' ? $text{'edit_unix'} :
$_->{'pass'} eq 'e' ? $text{'edit_extauth'} :
$_->{'pass'} eq '*LK*' || $_->{'pass'} =~ /^!/ ?
$text{'edit_lock'} : $text{'unix_webminpass'};
[ $_->{'name'}, "$_->{'name'} ($auth)" ]
} sort { $a->{'name'} cmp $b->{'name'} } &list_users();
foreach my $ua (@unixauth, [ ], [ ]) {
$utable .= &ui_columns_row([
&ui_select("mode_$i", !defined($ua->[0]) ? 0 :
$ua->[0] eq "" ? 0 :
$ua->[0] eq "*" ? 1 :
$ua->[0] =~ /^\@/ ? 2 : 3,
[ [ 0, " " ],
[ 1, $text{'unix_mall'} ],
[ 2, $text{'unix_group'} ],
[ 3, $text{'unix_user'} ] ]),
&ui_textbox("who_$i", $ua->[0] eq "*" || $ua->[0] eq "" ? "" :
$ua->[0] =~ /^\@(.*)$/ ? $1 : $ua->[0], 20),
&ui_select("to_$i", $ua->[1], \@webmins),
]);
$i++;
}
$utable .= &ui_columns_end();
$utable .= "
".&ui_note($text{'unix_mapdesc'}, 0)."
\n"; print &ui_table_row($text{'unix_utable'}, $utable); # Allow users who can sudo to root? print &ui_table_row("", &ui_checkbox("sudo", 1, $text{'unix_sudo'}, $miniserv{'sudo'})); # Allow PAM-only users? print &ui_table_row("", &ui_checkbox("pamany", 1, &text('unix_pamany', &ui_select("pamany_user", $miniserv{'pamany'}, \@webmins)), $miniserv{'pamany'})); print &ui_table_hr(); # Who can do Unix auth? my $users = $miniserv{"allowusers"} ? join("\n", split(/\s+/, $miniserv{"allowusers"})) : $miniserv{"denyusers"} ? join("\n", split(/\s+/, $miniserv{"denyusers"})) : ""; print &ui_table_row($text{'unix_restrict2'}, &ui_radio("access", $miniserv{"allowusers"} ? 1 : $miniserv{"denyusers"} ? 2 : 0, [ [ 0, $text{'unix_all'} ], [ 1, $text{'unix_allow'} ], [ 2, $text{'unix_deny'} ] ])."