I notice that permissions to nextcloud.log
keep resetting to rw-r-----
. I can give write permissions to the group but the perms don’t last. This is most inconvenient during testing with phpunit, which is run by a different user than the webserver, as only the first test passes and the next fails due to insufficient write privileges.
I tried setting the file permissions to rw-rw----
with the webserver stopped but there seems to be some logic that removes group write permissions right on the first file access. I also could not find a likely setting in config.php
.
Any clue, anybody?
Suffering from a similar issue locally on my dev instance I have this patch applied:
diff --git a/lib/private/Log/File.php b/lib/private/Log/File.php
index a33667c9b6..472fa6b60e 100644
--- a/lib/private/Log/File.php
+++ b/lib/private/Log/File.php
@@ -80,10 +80,13 @@ class File extends LogDetails implements IWriter, IFileBased {
* @param int $level
*/
public function write(string $app, $message, int $level) {
+// if (strpos($message, 'Failed to open stream: Permission denied at')) {
+// return;
+// }
$entry = $this->logDetailsAsJSON($app, $message, $level);
$handle = @fopen($this->logFile, 'a');
if ($this->logFileMode > 0 && is_file($this->logFile) && (fileperms($this->logFile) & 0777) != $this->logFileMode) {
- @chmod($this->logFile, $this->logFileMode);
+// @chmod($this->logFile, $this->logFileMode);
}
if ($handle) {
fwrite($handle, $entry."\n");
@nickvergessen: thanks, that seems a good solution
Meanwhile I helped myself with sudo -u www gmake test
I think it is not a good idea to use a different user for testing. Perhaps other parts of webserver/nextcloud do use different user/group-rights, too. What do you want to test? Webserver/Nextcloud or a test user?
And for security reason: Always use only a copy of the system.
You are probably right, I shall resolve to using sudo
.
I am working my way into testing my own app on NC and just want to get it right.