Fix old stat() code and support stat_mode

This commit is contained in:
2019-06-13 02:24:23 -07:00
parent 30f646f141
commit 4f1ef015b3

View File

@@ -435,18 +435,25 @@ foreach ($files as $splFileInfo) {
} }
// capture stat before values change // Collect file stat()
if ($p['stat_mode']) {
$sty[$i] = statToArray(shell_exec("stat -s ".$shellpath." 2>&1"));
if ($p['stat_mode'] > 1 && $splFileInfo->getType() != "link") {
// capture stat values for postflight comparison
$stx[$i] = array($splFileInfo->getATime(), $splFileInfo->getMTime(), $splFileInfo->getCTime());
}
} else {
$sty[$i] = "bypass";
if ($splFileInfo->getType() != "link") {
$stx[$i] = array( $splFileInfo->getATime(),
$splFileInfo->getMTime(),
$splFileInfo->getCTime() );
} }
$sty[$i] = statToArray(shell_exec("stat -s ".$shellpath." 2>&1"));
//$sty[$i] = "bypass";
// Check file can be read // Check file can be read
if ($realpath && !is_readable($realpath)) { if ($realpath && !is_readable($realpath)) {
@@ -1168,13 +1175,13 @@ foreach ($files as $splFileInfo) {
// Double check stat for file against pre-run value // Double check stat for file against pre-run value
if ($p['verify_stat'] && $type != "link") { if ($p['stat_mode'] > 1 && $type != "link") {
$restat = statToArray(shell_exec("stat -s ".$shellpath." 2>&1")); $restat = statToArray(shell_exec("stat -s ".$shellpath." 2>&1"));
$message = array(); $message = array();
if ($sty[$j]['st_atime'] != $restat['st_atime']) { if ($sty[$j]['st_atime'] != $restat['st_atime']) {
if ($p['fixatimes'] && $type != "link" && is_writable($pathname)) { if ($p['stat_mode'] == 3 && is_writable($pathname)) {
exec("touch -at `date -r ".$sty[$j]['st_atime']." +%Y%m%d%H%M.%S` ".$shellpath." 2>&1"); exec("touch -at `date -r ".$sty[$j]['st_atime']." +%Y%m%d%H%M.%S` ".$shellpath." 2>&1");
$message[] = "atime (fix)"; $message[] = "atime (fix)";
} else { } else {