Chmod(): Operation not permitted at /usr/share/webapps/nextcloud/lib/private/Log/File.php#84

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version: 18.0.3-1
Operating system and version: Arch Linux 5.6.4.arch1-1
nginx version: 1.17.10
PHP version: 7.4.5-1

The Nextcloud log has multiple entries regarding chmod errors pertaining to a specific file.

The file in question is /usr/share/webapps/nextcloud/lib/private/Log/File.php

It is owned by http:http; its permissions are set at 755 (-rwxr-xr-x)

Nextcloud seems to work without issue, but perhaps something is broken, and I just haven’t recognized it yet.

Is this the first time you’ve seen this error?: Y

Steps to replicate it:

  1. Upgrade to Nextcloud 18
  2. Upgrade to PHP 7.4
  3. Use Nextcloud calendar, files, and Logging features

The output of your Nextcloud log in Admin > Logging:

{"reqId":"wVQqW0btO6itxW3QwDQx","level":3,"time":"2020-04-16T14:02:13+00:00","remoteAddr":"xxx.xxx.xxx.xxx","user":"--","app":"PHP","method":"GET","url":"/apps/theming/styles?v=2","message":"chmod(): Operation not permitted at /usr/share/webapps/nextcloud/lib/private/Log/File.php#84","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0","version":"18.0.3.0"}
{"reqId":"hM5SduLb2Prjjw90UmuV","level":3,"time":"2020-04-16T14:02:17+00:00","remoteAddr":"xxx.xxx.xxx.xxx","user":"ncuser","app":"PHP","method":"GET","url":"/apps/files/","message":"chmod(): Operation not permitted at /usr/share/webapps/nextcloud/lib/private/Log/File.php#84","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0","version":"18.0.3.0"}
{"reqId":"87WYLBX5L7rPmHoBucwj","level":3,"time":"2020-04-16T14:02:29+00:00","remoteAddr":"xxx.xxx.xxx.xxx","user":"ncuser","app":"PHP","method":"GET","url":"/apps/calendar/","message":"chmod(): Operation not permitted at /usr/share/webapps/nextcloud/lib/private/Log/File.php#84","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0","version":"18.0.3.0"}
{"reqId":"yWI0LCpV623FYpZfli8z","level":3,"time":"2020-04-16T14:08:08+00:00","remoteAddr":"xxx.xxx.xxx.xxx","user":"ncuser","app":"PHP","method":"GET","url":"/settings/user","message":"chmod(): Operation not permitted at /usr/share/webapps/nextcloud/lib/private/Log/File.php#84","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0","version":"18.0.3.0"}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'redacted',
  'passwordsalt' => 'redacted',
  'secret' => 'redacted',
  'trusted_domains' => 
  array (
    0 => 'cloud.redacted.com',
  ),
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'dbindex' => 0,
    'password' => 'secret',
    'timeout' => 1.5,
  ),
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'datadirectory' => '/redacted/redacted',
  'dbtype' => 'mysql',
  'version' => '18.0.3.0',
  'overwrite.cli.url' => 'https://cloud.redacted.com',
  'dbname' => 'redacted',
  'dbhost' => 'localhost',
  'dbport' => 'redacted',
  'dbtableprefix' => 'redacted',
  'mysql.utf8mb4' => true,
  'dbuser' => 'redacted',
  'dbpassword' => 'redacted',
  'installed' => true,
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud-error.log',
  'loglevel' => 3,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'redacted',
  'mail_domain' => 'redacted',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'mail.redacted.com',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'redacted@redacted.com',
  'mail_smtppassword' => 'redacted',
  'maintenance' => false,
  'theme' => '',
  'app_install_overwrite' => 
  array (
    0 => 'files_rightclick',
    1 => 'files_reader',
  ),
);

The output of your nginx log in /var/log/nginx:

2020/04/16 08:11:41 [warn] 1188#1188: *121 an upstream response is buffered to a temporary file /var/lib/nginx/proxy/1/00/0000000001 while reading upstream, client: redacted, server: cloud.redacted.com, request: "GET /loleaflet/a96fdaa/bundle.js HTTP/2.0", upstream: "https://127.0.0.1:9980/loleaflet/a96fdaa/bundle.js", host: "cloud.redacted.com"
2020/04/17 11:21:20 [warn] 8419#8419: *1 an upstream response is buffered to a temporary file /var/lib/nginx/proxy/1/00/0000000001 while reading upstream, client: redacted, server: cloud.redacted.com, request: "GET /loleaflet/a96fdaa/bundle.js HTTP/2.0", upstream: "https://127.0.0.1:9980/loleaflet/a96fdaa/bundle.js", host: "cloud.redacted.com"

