Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: a9923d64c8
Fetching contributors…

Cannot retrieve contributors at this time

executable file 101 lines (85 sloc) 2.538 kb
do 'acl-lib.pl';
# backup_config_files()
# Returns files and directories that can be backed up
sub backup_config_files
{
my @rv;
# Add primary user and group files
my %miniserv;
&get_miniserv_config(\%miniserv);
push(@rv, $miniserv{'userfile'});
push(@rv, &acl_filename());
# Add all .acl files for users and groups
foreach my $u (&list_users(), &list_groups()) {
if (!$u->{'proto'}) {
push(@rv, "$config_directory/$u->{'name'}.acl",
glob("$config_directory/*/$u->{'name'}.acl"));
}
}
# Add /etc/webmin/config
system("cp $config_directory/config $config_directory/config.aclbackup");
push(@rv, "$config_directory/config.aclbackup");
# Add /etc/webmin/miniserv.conf
system("cp $config_directory/miniserv.conf $config_directory/miniserv.conf.aclbackup");
push(@rv, "$config_directory/miniserv.conf.aclbackup");
return @rv;
}
# pre_backup(&files)
# Called before the files are actually read
sub pre_backup
{
return undef;
}
# post_backup(&files)
# Called after the files are actually read
sub post_backup
{
unlink("$config_directory/config.aclbackup");
unlink("$config_directory/miniserv.conf.aclbackup");
return undef;
}
# pre_restore(&files)
# Called before the files are restored from a backup
sub pre_restore
{
# Remove user and group .acl files
foreach my $u (&list_users(), &list_groups()) {
if (!$u->{'proto'}) {
unlink("$config_directory/$u->{'name'}.acl",
glob("$config_directory/*/$u->{'name'}.acl"));
}
}
return undef;
}
# post_restore(&files)
# Called after the files are restored from a backup
sub post_restore
{
# Splice global config entries for users into real config
my %aclbackup;
&read_file("$config_directory/config.aclbackup", \%aclbackup);
unlink("$config_directory/config.aclbackup");
foreach my $k (keys %gconfig) {
delete($gconfig{$k}) if ($k =~ /^(lang_|notabs_|skill_|risk_|theme_|ownmods_)/);
}
foreach my $k (keys %aclbackup) {
$gconfig{$k} = $aclbackup{$k} if ($k =~ /^(lang_|notabs_|skill_|risk_|theme_|ownmods_)/);
}
&write_file("$config_directory/config", \%gconfig);
# Splice miniserv.conf entries for users into real config
%aclbackup = ( );
&read_file("$config_directory/miniserv.conf.aclbackup", \%aclbackup);
unlink("$config_directory/miniserv.conf.aclbackup");
my %miniserv;
&get_miniserv_config(\%miniserv);
foreach $k (keys %miniserv) {
delete($miniserv{$k}) if ($k =~ /^(preroot_)/);
}
foreach $k (keys %aclbackup) {
$miniserv{$k} = $aclbackup{$k} if ($k =~ /^(preroot_)/);
}
&put_miniserv_config(\%miniserv);
&restart_miniserv();
return undef;
}
1;
Jump to Line
Something went wrong with that request. Please try again.