Fix save and run cron job when changing user

http://www.virtualmin.com/node/18806
This commit is contained in:
Jamie Cameron
2011-07-12 16:48:38 -07:00
parent 31fedb5efb
commit 44b35a85dd
3 changed files with 15 additions and 1 deletions

View File

@@ -338,7 +338,8 @@ else {
$_[0]->{'line'} = scalar(@$lref);
push(@$lref, &cron_job_line($_[0]));
&flush_file_lines();
system("chown $_[0]->{'user'} $cron_temp_file");
&set_ownership_permissions($_[0]->{'user'}, undef, undef,
$cron_temp_file);
&copy_crontab($_[0]->{'user'});
$_[0]->{'file'} = "$config{'cron_dir'}/$_[0]->{'user'}";
$_[0]->{'index'} = scalar(@cron_jobs_cache);

View File

@@ -75,6 +75,7 @@ save_eallow=The user '$1' is not allowed to access cron
save_ecannot=You are not allowed to create or edit cron jobs for '$1'
save_enone=You did not choose any $1 to execute
save_ecannot2=You are not allowed to create cron jobs
save_eidx=Cron job was successfully saved, but cannot be run as it was not found!
allow_title=Control Cron Access
allow_desc=This form allows you to control which users can create and run cron jobs.

View File

@@ -79,6 +79,17 @@ if (!$in{'new'}) {
else {
&delete_cron_job($oldjob);
&create_cron_job($job);
# Find new index, which will change due to user move
undef(@cron_jobs_cache);
$in{'idx'} = undef;
foreach $newjob (&list_cron_jobs()) {
if ($newjob->{'user'} eq $job->{'user'} &&
$newjob->{'active'} eq $job->{'active'} &&
$newjob->{'command'} eq $job->{'command'}) {
$in{'idx'} = $newjob->{'index'};
}
}
}
}
else {
@@ -96,6 +107,7 @@ else {
if ($in{'saverun'}) {
# Redirect to execute form
defined($in{'idx'}) || &error($text{'save_eidx'});
&redirect("exec_cron.cgi?idx=$in{'idx'}");
}
else {