Ping on this. Anyone have a solution to this? This must be a widespread problem.

Please post your correct username for nginx, nextcloud, MariaDB.

Please also post:

ls -al /redacted/redacted

Control that all files and directorys are correctly owned.

I don’t know why, but perhaps just through updating linux, Nextcloud, and all the surrounding apps, I no longer have this problem.

buzz

@devnull This problem is back again. It may have to do with how the Arch Linux Nextcloud package is configured. I don’t know.

Here’s the error message currently populating my nextcloud-error.log file:

`

{“reqId”:“3ldo9kwG84XGb87ZemzR”,“level”:3,“time”:“2020-11-01T17:19:20+00:00”,“remoteAddr”:“123.123.123.123”,“user”:“myUser”,“app”:“PHP”,“method”:“GET”,“url”:"/index.php/apps/files/ajax/getstoragestats.php?dir=%2F",“message”:“chmod(): Operation not permitted at /usr/share/webapps/nextcloud/lib/private/Log/File.php#87”,“userAgent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0”,“version”:“20.0.1.1”}

`
Questions:

  1. “user”:“myUser” <–Is this my nextcloud user or my linux user or something else?
  2. The above user “myUser” asked PHP to run the getstoragestats script. <-- True?
  3. The getstoragestats script is trying to change the mode of the File script, but isn’t allowed to. <-- True?
  4. If #3 is true, is PHP attempting this operation as the nextcloud user, the linux user, or a different user?

