mirror of
https://github.com/webmin/webmin.git
synced 2025-07-21 23:40:34 +00:00
Add missing module
This commit is contained in:
65
htpasswd-file/acl_security.pl
Normal file
65
htpasswd-file/acl_security.pl
Normal file
@ -0,0 +1,65 @@
|
||||
|
||||
require 'htpasswd-file-lib.pl';
|
||||
|
||||
# acl_security_form(&options)
|
||||
# Output HTML for editing security options for the passwd module
|
||||
sub acl_security_form
|
||||
{
|
||||
print "<tr> <td><b>$text{'acl_repeat'}</b></td> <td>\n";
|
||||
printf "<input type=radio name=repeat value=1 %s> $text{'yes'}\n",
|
||||
$_[0]->{'repeat'} ? "checked" : "";
|
||||
printf "<input type=radio name=repeat value=0 %s> $text{'no'}</td>\n",
|
||||
$_[0]->{'repeat'} ? "" : "checked";
|
||||
|
||||
print "<td><b>$text{'acl_create'}</b></td> <td>\n";
|
||||
printf "<input type=radio name=create value=1 %s> $text{'yes'}\n",
|
||||
$_[0]->{'create'} ? "checked" : "";
|
||||
printf "<input type=radio name=create value=0 %s> $text{'no'}</td> </tr>\n",
|
||||
$_[0]->{'create'} ? "" : "checked";
|
||||
|
||||
print "<tr> <td><b>$text{'acl_rename'}</b></td> <td>\n";
|
||||
printf "<input type=radio name=rename value=1 %s> $text{'yes'}\n",
|
||||
$_[0]->{'rename'} ? "checked" : "";
|
||||
printf "<input type=radio name=rename value=0 %s> $text{'no'}</td>\n",
|
||||
$_[0]->{'rename'} ? "" : "checked";
|
||||
|
||||
print "<td><b>$text{'acl_delete'}</b></td> <td>\n";
|
||||
printf "<input type=radio name=delete value=1 %s> $text{'yes'}\n",
|
||||
$_[0]->{'delete'} ? "checked" : "";
|
||||
printf "<input type=radio name=delete value=0 %s> $text{'no'}</td> </tr>\n",
|
||||
$_[0]->{'delete'} ? "" : "checked";
|
||||
|
||||
print "<tr> <td><b>$text{'acl_enable'}</b></td> <td>\n";
|
||||
printf "<input type=radio name=enable value=1 %s> $text{'yes'}\n",
|
||||
$_[0]->{'enable'} ? "checked" : "";
|
||||
printf "<input type=radio name=enable value=0 %s> $text{'no'}</td>\n",
|
||||
$_[0]->{'enable'} ? "" : "checked";
|
||||
|
||||
print "<td><b>$text{'acl_sync'}</b></td> <td>\n";
|
||||
printf "<input type=radio name=sync value=1 %s> $text{'yes'}\n",
|
||||
$_[0]->{'sync'} ? "checked" : "";
|
||||
printf "<input type=radio name=sync value=0 %s> $text{'no'}</td> </tr>\n",
|
||||
$_[0]->{'sync'} ? "" : "checked";
|
||||
|
||||
print "<tr> <td><b>$text{'acl_single'}</b></td> <td>\n";
|
||||
printf "<input type=radio name=single value=1 %s> $text{'yes'}\n",
|
||||
$_[0]->{'single'} ? "checked" : "";
|
||||
printf "<input type=radio name=single value=0 %s> $text{'no'}</td>\n",
|
||||
$_[0]->{'single'} ? "" : "checked";
|
||||
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
# acl_security_save(&options)
|
||||
# Parse the form for security options for the bind8 module
|
||||
sub acl_security_save
|
||||
{
|
||||
$_[0]->{'repeat'} = $in{'repeat'};
|
||||
$_[0]->{'create'} = $in{'create'};
|
||||
$_[0]->{'rename'} = $in{'rename'};
|
||||
$_[0]->{'delete'} = $in{'delete'};
|
||||
$_[0]->{'enable'} = $in{'enable'};
|
||||
$_[0]->{'sync'} = $in{'sync'};
|
||||
$_[0]->{'single'} = $in{'single'};
|
||||
}
|
||||
|
1
htpasswd-file/config
Normal file
1
htpasswd-file/config
Normal file
@ -0,0 +1 @@
|
||||
md5=0
|
2
htpasswd-file/config.info
Normal file
2
htpasswd-file/config.info
Normal file
@ -0,0 +1,2 @@
|
||||
file=HTPasswd format file to edit,0
|
||||
md5=Password encryption type,1,1-MD5,0-Crypt
|
7
htpasswd-file/defaultacl
Normal file
7
htpasswd-file/defaultacl
Normal file
@ -0,0 +1,7 @@
|
||||
repeat=0
|
||||
create=1
|
||||
rename=1
|
||||
sync=1
|
||||
enable=1
|
||||
single=0
|
||||
delete=1
|
82
htpasswd-file/edit.cgi
Executable file
82
htpasswd-file/edit.cgi
Executable file
@ -0,0 +1,82 @@
|
||||
#!/usr/local/bin/perl
|
||||
# edit.cgi
|
||||
# Display a form for editing or creating a htpasswd user
|
||||
|
||||
require './htpasswd-file-lib.pl';
|
||||
&ReadParse();
|
||||
if ($in{'new'}) {
|
||||
&ui_print_header(undef, $text{'edit_title1'}, "");
|
||||
$user = { 'enabled' => 1 };
|
||||
}
|
||||
else {
|
||||
&ui_print_header(undef, $text{'edit_title2'}, "");
|
||||
if (!$access{'single'}) {
|
||||
$users = &list_users();
|
||||
$user = $users->[$in{'idx'}];
|
||||
}
|
||||
}
|
||||
|
||||
print "<form action=save.cgi method=post>\n";
|
||||
print "<input type=hidden name=idx value='$in{'idx'}'>\n";
|
||||
print "<input type=hidden name=new value='$in{'new'}'>\n";
|
||||
print "<table border>\n";
|
||||
print "<tr $tb> <td><b>$text{'edit_header'}</b></td> </tr>\n";
|
||||
print "<tr $cb> <td><table cellpadding=3>\n";
|
||||
|
||||
if ($access{'single'}) {
|
||||
print "<tr> <td><b>$text{'edit_single'}</b></td>\n";
|
||||
print "<td><input name=user size=20></td> </tr>\n";
|
||||
}
|
||||
else {
|
||||
print "<tr> <td><b>$text{'edit_user'}</b></td>\n";
|
||||
if ($access{'rename'} || $in{'new'}) {
|
||||
printf "<td><input name=user size=20 value='%s'></td> </tr>\n",
|
||||
&html_escape($user->{'user'});
|
||||
}
|
||||
}
|
||||
|
||||
if ($access{'enable'}) {
|
||||
print "<tr> <td><b>$text{'edit_enabled'}</b></td>\n";
|
||||
printf "<td><input type=radio name=enabled value=1 %s> %s\n",
|
||||
$user->{'enabled'} ? "checked" : "", $text{'yes'};
|
||||
printf "<input type=radio name=enabled value=0 %s> %s</td> </tr>\n",
|
||||
$user->{'enabled'} ? "" : "checked", $text{'no'};
|
||||
}
|
||||
|
||||
print "<tr> <td valign=top><b>$text{'edit_pass'}</b></td> <td>\n";
|
||||
if (!$in{'new'}) {
|
||||
if (!$access{'single'}) {
|
||||
print "<input type=radio name=pass_def value=1 checked> ",
|
||||
"$text{'edit_pass1'}<br>\n";
|
||||
print "<input type=radio name=pass_def value=0>\n";
|
||||
}
|
||||
if ($access{'repeat'}) {
|
||||
print "$text{'edit_passfrom'}\n";
|
||||
print "<input type=password name=oldpass size=20>\n";
|
||||
print "$text{'edit_passto'}\n";
|
||||
}
|
||||
else {
|
||||
print "$text{'edit_pass0'}\n";
|
||||
}
|
||||
}
|
||||
print "<input type=password name=pass size=20></td> </tr>\n";
|
||||
|
||||
print "</table></td></tr></table>\n";
|
||||
if ($in{'new'}) {
|
||||
print "<input type=submit value='$text{'create'}'>\n";
|
||||
}
|
||||
else {
|
||||
print "<input type=submit value='$text{'save'}'>\n";
|
||||
print "<input type=submit name=delete value='$text{'delete'}'>\n"
|
||||
if ($access{'delete'} && !$access{'single'});
|
||||
}
|
||||
print "</form>\n";
|
||||
|
||||
if ($access{'single'}) {
|
||||
&ui_print_footer("/", $text{'index'});
|
||||
}
|
||||
else {
|
||||
&ui_print_footer("", $text{'index_return'});
|
||||
}
|
||||
|
||||
|
247
htpasswd-file/htpasswd-file-lib.pl
Normal file
247
htpasswd-file/htpasswd-file-lib.pl
Normal file
@ -0,0 +1,247 @@
|
||||
# htpasswd-file-lib.pl
|
||||
# Functions for reading and writing a .htpasswd format file
|
||||
# XXX md5 and old password
|
||||
|
||||
BEGIN { push(@INC, ".."); };
|
||||
use WebminCore;
|
||||
if (!$module_name) {
|
||||
&init_config();
|
||||
%access = &get_module_acl();
|
||||
}
|
||||
do 'md5-lib.pl';
|
||||
$htdigest_command = &has_command("htdigest") || &has_command("htdigest2");
|
||||
|
||||
# list_users([file])
|
||||
# Returns an array of user and password details from the given file
|
||||
sub list_users
|
||||
{
|
||||
local $file = $_[0] || $config{'file'};
|
||||
if (!defined($list_authusers_cache{$file})) {
|
||||
$list_authusers_cache{$file} = [ ];
|
||||
local $_;
|
||||
local $lnum = 0;
|
||||
local $count = 0;
|
||||
open(HTPASSWD, $file);
|
||||
while(<HTPASSWD>) {
|
||||
if (/^(#?)\s*([^:]+):(\S*)/) {
|
||||
push(@{$list_authusers_cache{$file}},
|
||||
{ 'user' => $2,
|
||||
'pass' => $3,
|
||||
'enabled' => !$1,
|
||||
'file' => $file,
|
||||
'line' => $lnum,
|
||||
'index' => $count++ });
|
||||
}
|
||||
$lnum++;
|
||||
}
|
||||
close(HTPASSWD);
|
||||
}
|
||||
return $list_authusers_cache{$file};
|
||||
}
|
||||
|
||||
# list_digest_users([file])
|
||||
# Returns an array of user, domain and password details from the given file
|
||||
sub list_digest_users
|
||||
{
|
||||
local $file = $_[0] || $config{'file'};
|
||||
if (!defined($list_authusers_cache{$file})) {
|
||||
$list_authusers_cache{$file} = [ ];
|
||||
local $_;
|
||||
local $lnum = 0;
|
||||
local $count = 0;
|
||||
open(HTPASSWD, $file);
|
||||
while(<HTPASSWD>) {
|
||||
if (/^(#?)\s*(\S+):(\S+):(\S*)/) {
|
||||
push(@{$list_authusers_cache{$file}},
|
||||
{ 'user' => $2,
|
||||
'dom' => $3,
|
||||
'pass' => $4,
|
||||
'enabled' => !$1,
|
||||
'digest' => 1,
|
||||
'file' => $file,
|
||||
'line' => $lnum,
|
||||
'index' => $count++ });
|
||||
}
|
||||
$lnum++;
|
||||
}
|
||||
close(HTPASSWD);
|
||||
}
|
||||
return $list_authusers_cache{$file};
|
||||
}
|
||||
|
||||
# modify_user(&user)
|
||||
sub modify_user
|
||||
{
|
||||
local $lref = &read_file_lines($_[0]->{'file'});
|
||||
if ($_[0]->{'digest'}) {
|
||||
$lref->[$_[0]->{'line'}] = ($_[0]->{'enabled'} ? "" : "#").
|
||||
"$_[0]->{'user'}:$_[0]->{'dom'}:$_[0]->{'pass'}";
|
||||
}
|
||||
else {
|
||||
$lref->[$_[0]->{'line'}] = ($_[0]->{'enabled'} ? "" : "#").
|
||||
"$_[0]->{'user'}:$_[0]->{'pass'}";
|
||||
}
|
||||
&flush_file_lines($_[0]->{'file'});
|
||||
}
|
||||
|
||||
# create_user(&user, [file])
|
||||
sub create_user
|
||||
{
|
||||
$_[0]->{'file'} = $_[1] || $config{'file'};
|
||||
local $lref = &read_file_lines($_[0]->{'file'});
|
||||
$_[0]->{'line'} = @$lref;
|
||||
if ($_[0]->{'digest'}) {
|
||||
push(@$lref, ($_[0]->{'enabled'} ? "" : "#").
|
||||
"$_[0]->{'user'}:$_[0]->{'dom'}:$_[0]->{'pass'}");
|
||||
}
|
||||
else {
|
||||
push(@$lref, ($_[0]->{'enabled'} ? "" : "#").
|
||||
"$_[0]->{'user'}:$_[0]->{'pass'}");
|
||||
}
|
||||
&flush_file_lines($_[0]->{'file'});
|
||||
$_[0]->{'index'} = @{$list_authusers_cache{$_[0]->{'file'}}};
|
||||
push(@{$list_authusers_cache{$_[0]->{'file'}}}, $_[0]);
|
||||
}
|
||||
|
||||
# delete_user(&user)
|
||||
sub delete_user
|
||||
{
|
||||
local $lref = &read_file_lines($_[0]->{'file'});
|
||||
splice(@$lref, $_[0]->{'line'}, 1);
|
||||
&flush_file_lines($_[0]->{'file'});
|
||||
splice(@{$list_authusers_cache{$_[0]->{'file'}}}, $_[0]->{'index'}, 1);
|
||||
map { $_->{'line'}-- if ($_->{'line'} > $_[0]->{'line'}) }
|
||||
@{$list_authusers_cache{$_[0]->{'file'}}};
|
||||
}
|
||||
|
||||
# encrypt_password(string, [old], md5mode)
|
||||
sub encrypt_password
|
||||
{
|
||||
&seed_random();
|
||||
if ($_[2] == 1) {
|
||||
# MD5
|
||||
return &encrypt_md5($_[0], $_[1]);
|
||||
}
|
||||
elsif ($_[2] == 2) {
|
||||
# SHA1
|
||||
return &encrypt_sha1($_[0]);
|
||||
}
|
||||
elsif ($_[2] == 3) {
|
||||
# Digest
|
||||
return &digest_password(undef, undef, $_[0]);
|
||||
}
|
||||
else {
|
||||
# Crypt
|
||||
if ($gconfig{'os_type'} eq 'windows' && &has_command("htpasswd")) {
|
||||
# Call htpasswd program
|
||||
local $qp = quotemeta($_[0]);
|
||||
local $out = `htpasswd -n -b foo $qp 2>&1 <$null_file`;
|
||||
if ($out =~ /^foo:(\S+)/) {
|
||||
return $1;
|
||||
}
|
||||
else {
|
||||
&error("htpasswd failed : $out");
|
||||
}
|
||||
}
|
||||
else {
|
||||
# Use built-in encryption code
|
||||
local $salt = $_[1] ||
|
||||
chr(int(rand(26))+65).chr(int(rand(26))+65);
|
||||
return &unix_crypt($_[0], $salt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# digest_password(user, realm, pass)
|
||||
# Encrypts a password in the format used by htdigest
|
||||
sub digest_password
|
||||
{
|
||||
local ($user, $dom, $pass) = @_;
|
||||
local $temp = &tempname();
|
||||
eval "use Digest::MD5";
|
||||
if (!$@) {
|
||||
# Use the digest::MD5 module to do the encryption directly
|
||||
return Digest::MD5::md5_hex("$user:$dom:$pass");
|
||||
}
|
||||
else {
|
||||
# Shell out to htdigest command
|
||||
&foreign_require("proc", "proc-lib.pl");
|
||||
local ($fh, $fpid) = &proc::pty_process_exec("$htdigest_command -c $temp ".quotemeta($dom)." ".quotemeta($user));
|
||||
&wait_for($fh, "password:");
|
||||
&sysprint($fh, "$pass\n");
|
||||
&wait_for($fh, "password:");
|
||||
&sysprint($fh, "$pass\n");
|
||||
&wait_for($fh);
|
||||
close($fh);
|
||||
local $tempusers = &list_digest_users($temp);
|
||||
unlink($temp);
|
||||
return $tempusers->[0]->{'pass'};
|
||||
}
|
||||
}
|
||||
|
||||
# list_groups(file)
|
||||
# Returns an array of group details from the given file
|
||||
sub list_groups
|
||||
{
|
||||
local $file = $_[0];
|
||||
if (!defined($list_authgroups_cache{$file})) {
|
||||
$list_authgroups_cache{$file} = [ ];
|
||||
local $_;
|
||||
local $lnum = 0;
|
||||
local $count = 0;
|
||||
open(HTPASSWD, $file);
|
||||
while(<HTPASSWD>) {
|
||||
if (/^(#?)\s*(\S+):\s*(.*)/) {
|
||||
push(@{$list_authgroups_cache{$file}},
|
||||
{ 'group' => $2,
|
||||
'enabled' => !$1,
|
||||
'members' => [ split(/\s+/, $3) ],
|
||||
'file' => $file,
|
||||
'line' => $lnum,
|
||||
'index' => $count++ });
|
||||
}
|
||||
$lnum++;
|
||||
}
|
||||
close(HTPASSWD);
|
||||
}
|
||||
return $list_authgroups_cache{$file};
|
||||
}
|
||||
|
||||
# modify_group(&group)
|
||||
sub modify_group
|
||||
{
|
||||
local $lref = &read_file_lines($_[0]->{'file'});
|
||||
$lref->[$_[0]->{'line'}] = ($_[0]->{'enabled'} ? "" : "#").
|
||||
"$_[0]->{'group'}: ".
|
||||
join(" ", @{$_[0]->{'members'}});
|
||||
&flush_file_lines();
|
||||
}
|
||||
|
||||
# create_group(&group, [file])
|
||||
sub create_group
|
||||
{
|
||||
$_[0]->{'file'} = $_[1] || $config{'file'};
|
||||
local $lref = &read_file_lines($_[0]->{'file'});
|
||||
$_[0]->{'line'} = @$lref;
|
||||
push(@$lref, ($_[0]->{'enabled'} ? "" : "#").
|
||||
"$_[0]->{'group'}: ".
|
||||
join(" ", @{$_[0]->{'members'}}));
|
||||
&flush_file_lines();
|
||||
$_[0]->{'index'} = @{$list_authgroups_cache{$_[0]->{'file'}}};
|
||||
push(@{$list_authgroups_cache{$_[0]->{'file'}}}, $_[0]);
|
||||
}
|
||||
|
||||
# delete_group(&group)
|
||||
sub delete_group
|
||||
{
|
||||
local $lref = &read_file_lines($_[0]->{'file'});
|
||||
splice(@$lref, $_[0]->{'line'}, 1);
|
||||
&flush_file_lines();
|
||||
splice(@{$list_authgroups_cache{$_[0]->{'file'}}}, $_[0]->{'index'}, 1);
|
||||
map { $_->{'line'}-- if ($_->{'line'} > $_[0]->{'line'}) }
|
||||
@{$list_authgroups_cache{$_[0]->{'file'}}};
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
BIN
htpasswd-file/images/.xvpics/icon.gif
Normal file
BIN
htpasswd-file/images/.xvpics/icon.gif
Normal file
Binary file not shown.
BIN
htpasswd-file/images/icon.gif
Normal file
BIN
htpasswd-file/images/icon.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 627 B |
BIN
htpasswd-file/images/smallicon.gif
Normal file
BIN
htpasswd-file/images/smallicon.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 678 B |
91
htpasswd-file/index.cgi
Executable file
91
htpasswd-file/index.cgi
Executable file
@ -0,0 +1,91 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Display users in the .htpasswd file
|
||||
|
||||
require './htpasswd-file-lib.pl';
|
||||
if ($access{'single'}) {
|
||||
&redirect("edit.cgi");
|
||||
exit;
|
||||
}
|
||||
|
||||
&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
|
||||
|
||||
# Check if file is set in config
|
||||
if (!$config{'file'}) {
|
||||
print &text('index_econfig',
|
||||
"../config.cgi?$module_name"),"<p>\n";
|
||||
&ui_print_footer("/", $text{'index'});
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($config{'md5'}) {
|
||||
# Check if MD5 perl module is installed, and offer to install
|
||||
&foreign_require("useradmin", "user-lib.pl");
|
||||
if (!defined(&useradmin::check_md5)) {
|
||||
print &text('index_eversion',
|
||||
"../config.cgi?$module_name"),"<p>\n";
|
||||
&ui_print_footer("/", $text{'index'});
|
||||
exit;
|
||||
}
|
||||
elsif ($err = &useradmin::check_md5()) {
|
||||
print &text('index_emd5',
|
||||
"../config.cgi?$module_name",
|
||||
"<tt>$err</tt>",
|
||||
"../cpan/download.cgi?source=3&cpan=Digest::MD5&mode=2&return=/$module_name/&returndesc=".&urlize($text{'index_return'})),"<p>\n";
|
||||
&ui_print_footer("/", $text{'index'});
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
# Display list of users
|
||||
print &ui_subheading(&text('index_file', "<tt>$config{'file'}</tt>"));
|
||||
$users = &list_users();
|
||||
if (@$users) {
|
||||
print "<a href='edit.cgi?new=1'>$text{'index_add'}</a><br>\n"
|
||||
if ($access{'create'});
|
||||
print "<table border width=100%>\n";
|
||||
print "<tr $tb> <td><b>$text{'index_header'}</b></td> </tr>\n";
|
||||
print "<tr $cb> <td><table width=100%>\n";
|
||||
for($i=0; $i<@$users; $i++) {
|
||||
$u = $users->[$i];
|
||||
$link = "<a href='edit.cgi?idx=$u->{'index'}'>".
|
||||
"$u->{'user'}</a>";
|
||||
print "<tr>\n" if ($i%4 == 0);
|
||||
if ($u->{'enabled'}) {
|
||||
print "<td width=25%>$link</td>\n";
|
||||
}
|
||||
else {
|
||||
print "<td width=25%><i>$link</i></td>\n";
|
||||
}
|
||||
print "</tr>\n" if ($i%4 == 3);
|
||||
}
|
||||
if ($i%4) {
|
||||
while($i++%4) { print "<td width=25%></td>\n"; }
|
||||
print "</tr>\n";
|
||||
}
|
||||
print "</table></td></tr></table>\n";
|
||||
}
|
||||
else {
|
||||
print "<b>$text{'index_none'}</b><p>\n";
|
||||
}
|
||||
print "<a href='edit.cgi?new=1'>$text{'index_add'}</a><p>\n"
|
||||
if ($access{'create'});
|
||||
|
||||
if ($access{'sync'}) {
|
||||
# Show sync options
|
||||
print "<hr>\n";
|
||||
print &ui_subheading($text{'index_sync'});
|
||||
print "<form action=save_sync.cgi>\n";
|
||||
printf "<input type=checkbox name=create value=1 %s> %s<p>\n",
|
||||
$config{'sync_create'} ? "checked" : "",
|
||||
$text{'index_synccreate'};
|
||||
printf "<input type=checkbox name=modify value=1 %s> %s<p>\n",
|
||||
$config{'sync_modify'} ? "checked" : "",
|
||||
$text{'index_syncmodify'};
|
||||
printf "<input type=checkbox name=delete value=1 %s> %s<p>\n",
|
||||
$config{'sync_delete'} ? "checked" : "",
|
||||
$text{'index_syncdelete'};
|
||||
print "<input type=submit value='$text{'index_ssave'}'></form>\n";
|
||||
}
|
||||
|
||||
&ui_print_footer("/", $text{'index'});
|
||||
|
55
htpasswd-file/lang/en
Normal file
55
htpasswd-file/lang/en
Normal file
@ -0,0 +1,55 @@
|
||||
index_title=Manage HTPasswd File
|
||||
index_econfig=This module cannot be used until a password file has been set on the <a href='$1'>module configuration</a> page.
|
||||
index_emd5=This module has been <a href='$1'>configured</a> to use MD5 encryption for passwords, but the $2 Perl module is not installed. <a href='$3'>Click here</a> to have the $2 module downloaded and installed.
|
||||
index_header=Password file users
|
||||
index_none=No users exist in the configured password file.
|
||||
index_add=Add a new user to the password file.
|
||||
index_file=Users in Password File $1
|
||||
index_sync=Unix User Synchronization
|
||||
index_return=user list
|
||||
index_eversion=This module has been <a href='$1'>configured</a> to use MD5 encryption for passwords, but the version of the Users and Groups module installed on your system does not include the needed MD5 functions. Upgrade to version 1.114 or later.
|
||||
index_synccreate=Add a user when a Unix user is created?
|
||||
index_syncmodify=Re-name or change the password of a user when the corresponding Unix user is modified?
|
||||
index_syncdelete=Delete a user when the corresponding Unix user is deleted?
|
||||
index_ssave=Save and Apply
|
||||
|
||||
edit_title1=Create User
|
||||
edit_title2=Edit User
|
||||
edit_header=Password file user details
|
||||
edit_user=Username
|
||||
edit_enabled=Enabled?
|
||||
edit_pass=Password
|
||||
edit_pass1=Leave unchanged
|
||||
edit_pass0=Set to
|
||||
edit_passfrom=Change from
|
||||
edit_passto=to new password
|
||||
edit_single=User to change
|
||||
edit_return=password change form
|
||||
|
||||
save_err=Failed to save user
|
||||
save_euser1=Missing username
|
||||
save_euser2=Username cannot contain the : character
|
||||
save_epass=Password cannot contain the : character
|
||||
save_eclash=A user with the same name already exists
|
||||
save_eoldpass=Old password is not correct
|
||||
save_ecreate=You are not allowed to create users
|
||||
save_edelete=You are not allowed to delete users
|
||||
save_euser=User does not exist
|
||||
save_title=User Saved
|
||||
save_done=The user $1 has been updated.
|
||||
|
||||
acl_repeat=Must enter old password when changing?
|
||||
acl_create=Can create new users?
|
||||
acl_rename=Can rename users?
|
||||
acl_delete=Can delete users?
|
||||
acl_sync=Can configure synchronization?
|
||||
acl_enable=Can enable and disable users?
|
||||
acl_single=Skip user list and go direct to password change form?
|
||||
|
||||
sync_ecannot=You are not allowed to configure synchronization
|
||||
|
||||
log_sync=Changed synchronization options
|
||||
log_create=Created user $1
|
||||
log_delete=Deleted user $1
|
||||
log_modify=Modified user $1
|
||||
|
18
htpasswd-file/log_parser.pl
Normal file
18
htpasswd-file/log_parser.pl
Normal file
@ -0,0 +1,18 @@
|
||||
# log_parser.pl
|
||||
# Functions for parsing this module's logs
|
||||
|
||||
do 'htpasswd-file-lib.pl';
|
||||
|
||||
# parse_webmin_log(user, script, action, type, object, ¶ms)
|
||||
# Converts logged information from this module into human-readable form
|
||||
sub parse_webmin_log
|
||||
{
|
||||
local ($user, $script, $action, $type, $object, $p) = @_;
|
||||
if ($action eq "sync") {
|
||||
return $text{'log_sync'};
|
||||
}
|
||||
else {
|
||||
return &text('log_'.$action, "<tt>".&html_escape($object)."</tt>");
|
||||
}
|
||||
}
|
||||
|
1
htpasswd-file/md5-lib.pl
Symbolic link
1
htpasswd-file/md5-lib.pl
Symbolic link
@ -0,0 +1 @@
|
||||
../useradmin/md5-lib.pl
|
5
htpasswd-file/module.info
Normal file
5
htpasswd-file/module.info
Normal file
@ -0,0 +1,5 @@
|
||||
name=HTPasswdFile
|
||||
desc=Manage HTPasswd File
|
||||
category=servers
|
||||
depends=useradmin
|
||||
version=1.4
|
75
htpasswd-file/save.cgi
Executable file
75
htpasswd-file/save.cgi
Executable file
@ -0,0 +1,75 @@
|
||||
#!/usr/local/bin/perl
|
||||
# save_user.cgi
|
||||
# Create, update or delete a password file user
|
||||
|
||||
require './htpasswd-file-lib.pl';
|
||||
&ReadParse();
|
||||
&error_setup($text{'save_err'});
|
||||
$users = &list_users();
|
||||
if (!$in{'new'}) {
|
||||
if (!$access{'single'}) {
|
||||
$user = $users->[$in{'idx'}];
|
||||
}
|
||||
else {
|
||||
($user) = grep { $_->{'user'} eq $in{'user'} } @$users;
|
||||
$user || &error($text{'save_euser'});
|
||||
}
|
||||
$loguser = $user->{'user'};
|
||||
}
|
||||
else {
|
||||
$loguser = $in{'user'};
|
||||
}
|
||||
|
||||
&lock_file($config{'file'});
|
||||
if ($in{'delete'}) {
|
||||
# Just delete this user
|
||||
$access{'delete'} || &error($text{'save_edelete'});
|
||||
&delete_user($user);
|
||||
}
|
||||
else {
|
||||
# Validate inputs
|
||||
if (!$access{'single'} && $access{'rename'} || $in{'new'}) {
|
||||
$in{'user'} || &error($text{'save_euser1'});
|
||||
$in{'user'} =~ /:/ && &error($text{'save_euser2'});
|
||||
if ($in{'new'} || $user->{'user'} ne $in{'user'}) {
|
||||
($clash) = grep { $_->{'user'} eq $in{'user'} } @$users;
|
||||
$clash && &error($text{'save_eclash'});
|
||||
}
|
||||
}
|
||||
!$in{'pass_def'} && $in{'pass'} =~ /:/ && &error($text{'save_epass'});
|
||||
if ($access{'repeat'} && !$in{'new'}) {
|
||||
$user->{'pass'} eq &encrypt_password($in{'oldpass'}, $user->{'pass'}, $config{'md5'}) || &error($text{'save_eoldpass'});
|
||||
}
|
||||
|
||||
# Actually save
|
||||
$user->{'user'} = $in{'user'}
|
||||
if ($in{'new'} || !$access{'single'} && $access{'rename'});
|
||||
if (!$in{'pass_def'}) {
|
||||
$user->{'pass'} = &encrypt_password($in{'pass'}, undef, $config{'md5'});
|
||||
}
|
||||
if ($access{'enable'}) {
|
||||
$user->{'enabled'} = $in{'enabled'};
|
||||
}
|
||||
elsif ($in{'new'}) {
|
||||
$user->{'enabled'} = 1;
|
||||
}
|
||||
if ($in{'new'}) {
|
||||
&create_user($user);
|
||||
}
|
||||
else {
|
||||
&modify_user($user);
|
||||
}
|
||||
}
|
||||
&unlock_file($config{'file'});
|
||||
&webmin_log($in{'delete'} ? "delete" : $in{'new'} ? "create" : "modify",
|
||||
"user", $loguser, $user);
|
||||
if ($access{'single'}) {
|
||||
&ui_print_header(undef, $text{'save_title'}, "");
|
||||
print &text('save_done', "<tt>$loguser</tt>"),"<p>\n";
|
||||
&ui_print_footer("edit.cgi", $text{'edit_return'});
|
||||
}
|
||||
else {
|
||||
&redirect("");
|
||||
}
|
||||
|
||||
|
16
htpasswd-file/save_sync.cgi
Executable file
16
htpasswd-file/save_sync.cgi
Executable file
@ -0,0 +1,16 @@
|
||||
#!/usr/local/bin/perl
|
||||
# save_sync.cgi
|
||||
# Update synchronization settings
|
||||
|
||||
require './htpasswd-file-lib.pl';
|
||||
$access{'sync'} || &error($text{'sync_ecannot'});
|
||||
&ReadParse();
|
||||
&lock_file("$module_config_directory/config");
|
||||
$config{'sync_create'} = $in{'create'};
|
||||
$config{'sync_modify'} = $in{'modify'};
|
||||
$config{'sync_delete'} = $in{'delete'};
|
||||
&write_file("$module_config_directory/config", \%config);
|
||||
&unlock_file("$module_config_directory/config");
|
||||
&webmin_log("sync");
|
||||
&redirect("");
|
||||
|
59
htpasswd-file/useradmin_update.pl
Normal file
59
htpasswd-file/useradmin_update.pl
Normal file
@ -0,0 +1,59 @@
|
||||
|
||||
do 'htpasswd-file-lib.pl';
|
||||
|
||||
sub useradmin_create_user
|
||||
{
|
||||
return if (!$config{'file'});
|
||||
local $users = &list_users();
|
||||
local ($clash) = grep { $_->{'user'} eq $_[0]->{'user'} } @$users;
|
||||
return if ($clash);
|
||||
local $user = { 'user' => $_[0]->{'user'},
|
||||
'enabled' => 1 };
|
||||
if ($_[0]->{'passmode'} == 0) {
|
||||
$user->{'pass'} = "";
|
||||
}
|
||||
elsif ($_[0]->{'passmode'} == 1) {
|
||||
$user->{'pass'} = "*LK*";
|
||||
}
|
||||
elsif ($_[0]->{'passmode'} == 2) {
|
||||
$user->{'pass'} = $_[0]->{'pass'};
|
||||
}
|
||||
else {
|
||||
$user->{'pass'} = &encrypt_password($_[0]->{'plainpass'},
|
||||
undef, $config{'md5'});
|
||||
}
|
||||
&create_user($user);
|
||||
}
|
||||
|
||||
sub useradmin_modify_user
|
||||
{
|
||||
return if (!$config{'file'});
|
||||
local $users = &list_users();
|
||||
local ($user) = grep { $_->{'user'} eq $_[0]->{'olduser'} } @$users;
|
||||
return if (!$user);
|
||||
$user->{'user'} = $_[0]->{'user'};
|
||||
if ($_[0]->{'passmode'} == 0) {
|
||||
$user->{'pass'} = "";
|
||||
}
|
||||
elsif ($_[0]->{'passmode'} == 1) {
|
||||
$user->{'pass'} = "*LK*";
|
||||
}
|
||||
elsif ($_[0]->{'passmode'} == 2) {
|
||||
$user->{'pass'} = $_[0]->{'pass'};
|
||||
}
|
||||
elsif ($_[0]->{'passmode'} == 3) {
|
||||
$user->{'pass'} = &encrypt_password($_[0]->{'plainpass'},
|
||||
undef, $config{'md5'});
|
||||
}
|
||||
&modify_user($user);
|
||||
}
|
||||
|
||||
sub useradmin_delete_user
|
||||
{
|
||||
return if (!$config{'file'});
|
||||
local $users = &list_users();
|
||||
local ($user) = grep { $_->{'user'} eq $_[0]->{'user'} } @$users;
|
||||
return if (!$user);
|
||||
&delete_user($user);
|
||||
}
|
||||
|
Reference in New Issue
Block a user