htaccess-htpasswd/ 0040775 0005671 0000012 00000000000 10004067665 014200 5 ustar jcameron wheel htaccess-htpasswd/module.info 0100664 0005671 0000012 00000000275 10006706205 016333 0 ustar jcameron wheel name=HTAccess Files desc=Protected Web Directories depends=htaccess longdesc=Create .htaccess and htpasswd files to protect web-acessible directories. usermin=1 category=apps version=1.061 htaccess-htpasswd/config 0100664 0005671 0000012 00000000070 07756276630 015400 0 ustar jcameron wheel htaccess=.htaccess htpasswd=htpasswd md5=0 dirs= home=1 htaccess-htpasswd/config.info 0100664 0005671 0000012 00000000255 07756276614 016341 0 ustar jcameron wheel htaccess=Apache options file name,0 htpasswd=Users file name,0 dirs=Allowed directories for options files,9,0,0,\t home=Include home directory in allowed list?,1,1-Yes,0-No htaccess-htpasswd/search.cgi 0100775 0005671 0000012 00000003135 10006703354 016125 0 ustar jcameron wheel #!/usr/local/bin/perl # search.cgi # Find .htaccess files under some directory require './htaccess-lib.pl'; &foreign_require($apachemod, "apache-lib.pl"); &ReadParse(); &error_setup($text{'search_err'}); $in{'search'} =~ /^\// && $in{'search'} !~ /\.\./ || &error($text{'search_edir'}); &can_access_dir($in{'search'}) || &error($text{'search_ecannot'}); $| = 1; $theme_no_table++; &header($text{'search_title'}, ""); print "
\n";
# Use the find command
&switch_user();
open(FIND, "find ".quotemeta($in{'search'})." -name ".
quotemeta($config{'htaccess'})." -print 2>/dev/null |");
while($f = $text{'search_done'} \n";
&switch_back();
&lock_file($directories_file);
&save_directories(\@dirs);
&unlock_file($directories_file);
&webmin_log("search", $in{'search'});
print " \n";
}
print "$text{'index_add'} \n";
print "
\n";
}
elsif (!open(TEST, $f)) {
print &text('search_open', "$f", $!),"
\n";
}
else {
$conf = &foreign_call($apachemod, "get_htaccess_config", $f);
$currfile = &foreign_call($apachemod, "find_directive",
"AuthUserFile", $conf, 1);
if ($currfile) {
print &text('search_found', "$f",
"$currfile"),"
\n";
local $d = $f;
$d =~ s/\/$config{'htaccess'}$//;
push(@dirs, [ $d, $currfile ]);
}
else {
print &text('search_noprot', "$f"),"
\n";
}
}
}
close(FIND);
print "
\n";
&footer("", $text{'index_return'});
htaccess-htpasswd/edit_dir.cgi 0100775 0005671 0000012 00000004666 07756274630 016477 0 ustar jcameron wheel #!/usr/local/bin/perl
# edit_dir.cgi
# Display information about a protected directory
require './htaccess-lib.pl';
&foreign_require($apachemod, "apache-lib.pl");
&ReadParse();
if ($in{'new'}) {
&header($text{'dir_title1'}, "");
}
else {
&header($text{'dir_title2'}, "");
@dirs = &list_directories();
($dir) = grep { $_->[0] eq $in{'dir'} } @dirs;
&can_access_dir($dir->[0]) || &error($text{'dir_ecannot'});
}
print "
\n";
print "\n";
print "
\n";
&footer("", $text{'index_return'});
htaccess-htpasswd/edit_user.cgi 0100775 0005671 0000012 00000003647 07750633354 016671 0 ustar jcameron wheel #!/usr/local/bin/perl
# edit_user.cgi
# Display a form for editing or creating a htpasswd user
require './htaccess-lib.pl';
&ReadParse();
@dirs = &list_directories();
($dir) = grep { $_->[0] eq $in{'dir'} } @dirs;
&can_access_dir($dir->[0]) || &error($text{'dir_ecannot'});
&switch_user();
if ($in{'new'}) {
&header($text{'edit_title1'}, "");
$user = { 'enabled' => 1 };
}
else {
&header($text{'edit_title2'}, "");
$users = &list_users($dir->[1]);
$user = $users->[$in{'idx'}];
}
print "
\n";
print "\n";
print "
\n";
&footer("", $text{'index_return'});
htaccess-htpasswd/htaccess-lib.pl 0100664 0005671 0000012 00000004067 07756277244 017122 0 ustar jcameron wheel # htaccess-lib.pl
# Common functions for the htaccess and htpasswd file management module
do '../web-lib.pl';
&init_config();
do 'htpasswd-file-lib.pl';
if ($module_info{'usermin'}) {
# Allow directories are in module configuration
&switch_to_remote_user();
&create_user_config_dirs();
push(@accessdirs, $remote_user_info[7]) if ($config{'home'});
push(@accessdirs, split(/\t+/, $config{'dirs'}));
$directories_file = "$user_module_config_directory/directories";
$apachemod = "htaccess";
}
else {
# Allowed directories come from ACL
%access = &get_module_acl();
@accessdirs = split(/\t+/, $access{'dirs'});
if ($access{'home'}) {
local @uinfo = getpwnam($remote_user);
push(@accessdirs, $uinfo[7]) if (defined(@uinfo));
}
$directories_file = "$module_config_directory/directories";
$directories_file .= ".".$remote_user if ($access{'userdirs'});
$apachemod = "apache";
}
# list_directories()
# Returns a list of protected directories known to this module, and the
# users file for each.
sub list_directories
{
open(DIRS, $directories_file);
while(
\n";
@accessdirs || &error($text{'index_eaccess'});
@dirs = &list_directories();
@dirs = grep { &can_access_dir($_->[0]) } @dirs;
if (@dirs) {
print "$text{'index_add'}
\n";
print "\n";
print "
\n";
}
else {
print "$text{'index_none'} \n";
foreach $d (@dirs) {
print "$text{'index_dir'} ",
"$text{'index_users'} \n";
print " \n";
}
print "$d->[0] \n";
print " \n";
print "\n";
$users = &list_users($d->[1]);
if ($userconfig{'sort'} == 1 || $config{'sort'} == 1) {
$users = [ sort { $a->{'user'} cmp $b->{'user'} }
@$users ];
}
for($i=0; $i<@$users; $i++) {
$u = $users->[$i];
$link = "[0])."'>$u->{'user'}";
print "
\n";
print "$text{'index_uadd'}\n";
print "\n" if ($i%4 == 0);
if ($u->{'enabled'}) {
print " \n" if ($i%4 == 3);
}
if ($i%4) {
while($i++%4) { print "$link \n";
}
else {
print "$link \n";
}
print "\n"; }
print "\n";
}
if (!@$users) {
print " \n";
}
print "$text{'index_nousers'}",
"
\n";
print "\n";
print "
\n";
&footer("/", $text{'index'});
htaccess-htpasswd/lang/ 0040775 0005671 0000012 00000000000 10004070324 015103 5 ustar jcameron wheel htaccess-htpasswd/lang/es 0100664 0005671 0000012 00000004355 10003656261 015452 0 ustar jcameron wheel index_title=Directorios Web Protegidos
index_dir=Directorio protegido
index_users=Usuarios habilitados
index_none=An no han sido definidos directorios protegidos.
index_add=Agregar proteccin para un nuevo directorio.
index_uadd=Agregar un nuevo usuario para este directorio.
index_return=lista de usuarios y directorios
index_nousers=Ninguno definido an
index_eaccess=No tiene acceso a ningn directorio!
dir_title1=Agregar Directorio Protegido
dir_title2=Editar Directorio Protegido
dir_header=Opciones de directorio protegido
dir_dir=Camino del directorio
dir_file=Archivo conteniendo usuarios
dir_auto=Seleccionar automticamente
dir_sel=Archivo seleccionado ..
dir_crypt=Encripcin de contrasea
dir_crypt0=Unix crypt
dir_crypt1=MD5
dir_realm=Autenticacin realm
dir_err=Fallo al salvar directorio
dir_eclash=Este directorio ya est protegido
dir_edir=Directorio no ingresado o no vlido
dir_ecannot=No est autorizado a proteger este directorio
dir_efile=Nombre de archivo de usuarios no ingresado o no vlido
dir_ehtaccess=Fallo al crear archivo de opciones de Apache $1 : $2
dir_ehtpasswd=Fallo al crear archivo de usuarios $1 : $2
dir_remove=Borrar totalmente archivos $1 y $2?
dir_erealm=Autenticacin realm no ingresada
edit_title1=Crear Usuario
edit_title2=Editar Usuario
edit_header=Detalles del usuario del archivo de contraseas
edit_user=Nombre de usuario
edit_enabled=Habilitado?
edit_pass=Contrasea
edit_pass1=Dejar incambiado
edit_pass0=Configurar a
edit_passfrom=Cambiar desde
edit_passto=a nueva contrasea
save_err=Fallo al salvar usuario
save_euser1=Nombre de usuario no ingresado
save_euser2=Nombre de usuario no puede contener el carcter :
save_epass=Contrasea no puede contener el carcter :
save_eclash=Ya existe un usuario con el mismo nombre
save_eoldpass=La password anterior no es correcta
save_title=Usuario Salvado
acl_dirs=Permitir directorios
acl_user=Crear archivos .htaccess y htusers como usuario Unix
acl_same=Igual que el usuario de ingreso Webmin
acl_home=Incluir el directorio de inicio del usuario Unix?
log_create_dir=Agregado directorio $1
log_modify_dir=Modificado directorio $1
log_delete_dir=Borrado directorio $1
log_create_user=Creado usuario $1
log_modify_user=Modificado usuario $1
log_delete_user=Borrado usuario $1
htaccess-htpasswd/lang/en 0100664 0005671 0000012 00000005004 10004070324 015424 0 ustar jcameron wheel index_title=Protected Web Directories
index_dir=Protected directory
index_users=Allowed users
index_none=No protected directories have been defined yet.
index_add=Add protection for a new directory.
index_uadd=Add a new user for this directory.
index_return=users and directories list
index_nousers=None defined yet
index_eaccess=You do not have access to any directories!
index_search=Find existing protected directories under:
dir_title1=Add Protected Directory
dir_title2=Edit Protected Directory
dir_header=Protected directory options
dir_dir=Directory path
dir_file=File containing users
dir_auto=Choose automatically
dir_sel=Selected file ..
dir_crypt=Password encryption
dir_crypt0=Unix crypt
dir_crypt1=MD5
dir_realm=Authentication realm
dir_err=Failed to save directory
dir_eclash=This directory is already protected
dir_edir=Missing or invalid directory
dir_ecannot=You are not allowed to protect this directory
dir_efile=Missing or invalid users filename
dir_ehtaccess=Failed to create Apache options file $1 : $2
dir_ehtpasswd=Failed to create users file $1 : $2
dir_remove=Totally delete $1 and $2 files?
dir_erealm=Missing authentication realm
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
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_title=User Saved
acl_dirs=Allowed directories
acl_user=Create .htaccess and htusers files as Unix user
acl_same=Same as Webmin login
acl_home=Include Unix user's home directory?
log_create_dir=Added directory $1
log_modify_dir=Modified directory $1
log_delete_dir=Deleted directory $1
log_create_user=Created user $1
log_modify_user=Modified user $1
log_delete_user=Deleted user $1
search_title=Search Results
search_err=Search failed
search_edir=Missing or invalid absolute directory to search
search_ecannot=You are not allowed to search that directory
search_doing=Searching for protected directories under $1 ..
search_found=Found new Apache options file $1 with users in $2.
search_already=Skipping known Apache options file $1.
search_noprot=Skipping Apache options file $1, as it does not protect the directory.
search_open=Could not open Apache options file $1 : $2
search_done=.. done
htaccess-htpasswd/log_parser.pl 0100644 0005671 0000012 00000000603 07751273253 016673 0 ustar jcameron wheel # log_parser.pl
# Functions for parsing this module's logs
do 'htaccess-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) = @_;
return &text('log_'.$action.'_'.$type,
"".&html_escape($object)."");
}
htaccess-htpasswd/uconfig.info 0100664 0005671 0000012 00000000060 07756276245 016520 0 ustar jcameron wheel sort=Sort users by,1,1-Username,0-Order in file
htaccess-htpasswd/save_dir.cgi 0100775 0005671 0000012 00000007476 07756275767 016526 0 ustar jcameron wheel #!/usr/local/bin/perl
# save_dir.cgi
# Create or update a .htaccess file
require './htaccess-lib.pl';
&ReadParse();
@dirs = &list_directories();
&error_setup($text{'dir_err'});
&foreign_require($apachemod, "apache-lib.pl");
# Work out what .htaccess file to use
if ($in{'new'} && $in{'dir'} !~ /^\// && $accessdirs[0] ne "/") {
# Make path absolute
$in{'dir'} = "$accessdirs[0]/$in{'dir'}";
}
($dir) = grep { $_->[0] eq $in{'dir'} } @dirs;
if ($in{'new'}) {
$dir && &error($text{'dir_eclash'});
$htaccess = "$in{'dir'}/$config{'htaccess'}";
}
else {
$htaccess = "$dir->[0]/$config{'htaccess'}";
}
&lock_file($htaccess);
&lock_file($directories_file);
# Get the apache directives for the .htaccess file, if any
$conf = &foreign_call($apachemod, "get_htaccess_config", $htaccess);
$currfile = &foreign_call($apachemod, "find_directive",
"AuthUserFile", $conf, 1);
&lock_file($currfile) if ($currfile);
# Make sure it is allowed
&switch_user();
&can_access_dir($htaccess) || &error($text{'dir_ecannot'});
open(TEST, ">>$htaccess") || &error(&text('dir_ehtaccess', $htaccess, $!));
close(TEST);
if ($in{'delete'}) {
if ($in{'remove'}) {
# Blow away .htaccess and htpasswd
unlink($htaccess);
unlink($currfile) if ($currfile);
@dirs = grep { $_ ne $dir } @dirs;
}
else {
# Take the authentication directives out of the .htaccess
@dirs = grep { $_ ne $dir } @dirs;
&foreign_call($apachemod, "save_directive",
"require", [ ], $conf, $conf);
}
}
else {
# Validate inputs?
if ($in{'new'}) {
$in{'dir'} =~ /^\// && -d $in{'dir'} ||
&error($text{'dir_edir'});
}
if ($in{'auto'}) {
$file = "$in{'dir'}/$config{'htpasswd'}";
}
else {
if ($in{'file'} !~ /^\//) {
$file = "$in{'dir'}/$file";
}
else {
$file = $in{'file'};
}
}
if ($in{'new'}) {
# Either update an existing .htaccess to ensure that all
# needed directives exist, or create from scratch
# Use the existing users path if there is one, otherwise add
$currfile = &foreign_call($apachemod, "find_directive",
"AuthUserFile", $conf, 1);
if ($currfile) {
$file = $currfile;
}
else {
&foreign_call($apachemod, "save_directive",
"AuthUserFile", [ $file ], $conf, $conf);
}
# Add an auth type if needed
$currtype = &foreign_call($apachemod, "find_directive",
"AuthType", $conf, 1);
if (!$currtype) {
&foreign_call($apachemod, "save_directive",
"AuthType", [ "Basic" ], $conf, $conf);
}
# Add a realm if needed
$currrealm = &foreign_call($apachemod, "find_directive",
"AuthName", $conf, 1);
if (!$currrealm) {
$in{'realm'} || &error($text{'dir_erealm'});
&foreign_call($apachemod, "save_directive", "AuthName",
[ "\"$in{'realm'}\"" ], $conf, $conf);
}
# Add a require if needed
$currrequire = &foreign_call($apachemod, "find_directive",
"require", $conf, 1);
if (!$currrequire) {
&foreign_call($apachemod, "save_directive",
"require", [ "valid-user" ],
$conf, $conf);
}
# Add to the known directories list
$dir = [ $in{'dir'}, $file, $in{'crypt'} ];
push(@dirs, $dir);
}
else {
# Just update the users file path and realm
&foreign_call($apachemod, "save_directive",
"AuthUserFile", [ $file ],
$conf, $conf);
&foreign_call($apachemod, "save_directive",
"AuthName", [ "\"$in{'realm'}\"" ],
$conf, $conf);
# Update the known directories list
$dir->[1] = $file;
$dir->[2] = $in{'crypt'};
}
# Create an empty users file if needed
if (!-r $file) {
&lock_file($file);
open(FILE, ">$file") ||
&error(&text('dir_ehtpasswd', $file, $!));
close(FILE);
&unlock_file($file);
}
}
&flush_file_lines();
&switch_back();
&save_directories(\@dirs);
&unlock_all_files();
&webmin_log($in{'delete'} ? "delete" : $in{'new'} ? "create" : "modify",
"dir", $dir->[0]);
&redirect("");
htaccess-htpasswd/save_user.cgi 0100775 0005671 0000012 00000002526 07750634463 016677 0 ustar jcameron wheel #!/usr/local/bin/perl
# save_user.cgi
# Create, update or delete a password file user
require './htaccess-lib.pl';
&ReadParse();
&error_setup($text{'save_err'});
@dirs = &list_directories();
($dir) = grep { $_->[0] eq $in{'dir'} } @dirs;
&can_access_dir($dir->[0]) || &error($text{'dir_ecannot'});
&lock_file($dir->[1]);
&switch_user();
$users = &list_users($dir->[1]);
if (!$in{'new'}) {
$user = $users->[$in{'idx'}];
$loguser = $user->{'user'};
}
else {
$loguser = $in{'user'};
}
if ($in{'delete'}) {
# Just delete this user
&delete_user($user);
}
else {
# Validate inputs
$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'});
# Actually save
$user->{'user'} = $in{'user'};
if (!$in{'pass_def'}) {
$user->{'pass'} = &encrypt_password(
$in{'pass'}, undef, $dir->[2]);
}
$user->{'enabled'} = $in{'enabled'};
if ($in{'new'}) {
&create_user($user, $dir->[1]);
}
else {
&modify_user($user);
}
}
&switch_back();
&unlock_file($dir->[1]);
&webmin_log($in{'delete'} ? "delete" : $in{'new'} ? "create" : "modify",
"user", $loguser, $user);
&redirect("");
htaccess-htpasswd/defaultuconfig 0100664 0005671 0000012 00000000007 07756276267 017140 0 ustar jcameron wheel sort=0