local(@pids);
@pids = &find_byname($_[0]);
return scalar(@pids) if (&is_readonly_mode());
+&webmin_debug_log('KILL', "signal=$_[1] name=$_[0]")
+ if ($gconfig{'debug_what_write'});
if (@pids) { kill($_[1], @pids); return scalar(@pids); }
else { return 0; }
}
$cmd =~ s/^\((.*)\)\s*$/$1/;
$cmd .= $and;
&additional_log('exec', undef, $cmd);
+&webmin_debug_log('CMD', "cmd=$cmd") if ($gconfig{'debug_what_cmd'});
return `$realcmd`;
}
sub backquote_with_timeout
{
local $realcmd = &translate_command($_[0]);
+&webmin_debug_log('CMD', "cmd=$realcmd timeout=$_[1]")
+ if ($gconfig{'debug_what_cmd'});
local $out;
local $pid = &open_execute_command(OUT, "($realcmd) <$null_file", 1, $_[2]);
local $start = time();
return undef;
}
local $realcmd = &translate_command($_[0]);
+&webmin_debug_log('CMD', "cmd=$realcmd") if ($gconfig{'debug_what_cmd'});
return `$realcmd`;
}
sub kill_logged
{
return scalar(@_)-1 if (&is_readonly_mode());
+&webmin_debug_log('KILL', "signal=$_[0] pids=".join(" ", @_[1..@_-1]))
+ if ($gconfig{'debug_what_write'});
&additional_log('kill', $_[0], join(" ", @_[1..@_-1])) if (@_ > 1);
if ($gconfig{'os_type'} eq 'windows') {
# Emulate some kills with process.exe
print STDERR "Vetoing rename from $_[0] to $_[1]\n";
return 1;
}
-local $ok = rename(&translate_filename($_[0]),
- &translate_filename($_[1]));
+local $src = &translate_filename($_[0]);
+local $dst = &translate_filename($_[1]);
+&webmin_debug_log('RENAME', "src=$src dst=$dst")
+ if ($gconfig{'debug_what_write'});
+local $ok = rename($src, $dst);
if (!$ok && $! !~ /permission/i) {
# Try the mv command, in case this is a cross-filesystem rename
if ($gconfig{'os_type'} eq 'windows') {
print STDERR "Vetoing symlink from $_[0] to $_[1]\n";
return 1;
}
-return symlink(&translate_filename($_[0]),
- &translate_filename($_[1]));
+local $src = &translate_filename($_[0]);
+local $dst = &translate_filename($_[1]);
+&webmin_debug_log('SYMLINK', "src=$src dst=$dst")
+ if ($gconfig{'debug_what_write'});
+return symlink($src, $dst);
}
# link_file(src, dest)
print STDERR "Vetoing link from $_[0] to $_[1]\n";
return 1;
}
-unlink(&translate_filename($_[1])); # make sure link works
-return link(&translate_filename($_[0]),
- &translate_filename($_[1]));
+local $src = &translate_filename($_[0]);
+local $dst = &translate_filename($_[1]);
+&webmin_debug_log('LINK', "src=$src dst=$dst")
+ if ($gconfig{'debug_what_write'});
+unlink($dst); # make sure link works
+return link($src, $dst);
}
# make_dir(dir, perms, recursive)
}
$dir = &translate_filename($dir);
return 1 if (-d $dir && $recur); # already exists
+&webmin_debug_log('MKDIR', $dir) if ($gconfig{'debug_what_write'});
local $rv = mkdir($dir, $perms);
if (!$rv && $recur) {
# Failed .. try mkdir -p
return 1;
}
@files = map { &translate_filename($_) } @files;
+if ($gconfig{'debug_what_write'}) {
+ foreach my $f (@files) {
+ &webmin_debug_log('PERMS',
+ "file=$f user=$user group=$group perms=$perms");
+ }
+ }
local $rv = 1;
if (defined($user)) {
local $uid = $user !~ /^\d+$/ ? getpwnam($user) : $user;
my $err;
foreach my $f (@_) {
my $realf = &translate_filename($f);
+ &webmin_debug_log('UNLINK', $realf) if ($gconfig{'debug_what_write'});
if (-d $realf) {
if (!rmdir($realf)) {
if ($gconfig{'os_type'} eq 'windows') {
local ($src, $dst) = @_;
local $ok = 1;
local ($err, $out);
+&webmin_debug_log('COPY', "src=$src dst=$dst")
+ if ($gconfig{'debug_what_write'});
if ($gconfig{'os_type'} eq 'windows') {
# No tar or cp on windows, so need to use copy command
$src =~ s/\//\\/g;
$cmd = "($cmd)" if ($gconfig{'os_type'} ne 'windows');
return system("$cmd >$null_file 2>$null_file <$null_file");
}
+&webmin_debug_log('CMD', "cmd=$cmd") if ($gconfig{'debug_what_cmd'});
# Setup pipes
$| = 1; # needed on some systems to flush before forking
return open($fh, $null_file);
}
}
-elsif ($mode == 0) {
+# Really run it
+&webmin_debug_log('CMD', "cmd=$realcmd mode=$mode")
+ if ($gconfig{'debug_what_cmd'});
+if ($mode == 0) {
return open($fh, "| $cmd");
}
elsif ($mode == 1) {