diff --git a/at/macos-lib.pl b/at/macos-lib.pl index 4f9d0b586..c5604287a 100755 --- a/at/macos-lib.pl +++ b/at/macos-lib.pl @@ -35,21 +35,24 @@ return @rv; # create_atjob(user, time, commands, directory, send-email) sub create_atjob { -my @tm = localtime($_[1]); +my ($user, $tm, $cmds, $dir, $email) = @_; +my @tm = localtime($tm); my $date = sprintf "%2.2d:%2.2d %d.%d.%d", $tm[2], $tm[1], $tm[3], $tm[4]+1, $tm[5]+1900; -my $mailflag = $_[4] ? "-m" : ""; +my $mailflag = $email ? "-m" : ""; no strict "subs"; -&open_execute_command(AT, "su \"$_[0]\" -c \"cd $_[3] ; at $mailflag $date\" >/dev/null 2>&1", 0); -print AT $_[2]; +my $fullcmd = &command_as_user($user, 0, "cd $dir ; at $mailflag $date"); +&open_execute_command(AT, "$fullcmd >/dev/null 2>&1", 0); +print AT $cmds; close(AT); use strict "subs"; -&additional_log('exec', undef, "su \"$_[0]\" -c \"cd $_[3] ; at $mailflag $date\""); +&additional_log('exec', undef, $fullcmd); } # delete_atjob(id) sub delete_atjob { -&system_logged("atrm \"$_[0]\" >/dev/null 2>&1"); +my ($id) = @_; +&system_logged("atrm ".quotemeta($id)." >/dev/null 2>&1"); } diff --git a/at/openserver-lib.pl b/at/openserver-lib.pl index 3bc9ba01c..8aeb718a3 100755 --- a/at/openserver-lib.pl +++ b/at/openserver-lib.pl @@ -5,13 +5,13 @@ no warnings "redefine"; sub list_atjobs { -local @rv; +my @rv; opendir(DIR, $config{'at_dir'}) || return (); while($f = readdir(DIR)) { - local $p = "$config{'at_dir'}/$f"; + my $p = "$config{'at_dir'}/$f"; if ($f =~ /^(\d+)\.a(\S+)$/) { - local @st = stat($p); - local $job = { 'id' => $f, + my @st = stat($p); + my $job = { 'id' => $f, 'date' => $1, 'user' => scalar(getpwuid($st[4])), 'created' => $st[9] }; @@ -32,17 +32,20 @@ return @rv; # create_atjob(user, time, commands, directory) sub create_atjob { -local @tm = localtime($_[1]); -local $date = strftime "%H:%M %b %d", @tm; -&open_execute_command(AT, "su \"$_[0]\" -c \"cd $_[3] ; at $date\"", 0); -print AT $_[2]; +my ($user, $tm, $cmds, $dir) = @_; +my @tm = localtime($tm); +my $date = strftime "%H:%M %b %d", @tm; +my $fullcmd = &command_as_user($user, 0, "cd $dir ; at $date"); +&open_execute_command(AT, $fullcmd, 0); +print AT $cmds; close(AT); -&additional_log('exec', undef, "su \"$_[0]\" -c \"cd $_[3] ; at $date\""); +&additional_log('exec', undef, $fullcmd); } # delete_atjob(id) sub delete_atjob { -&system_logged("at -r \"$_[0]\""); +my ($id) = @_; +&system_logged("at -r ".quotemeta($id)); }