X7ROOT File Manager
Current Path:
/usr/libexec/webmin/virtualmin-htpasswd
usr
/
libexec
/
webmin
/
virtualmin-htpasswd
/
📁
..
📄
CHANGELOG
(404 B)
📄
LICENSE
(34.32 KB)
📄
add.cgi
(3.14 KB)
📄
add_form.cgi
(1.52 KB)
📄
cgi_args.pl
(279 B)
📄
create-protected-directory.pl
(4.78 KB)
📄
create-protected-user.pl
(3.63 KB)
📄
delete-protected-directory.pl
(3.35 KB)
📄
delete-protected-user.pl
(2.64 KB)
📄
delete.cgi
(1.82 KB)
📄
find.cgi
(1.79 KB)
📁
help
📄
index.cgi
(2.42 KB)
📄
install-type
(4 B)
📁
lang
📄
list-protected-directories.pl
(3.01 KB)
📄
list-protected-users.pl
(2.99 KB)
📄
module.info
(147 B)
📄
module.info.af.auto
(34 B)
📄
module.info.ar.auto
(49 B)
📄
module.info.be.auto
(41 B)
📄
module.info.bg.auto
(65 B)
📄
module.info.ca.auto
(44 B)
📄
module.info.cs.auto
(42 B)
📄
module.info.da.auto
(40 B)
📄
module.info.de.auto
(45 B)
📄
module.info.el.auto
(79 B)
📄
module.info.es.auto
(45 B)
📄
module.info.eu.auto
(43 B)
📄
module.info.fa.auto
(58 B)
📄
module.info.fi
(40 B)
📄
module.info.fr.auto
(47 B)
📄
module.info.he.auto
(45 B)
📄
module.info.hr.auto
(41 B)
📄
module.info.hu.auto
(40 B)
📄
module.info.it.auto
(41 B)
📄
module.info.ja.auto
(43 B)
📄
module.info.ko.auto
(39 B)
📄
module.info.lt.auto
(45 B)
📄
module.info.lv.auto
(41 B)
📄
module.info.ms.auto
(40 B)
📄
module.info.mt.auto
(43 B)
📄
module.info.nl
(42 B)
📄
module.info.no
(40 B)
📄
module.info.pl.auto
(39 B)
📄
module.info.pt.auto
(45 B)
📄
module.info.pt_BR.auto
(48 B)
📄
module.info.ro.auto
(40 B)
📄
module.info.ru.auto
(57 B)
📄
module.info.sk.auto
(40 B)
📄
module.info.sl.auto
(41 B)
📄
module.info.sv.auto
(38 B)
📄
module.info.th.auto
(111 B)
📄
module.info.tr.auto
(38 B)
📄
module.info.uk.auto
(63 B)
📄
module.info.ur.auto
(72 B)
📄
module.info.vi.auto
(41 B)
📄
module.info.zh.auto
(37 B)
📄
module.info.zh_TW.auto
(40 B)
📄
virtual_feature.pl
(7.38 KB)
📄
virtualmin-htpasswd-lib.pl
(2.03 KB)
Editing: create-protected-user.pl
#!/usr/bin/perl use strict; use warnings; our $module_name; =head1 create-protected-user.pl Add a user to some protected directory. This command adds a user to a protected directory, identified by the C<--domain> and C<--path> flags. The login for the new user must be set with C<--user>, and the initial password with the C<--pass> flag (or C<--encpass> if you have a pre-hashed password in the right format). To create a user that is initially blocked from logging in, use the C<--disabled> flag. =cut package virtualmin_htpasswd; if (!$module_name) { no warnings "once"; $main::no_acl_check++; use warnings "once"; $ENV{'WEBMIN_CONFIG'} ||= "/etc/webmin"; $ENV{'WEBMIN_VAR'} ||= "/var/webmin"; my $pwd; if ($0 =~ /^(.*)\/[^\/]+$/) { chdir($pwd = $1); } else { chop($pwd = `pwd`); } $0 = "$pwd/created-protected-user.pl"; require './virtualmin-htpasswd-lib.pl'; $< == 0 || die "create-protected-user must be run as root"; } my @OLDARGV = @ARGV; # Parse command-line args my ($dname, $path, $user, $pass, $encpass); my $enabled = 1; while(@ARGV > 0) { my $a = shift(@ARGV); if ($a eq "--domain") { $dname = shift(@ARGV); } elsif ($a eq "--path") { $path = shift(@ARGV); } elsif ($a eq "--user") { $user = shift(@ARGV); } elsif ($a eq "--pass") { $pass = shift(@ARGV); } elsif ($a eq "--encpass") { $encpass = shift(@ARGV); } elsif ($a eq "--enabled") { $enabled = 1; } elsif ($a eq "--disabled") { $enabled = 0; } else { &usage(); } } # Validate parameters $dname || &usage("Missing --domain parameter"); $path || &usage("Missing --directory parameter"); my $d = &virtual_server::get_domain_by("dom", $dname); $d || &usage("No domain named $dname found"); $user || &usage("Missing --user parameter"); $pass || $encpass || &usage("Missing --pass or --encpass parameter"); # Get the directories for this domain my @dirs = &htaccess_htpasswd::list_directories(); @dirs = grep { &can_directory($_->[0], $d) } @dirs; my ($dir) = grep { $_->[0] eq $path || &remove_public_html($_->[0], $d) eq $path } @dirs; $dir || &usage("Directory $path is not registered"); # Get the current users for the dir and check for a clash my $users = $dir->[2] == 3 ? &htaccess_htpasswd::list_digest_users($dir->[1]) : &htaccess_htpasswd::list_users($dir->[1]); my ($clash) = grep { $_->{'user'} eq $user } @$users; $clash && &usage("A user named $user already exists"); # Add a new user object my $suser = { 'user' => $user, 'dom' => $d->{'dom'}, 'enabled' => $enabled }; if ($encpass) { $suser->{'pass'} = $encpass; } else { $suser->{'pass'} = &htaccess_htpasswd::encrypt_password( $pass, undef, $dir->[2]); } &virtual_server::write_as_domain_user($d, sub { &htaccess_htpasswd::create_user($suser, $dir->[1]) }); print "Created $suser->{'user'} in $dir->[1]\n"; sub usage { print "$_[0]\n\n" if ($_[0]); print "Add a user to some protected directory.\n"; print "\n"; print "virtualmin create-protected-user --domain name\n"; print " --path directory\n"; print " --user username\n"; print " [--pass password | --encpass hash]\n"; print " [--enabled | --disabled]\n"; exit(1); }
Upload File
Create Folder