User Confusion. which user is trying to do what?

  1. Nextcloud user: the user name I use when I log into Nextcloud
  2. My webserver user, which owns nearly all the files and folders in my /usr/share/webapps/nextcloud/* tree.
  3. The linux user, which probably doesn’t matter (?), since my server typically has no user logged in.
  4. PHP user? Is there such a thing
  5. MariaDB (MySQL) user: there’s a Nextcloud table in the MariaDB. could this be a factor in this error?

Is anyone able help me understand which account is trying to do what? Then, I can update file permissions (or whatever needs to be done) to finally be free fo thsi problem.

Thank you!

buzz

“chmod” is a linux/unix command is only executed from the webserver process (php). If the problem “is back” there was either a modification of the file owner in the nextcloud-directory or a modification in the php settings.

a.) nextcloud files
Please control all your nextcloud files for the correct webserver/php/nextcloud user:group. On Debian it is www-data:www-data . You can find it with “ls -l”. Please post some outputs.

b.) php settings
I found this for you https://forums.gentoo.org/viewtopic-t-1113692-start-0.html
Perhaps there is a php setting for the user. But i do not know it.

Have you updated your system?
Was there a change perhaps a new php version?
Perhaps in that file is an incorrect username:group for the webserver/php/nextcloud user.

Thank you, @devnull,

I changed my Nextcloud folder and file permissions:

  • chown -R http:http /usr/share/webapps/nextcloud = http:http
  • The webroot folder = http:http

All folders and files in the webroot were already set to http:http.

Numerous files in the Nextcloud folder tree were set as root:http, but again, they have been all set to http:http.

php-fpm (PHP) is running by the http user

My system is up-to-date. Arch linux allows me to update as often as I like, and I typically update my machine daily.

As mentioned above, I confirmed that PHP is running as http user, and PHP is otherwise working normally.

After cleaning this up, I rebooted the server.

Unfortunately, I am still receiving the chmod() error in my Nextloud log file:

chmod(): Operation not permitted at /usr/share/webapps/nextcloud/lib/private/Log/File.php#87

Is there any other information I can provide which would be helpful in troubleshooting this error?

Thank you for your help with this!

buzz

I think this is a folder for the program files. You must change the data-dir-folder.

Please post your data-dir-folder. You find it in config/config.php of your nextcloud.

@devnull, I’m sorry, I forgot to mention that folder in my previous post! I also ran the chown command recursively on my nextcloud data folder, and all subfolders and files are http:http.

It’s interesting because I have two recurring errors in my Nextcloud log.

The first error repeats five times, then the second error occurs once, then the pattern repeats, with no other unique errors in the log.

It looks like this:
Error PHP chmod(): Operation not permitted at /usr/share/webapps/nextcloud/lib/private/Log/File.php#87
Error PHP Error: imagettftext(): Problem doing text layout at /usr/share/webapps/nextcloud/lib/private/Preview/TXT.php#92
Error PHP Error: imagettftext(): Problem doing text layout at /usr/share/webapps/nextcloud/lib/private/Preview/TXT.php#92
Error PHP Error: imagettftext(): Problem doing text layout at /usr/share/webapps/nextcloud/lib/private/Preview/TXT.php#92
Error PHP Error: imagettftext(): Problem doing text layout at /usr/share/webapps/nextcloud/lib/private/Preview/TXT.php#92
Error PHP Error: imagettftext(): Problem doing text layout at /usr/share/webapps/nextcloud/lib/private/Preview/TXT.php#92

Also, note that the two files mentioned in the errors above have permissions set at 644, which is consistent with the other files in the folders.

As mentioned above, PHP is running under the http user (confirmed in the PHP information page):

Configure Command entry includes:
'--with-fpm-user=http' '--with-fpm-group=http'

And under the Environment section:
USER http

And under the PHP Variables section:
$_SERVER['USER'] http

I have verified that all folders and files are http:http in:

  1. Nextcloud folder (/usr/share/webapps/nextcloud), including all subfolders and all files in the folder tree.

  2. The Nextcloud data folder, including all subfolders and all files in the folder tree

It appears that PHP seems to be the issue, but I don’t understand why, given the configuration.

Thank you for your help with this!

buzz

I have a similar issue with NC21. After updating from 20 to 21. I also changed php from 7.4 to 8.0.
Afterwards I also got the error:

"reqId":"Qtpir4MTCgkTNFCsmVYC","level":3,"time":"2021-04-13T13:11:34+00:00","remoteAddr":"127.0.0.1","user":"user","app":"PHP","method":"GET","url":"/nextcloud/index.php/apps/photos/service-worker.js","message":{"Exception":"Error","Message":"chmod(): Operation not permitted at /var/www/nextcloud/lib/private/Log/File.php#87","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::","args":[2,"chmod(): Operation not permitted","/var/www/nextcloud/lib/private/Log/File.php",87]},{"file":"/var/www/nextcloud/lib/private/Log/File.php","line":87,"function":"chmod","args":["/var/log/nextcloud.log",416]},{"file":"/var/www/nextcloud/lib/private/Log.php","line":371,"function":"write","class":"OC\\Log\\File","type":"->","args":["camerarawpreviews","/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.",0]},{"file":"/var/www/nextcloud/lib/private/Log.php","line":220,"function":"writeLog","class":"OC\\Log","type":"->","args":["camerarawpreviews","/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.",0]},{"file":"/var/www/nextcloud/lib/private/Log.php","line":192,"function":"log","class":"OC\\Log","type":"->","args":[0,"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.",{"app":"camerarawpreviews"}]},{"file":"/var/www/nextcloud/lib/private/legacy/OC_App.php","line":173,"function":"debug","class":"OC\\Log","type":"->","args":["/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.",{"app":"camerarawpreviews"}]},{"file":"/var/www/nextcloud/lib/private/legacy/OC_App.php","line":137,"function":"loadApp","class":"OC_App","type":"::","args":["camerarawpreviews"]},{"file":"/var/www/nextcloud/lib/base.php","line":979,"function":"loadApps","class":"OC_App","type":"::","args":[]},{"file":"/var/www/nextcloud/index.php","line":37,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/nextcloud/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Waterfox/78.9.0","version":"21.0.1.1"}

What fixed it for me at the moment, was switching back to php7.4 from php8.0.

If anyone has an idea what could’ve caused it, I would really apreciate it…

I did have the above problem. I just fixed it and hope this helps you as well
Fixes:
There is a directory called config with in /usr/share/webapps/nextcloud directory. Interestingly all the files/folders with in this config folder owned by nextcloud. I have no idea how does nextcloud user profile come into my system. So I make sure that my php-fpm service is using correct user and group details as like my nginx web server(php-fpm service user/group details can be verified at /etc/php/php-fpm.d/www.conf).
so I recursively change the ownership and mode of the config folder as like the parent folder(nextcloud) as below

sudo chown -R http:http /usr/share/webapps/nextcloud/config
sudo chmod 750 /usr/share/webapps/nextcloud/config

Restarted both php-fpm service and nginx and now If I browse my domain, I am been greeted by nextcloud welcome page admin account creation etc…