local @tm = localtime($_[1]);
local $date = sprintf "%2.2d:%2.2d %d.%d.%d",
$tm[2], $tm[1], $tm[3], $tm[4]+1, $tm[5]+1900;
-&open_execute_command(AT, "su \"$_[0]\" -c \"cd $_[3] ; at $date\" >/dev/null 2>&1", 0);
+local $cmd = "cd ".quotemeta($_[3])." ; at $date";
+local @uinfo = getpwnam($_[0]);
+if ($uinfo[2] != $<) {
+ # Only SU if we are not already the user
+ $cmd = &command_as_user($_[0], 0, $cmd);
+ }
+&open_execute_command(AT, "$cmd >/dev/null 2>&1", 0);
print AT $_[2];
close(AT);
&additional_log('exec', undef, "su \"$_[0]\" -c \"cd $_[3] ; at $date\"");
# delete_atjob(id)
sub delete_atjob
{
-&system_logged("atrm \"$_[0]\" >/dev/null 2>&1");
+&system_logged("atrm ".quotemeta($_[0])." >/dev/null 2>&1");
}
{
local @tm = localtime($_[1]);
local $date = strftime "%H:%M %b %d", @tm;
-&open_execute_command(AT, "su \"$_[0]\" -c \"cd $_[3] ; at $date\"", 0);
+local $cmd = "cd ".quotemeta($_[3])." ; at $date";
+local @uinfo = getpwnam($_[0]);
+if ($uinfo[2] != $<) {
+ # Only SU if we are not already the user
+ $cmd = &command_as_user($_[0], 0, $cmd);
+ }
+&open_execute_command(AT, "$cmd >/dev/null 2>&1", 0);
print AT $_[2];
close(AT);
&additional_log('exec', undef, "su \"$_[0]\" -c \"cd $_[3] ; at $date\"");
# delete_atjob(id)
sub delete_atjob
{
-&system_logged("at -r \"$_[0]\"");
+&system_logged("at -r ".quotemeta($_[0]));
}
local @tm = localtime($_[1]);
local $date = sprintf "%2.2d:%2.2d %d.%d.%d",
$tm[2], $tm[1], $tm[3], $tm[4]+1, $tm[5]+1900;
-local $cmd = "cd $_[3]; at $date";
+local $cmd = "cd ".quotemeta($_[3])." ; at $date";
local @uinfo = getpwnam($_[0]);
if ($uinfo[2] != $<) {
# Only SU if we are not already the user
- $cmd = "su \"$_[0]\" -c \"$cmd\"";
+ $cmd = &command_as_user($_[0], 0, $cmd);
}
&open_execute_command(AT, "$cmd >/dev/null 2>&1", 0);
print AT $_[2];
# delete_atjob(id)
sub delete_atjob
{
-&system_logged("atrm \"$_[0]\" >/dev/null 2>&1");
+&system_logged("atrm ".quotemeta($_[0])." >/dev/null 2>&1");
}
{
local @tm = localtime($_[1]);
local $date = strftime "%H:%M %b %d", @tm;
-local $cmd = "cd $_[3]; at $date";
+local $cmd = "cd ".quotemeta($_[3])." ; at $date";
local @uinfo = getpwnam($_[0]);
if ($uinfo[2] != $<) {
# Only SU if we are not already the user
- $cmd = "su \"$_[0]\" -c \"$cmd\"";
+ $cmd = &command_as_user($_[0], 0, $cmd);
}
-&open_execute_command(AT, "$cmd ; at $date\"", 0);
+&open_execute_command(AT, "$cmd >/dev/null 2>&1", 0);
print AT $_[2];
close(AT);
&additional_log('exec', undef, $cmd);
# delete_atjob(id)
sub delete_atjob
{
-&system_logged("atrm \"$_[0]\"");
+&system_logged("atrm ".quotemeta($_[0]));
}
&clean_environment();
$ENV{'REMOTE_USER'} = $remote_user; # For usermin
$ENV{'BASE_REMOTE_USER'} = $base_remote_user;
- &at::create_atjob("root", $download{'time'},
- "$atjob_cmd $download{'id'}", "/");
+ &at::create_atjob(
+ $module_info{'usermin'} ? $remote_user : "root",
+ $download{'time'},
+ "$atjob_cmd $download{'id'}",
+ "/");
&reset_environment();
}
}
$can_upload = $config{'upload'};
$can_download = $config{'download'};
$can_fetch = $config{'fetch'};
- $can_schedule = 0;
+ $can_schedule = $config{'background'} && &foreign_check("at");
$can_background = $config{'background'};
if ($config{'home_only'}) {
@can_dirs = ( &resolve_links($remote_user_info[7]),