Compare commits

...

3 Commits

Author SHA1 Message Date
Robin Appelman 349ecf1046
extra debug for readonly stat
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-03-15 17:51:28 +01:00
Robin Appelman 87d41f4bff
double check readonly root with stat call
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-03-12 17:49:10 +01:00
Robin Appelman b04ef9afde
debug mode when readonly is detected
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-03-12 16:11:42 +01:00
2 changed files with 27 additions and 4 deletions

View File

@ -64,10 +64,21 @@ class NativeFileInfo implements IFileInfo {
$rawAttributes = explode(',', $this->share->getAttribute($this->path, 'system.dos_attr.*'));
$this->attributeCache = [];
foreach ($rawAttributes as $rawAttribute) {
list($name, $value) = explode(':', $rawAttribute);
[$name, $value] = explode(':', $rawAttribute);
$name = strtolower($name);
if ($name == 'mode') {
$this->attributeCache[$name] = (int)hexdec(substr($value, 2));
$mode = (int)hexdec(substr($value, 2));
if ($mode > 0x1000) {
$readonly = !(bool)($mode & 0x80); // 0x80: owner write permissions
} else {
$readonly = (bool)($mode & IFileInfo::MODE_READONLY);
}
if ($readonly) {
\OC::$server->getLogger()->warning("Readonly file mode $value for ". $this->path);
$stat = $this->share->getStat($this->path);
\OC::$server->getLogger()->warning("Stat for readonly file is is: ". json_encode($stat));
}
$this->attributeCache[$name] = $mode;
} else {
$this->attributeCache[$name] = (int)$value;
}
@ -112,7 +123,7 @@ class NativeFileInfo implements IFileInfo {
// Let us ignore the ATTR_NOT_CONTENT_INDEXED for now
$mode &= ~0x00002000;
return $mode;
}
@ -136,7 +147,15 @@ class NativeFileInfo implements IFileInfo {
if ($mode > 0x1000) {
return !(bool)($mode & 0x80); // 0x80: owner write permissions
} else {
return (bool)($mode & IFileInfo::MODE_READONLY);
$readonly = (bool)($mode & IFileInfo::MODE_READONLY);
if ($readonly && $this->path = "") {
// there seems to be a difference behavior between the various ways of getting the mode when querying the root, double check readonly status
$stat = $this->share->getStat($this->path);
\OC::$server->getLogger()->warning("Readonly root detected, stat for root is: ". json_encode($stat));
return (bool)($stat['mode'] && IFileInfo::MODE_READONLY);
} else {
return $readonly;
}
}
}

View File

@ -115,6 +115,10 @@ class NativeShare extends AbstractShare {
return $info;
}
public function getStat(string $path): array {
return $this->getState()->stat($this->buildUrl($path));
}
/**
* Multibyte unicode safe version of basename()
*