-# cron-lib.pl
-# Common crontab functions
+=head1 cron-lib.pl
+
+Common crontab functions
+
+=cut
do '../web-lib.pl';
&init_config();
$cron_temp_file = &transname();
use Time::Local;
-# list_cron_jobs()
-# Returns a lists of structures of all cron jobs
+=head2 list_cron_jobs
+
+Returns a lists of structures of all cron jobs
+
+=cut
sub list_cron_jobs
{
local (@rv, $lnum, $f);
return join(" ", @c);
}
-# copy_cron_temp(&job)
-# Copies a job's user's current cron configuration to the temp file
+=head2 copy_cron_temp(&job)
+
+Copies a job's user's current cron configuration to the temp file
+
+=cut
sub copy_cron_temp
{
local $fcron = ($config{'cron_dir'} =~ /\/fcron$/);
}
}
-# create_cron_job(&job)
-# Add a Cron job to a user's file
+=head2 create_cron_job(&job)
+
+Add a Cron job to a user's file
+
+=cut
sub create_cron_job
{
&check_cron_config_or_error();
}
}
-# insert_cron_job(&job)
-# Add a Cron job at the top of the user's file
+=head2 insert_cron_job(&job)
+
+Add a Cron job at the top of the user's file
+
+=cut
sub insert_cron_job
{
&check_cron_config_or_error();
}
}
-# renumber(file, line, offset)
-# All jobs in this file whose line is at or after the given one will be
-# incremented by the offset
+=head2 renumber(file, line, offset)
+
+All jobs in this file whose line is at or after the given one will be
+incremented by the offset
+
+=cut
sub renumber
{
local $j;
}
}
-# renumber_index(index, offset)
+=head2 renumber_index(index, offset)
+
+MISSING DOCUMENTATION
+
+=cut
sub renumber_index
{
local $j;
}
}
-# change_cron_job(&job)
+=head2 change_cron_job(&job)
+
+MISSING DOCUMENTATION
+
+=cut
sub change_cron_job
{
if ($_[0]->{'type'} == 0) {
}
}
-# delete_cron_job(&job)
+=head2 delete_cron_job(&job)
+
+MISSING DOCUMENTATION
+
+=cut
sub delete_cron_job
{
if ($_[0]->{'type'} == 0) {
&renumber_index($_[0]->{'index'}, -1);
}
-# read_crontab(user)
-# Return an array containing the lines of the cron table for some user
+=head2 read_crontab(user)
+
+Return an array containing the lines of the cron table for some user
+
+=cut
sub read_crontab
{
local(@tab);
}
-# copy_crontab(user)
-# Copy the cron temp file to that for this user
+=head2 copy_crontab(user)
+
+Copy the cron temp file to that for this user
+
+=cut
sub copy_crontab
{
if (&is_readonly_mode()) {
}
-# parse_job(job)
-# Parse a crontab line into an array containing:
-# active, mins, hrs, days, mons, weekdays, command
+=head2 parse_job(job)
+
+Parse a crontab line into an array containing:
+active, mins, hrs, days, mons, weekdays, command
+
+=cut
sub parse_job
{
local($job, $active) = ($_[0], 1);
return ($active, $1, $2, $3, $4, $5, $6);
}
-# user_sub(command, user)
-# Replace the string 'USER' in the command with the user name
+=head2 user_sub(command, user)
+
+Replace the string 'USER' in the command with the user name
+
+=cut
sub user_sub
{
local($tmp);
}
-# list_allowed()
-# Returns a list of all users in the cron allow file
+=head2 list_allowed
+
+Returns a list of all users in the cron allow file
+
+=cut
sub list_allowed
{
local(@rv, $_);
}
-# list_denied()
-# Return a list of users from the cron deny file
+=head2 list_denied
+
+Return a list of users from the cron deny file
+
+=cut
sub list_denied
{
local(@rv, $_);
}
-# save_allowed(user, user, ...)
-# Save the list of allowed users
+=head2 save_allowed(user, user, ...)
+
+Save the list of allowed users
+
+=cut
sub save_allowed
{
local($_);
}
-# save_denied(user, user, ...)
-# Save the list of denied users
+=head2 save_denied(user, user, ...)
+
+Save the list of denied users
+
+=cut
sub save_denied
{
local($_);
chmod(0444, $config{cron_deny_file});
}
-# read_envs(user)
-# Returns an array of name,value pairs containing the environment settings
-# from the crontab for some user
+=head2 read_envs(user)
+
+Returns an array of name,value pairs containing the environment settings
+from the crontab for some user
+
+=cut
sub read_envs
{
local(@tab, @rv, $_);
return @rv;
}
-# save_envs(user, [name, value]*)
-# Updates the cron file for some user with the given list of environment
-# variables. All others in the file are removed
+=head2 save_envs(user, [name, value]*)
+
+Updates the cron file for some user with the given list of environment
+variables. All others in the file are removed
+
+=cut
sub save_envs
{
local($i, @tab, $line);
©_crontab($_[0]);
}
-# expand_run_parts(directory)
+=head2 expand_run_parts(directory)
+
+MISSING DOCUMENTATION
+
+=cut
sub expand_run_parts
{
local $dir = $_[0];
return @rv;
}
-# is_run_parts(command)
+=head2 is_run_parts(command)
+
+MISSING DOCUMENTATION
+
+=cut
sub is_run_parts
{
local $rp = $config{'run_parts'};
return $rp && $_[0] =~ /$rp(.*)\s+([a-z0-9\.\-\/_]+)(\s*\))?$/i ? $2 : undef;
}
-# can_edit_user(&access, user)
+=head2 can_edit_user(&access, user)
+
+MISSING DOCUMENTATION
+
+=cut
sub can_edit_user
{
local %umap;
}
}
-# show_times_input(&job, [nospecial])
+=head2 show_times_input(&job, [nospecial])
+
+MISSING DOCUMENTATION
+
+=cut
sub show_times_input
{
return &theme_show_times_input(@_) if (defined(&theme_show_times_input));
print "</tr> <tr $cb> <td colspan=5>$text{'edit_ctrl'}</td> </tr>\n";
}
-# parse_times_input(&job, &in)
+=head2 parse_times_input(&job, &in)
+
+MISSING DOCUMENTATION
+
+=cut
sub parse_times_input
{
local $job = $_[0];
}
}
-# show_range_input(&job)
-# Given a cron job, prints fields for selecting it's run date range
+=head2 show_range_input(&job)
+
+Given a cron job, prints fields for selecting it's run date range
+
+=cut
sub show_range_input
{
local ($job) = @_;
print &ui_oneradio("range_def", 0, $rng, $has_start),"\n";
}
-# parse_range_input(&job, &in)
-# Updates the job object with the specified date range. May call &error
-# for invalid inputs
+=head2 parse_range_input(&job, &in)
+
+Updates the job object with the specified date range. May call &error
+for invalid inputs
+
+=cut
sub parse_range_input
{
local ($job, $in) = @_;
'jul', 'aug', 'sep', 'oct', 'nov', 'dec' );
@cron_weekday = ( 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat' );
-# fix_names(&cron)
-# Convert day and month names to numbers
+=head2 fix_names(&cron)
+
+Convert day and month names to numbers
+
+=cut
sub fix_names
{
local ($m, $w);
$_[0]->{'weekdays'} = join(",", @wds);
}
-# create_wrapper(wrapper-path, module, script)
-# Creates a wrapper script which calls a script in some module's directory
-# with the proper webmin environment variables set. This should always be used
-# when setting up a cron job, instead of attempting to run a command in the
-# module directory directly.
+=head2 create_wrapper(wrapper-path, module, script)
+
+Creates a wrapper script which calls a script in some module's directory
+with the proper webmin environment variables set. This should always be used
+when setting up a cron job, instead of attempting to run a command in the
+module directory directly.
+
+=cut
sub create_wrapper
{
local $perl_path = &get_perl_path();
chmod(0755, $_[0]);
}
-# cron_file(&job)
-# Returns the file that a cron job is in, or would be in
+=head2 cron_file(&job)
+
+Returns the file that a cron job is in, or would be in
+
+=cut
sub cron_file
{
return $_[0]->{'file'} || "$config{'cron_dir'}/$_[0]->{'user'}";
}
-# when_text(&job, [upper-case-first])
-# Returns a text string describing when a cron job is run
+=head2 when_text(&job, [upper-case-first])
+
+Returns a text string describing when a cron job is run
+
+=cut
sub when_text
{
local $pfx = $_[1] ? "uc" : "";
}
}
-# can_use_cron(user)
-# Returns 1 if some user is allowed to use cron, based on cron.allow and
-# cron.deny files
+=head2 can_use_cron(user)
+
+Returns 1 if some user is allowed to use cron, based on cron.allow and
+cron.deny files
+
+=cut
sub can_use_cron
{
local $err;
return !$err;
}
-# swap_cron_jobs(&job1, &job2)
-# Swaps two Cron jobs, which must be in the same file
+=head2 swap_cron_jobs(&job1, &job2)
+
+Swaps two Cron jobs, which must be in the same file
+
+=cut
sub swap_cron_jobs
{
if ($_[0]->{'type'} == 0) {
}
}
-# find_cron_process(&job, [&procs])
-# Finds the running process that was launched from a cron job.
-# job - A cron job hash reference
-# procs - An optional array reference of running process hash refs
+=head2 find_cron_process(&job, [&procs])
+
+Finds the running process that was launched from a cron job.
+job - A cron job hash reference
+procs - An optional array reference of running process hash refs
+
+=cut
sub find_cron_process
{
local @procs;
return $proc;
}
-# extract_input(command)
-# Given a command line cmd%input , returns the command and input parts
+=head2 extract_input(command)
+
+Given a command line cmd%input , returns the command and input parts
+
+=cut
sub extract_input
{
local ($cmd) = @_;
return ($cmd, $input);
}
-# convert_range(&job)
-# Given a cron job that uses range.pl , work out the date range and update
-# the job object command
+=head2 convert_range(&job)
+
+Given a cron job that uses range.pl , work out the date range and update
+the job object command
+
+=cut
sub convert_range
{
local ($job) = @_;
return 0;
}
-# unconvert_range(&job)
+=head2 unconvert_range(&job)
+
+MISSING DOCUMENTATION
+
+=cut
sub unconvert_range
{
local ($job) = @_;
return 0;
}
-# convert_comment(&job)
-# Given a cron job with a # command after the command, sets the comment field
+=head2 convert_comment(&job)
+
+Given a cron job with a # command after the command, sets the comment field
+
+=cut
sub convert_comment
{
local ($job) = @_;
return 0;
}
-# unconvert_comment(&job)
-# Adds an comment back to the command in a cron job
+=head2 unconvert_comment(&job)
+
+Adds an comment back to the command in a cron job
+
+=cut
sub unconvert_comment
{
local ($job) = @_;
return 0;
}
-# check_cron_config()
-# Returns an error message if the cron config doesn't look valid
+=head2 check_cron_config
+
+Returns an error message if the cron config doesn't look valid
+
+=cut
sub check_cron_config
{
# Check for single file and getter command