Skip to content

Commit

Permalink
Perioically refesh jail dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron committed Apr 16, 2017
1 parent ea0445e commit 1aea242
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 2 deletions.
3 changes: 3 additions & 0 deletions collectinfo.pl
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ package virtual_server;

# For any domains that are due for a let's encrypt cert renewal, do it now
&apply_letsencrypt_cert_renewals();

# Resync all jails
&copy_all_domain_jailkit_files();
1 change: 1 addition & 0 deletions config
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,4 @@ home_backup=virtualmin-backup
show_validation=0
jailkit_root=/home/chroot
defujail=0
jail_age=24
1 change: 1 addition & 0 deletions config-freebsd
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,4 @@ home_backup=virtualmin-backup
show_validation=0
jailkit_root=/home/chroot
defujail=0
jail_age=24
1 change: 1 addition & 0 deletions config.info
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,4 @@ mx_validate=Validate MX records for domains with email?,1,0-Yes,1-No
scriptdir=Template for default script directory,10,-Script default,*-Top level public_html directory,Directory template
python_cmd=Path to <tt>python</tt> command,3,Use system default
jailkit_root=Base directory for Jailkit directories,0
jail_age=Hours between Jailkit root directory refreshes,3,Never refesh automatically
20 changes: 20 additions & 0 deletions jailkit-lib.pl
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,27 @@ sub copy_jailkit_files
return &text('jailkit_einit', $err);
}
}
$d->{'jail_last_copy'} = time();
return undef;
}

# copy_all_domain_jailkit_files()
# For all domains with a jail enabled and which haven't copied files in the
# last 24 hours, copy them now
sub copy_all_domain_jailkit_files
{
foreach my $d (&list_domains()) {
next if ($d->{'parent'});
my $dir = &domain_jailkit_dir($d);
next if (!$dir || !-d $dir);
if ($config{'jail_age'} &&
time() - $d->{'jail_last_copy'} > $config{'jail_age'}*3600) {
# Time to sync
&copy_jailkit_files($d, $dir);
$d->{'jail_last_copy'} = time();
&save_domain($d);
}
}
}

1;
4 changes: 2 additions & 2 deletions save_limits.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ if (defined($in{'shell'})) {
# Update jail
if (!&check_jailkit_support()) {
my $oldjail = &get_domain_jailkit($d);
if (!$oldjail && $in{'jail'}) {
# Setup jail for this user
if ($in{'jail'}) {
# Setup or re-sync jail for this user
$err = &enable_domain_jailkit($d);
&error(&text('limits_ejailon', $err)) if ($err);
$d->{'jail'} = 1 if (!$err);
Expand Down

0 comments on commit 1aea242

Please sign in to comment.