Update write issues

zwame

Chevereto Member
Hi,

Thank you for your answer.
I noticed that version 3.20.9 was released and tried to upgrade, to see if this bug was corrected in our installation and to give feedback here.

The problem is that I receive a php-fpm error, every time I tried to upgrade. The error is always the same:
Code:
** errorId #6d44688229a40ae6 **
>> ErrorException [0]: copy(/var/www/img/app/lib/classes/class.upload.php): failed to open stream: Permission denied
At /app/install/update/updater.php:128

Stack trace:
#0 unknown file(unknown line): G\errorsAsExceptions(2, 'copy(/var/www/img/app/lib/classes/class.upload.php): failed to open stream: Permission denied', '/app/install/update/updater.php', 128, Array)
#1 /app/install/update/updater.php(128): copy('/app/install/update/temp/chevereto/app/lib/classes/class.upload.php', '/app/lib/classes/class.upload.php')
#2 /app/install/update/updater.php(243): CHV\extract('/app/install/update/temp/', Array)
#3 /app/routes/route.update.php(16): require_once('/app/install/update/updater.php')
#4 /lib/G/classes/class.handler.php(230): G\Handler->{closure}(G\Handler)
#5 /lib/G/classes/class.handler.php(130): G\Handler->processRequest()
#6 /app/web.php(411): G\Handler->__construct(Array)
#7 /app/loader.php(230): require_once('/app/web.php')
#8 /index.php(20): include_once('/app/loader.php')

What I find strange is that the update is decompressed and permissions look ok:
Code:
/var/www/img/app/install/update/temp # ls -lah
total 37
drwxrwx---  3 img  www     5B Jul  9 15:40 .
drwxrwx---  4 img  www     5B May  4  2019 ..
-rw-r--r--  1 img  www   303B Jul  9 15:38 README.txt
-rw-r--r--  1 img  www   522B Jul  9 15:38 Release notes.txt
drwxr-xr-x  8 img  www    10B Jul  9 15:40 chevereto

Code:
/var/www/img/app/install/update/temp/chevereto # ls -lah
total 58
drwxr-xr-x   8 img  www    10B Jul  9 15:40 .
drwxrwx---   3 img  www     5B Jul  9 15:40 ..
-rw-r--r--   1 img  www   1.3K Jul  9 15:38 .htaccess
drwxr-xr-x  10 img  www    20B Jul  9 15:40 app
-rw-r--r--   1 img  www   1.0K Jul  9 15:38 cli.php
drwxr-xr-x   4 img  www     4B Jul  9 15:40 content
drwxr-xr-x   2 img  www     2B Jul  9 15:40 images
drwxr-xr-x   6 img  www     6B Jul  9 15:40 importing
drwxr-xr-x   4 img  www     4B Jul  9 13:50 lib
drwxr-xr-x   2 img  www     2B Jul  9 15:40 sdk

I tried with the modified “app/lib/classes/class.upload.php”, and with the original “app/lib/classes/class.upload.php” with the “env TMP” parameter pointing to a local temp location (/var/www/img/temp).
I tried the update on the Web Dashboard, and gave me the "Can't connect to %s" message, but I thought it was normal, as it is only corrected in this 3.20.9.

I don’t know if I’m doing something wrong or obvious. I don’t know if this upgrade error as any relation with the original bug and if you can help.

Thanks.
 

Rodolfo

⭐ Chevereto Godlike
Chevereto Staff
Administrator
Hi, this is similar to the other issue as is also related to a uncaught exception. But in this case, the issue is that the system can't copy that particular file (class upload).

Use the attached file for app/install/update/updater.php which will allow to detect the permission issue.
 

Attachments

  • updater.zip
    3 KB · Views: 5

zwame

Chevereto Member
Hi. Sorry for the late feedback.

I tried to update Chevereto to version 3.20.9, copying that file, and it gave me this error in the php-fpm log:
Code:
[15-Jul-2021 00:40:02 Europe/Lisbon]
Aw, snap! Internal Server Error [debug @ error_log] - https://chv.to/debug

** errorId #017c5aa447ea0d86 **
>> Exception [403]: Can't update /sdk/pup.js file - php:img>copy(pup.js): failed to open stream: No such file or directory
At /app/install/update/updater.php:132

Stack trace:
#0 /app/install/update/updater.php(245): CHV\extract('/app/install/update/temp/', Array)
#1 /app/routes/route.update.php(16): require_once('/app/install/update/updater.php')
#2 /lib/G/classes/class.handler.php(230): G\Handler->{closure}(G\Handler)
#3 /lib/G/classes/class.handler.php(130): G\Handler->processRequest()
#4 /app/web.php(411): G\Handler->__construct(Array)
#5 /app/loader.php(230): require_once('/app/web.php')
#6 /index.php(20): include_once('/app/loader.php')
[code]

I noticed the "Can't update /sdk/pup.js file" in the error, but I have that file:
[code]
felix@webprojectos:~ % doas ls -lah /var/www/img/sdk
total 204
drwxrwx---   2 img  www     4B May  4  2019 .
drwxrwx---  10 img  www    16B Jul  9 15:11 ..
-rwxrwx---   1 img  www    50K Jul  9 15:40 pup.dev.js
-rwxrwx---   1 img  www    24K Jul  9 15:40 pup.js

I tried the update with the modified "app/lib/classes/class.upload.php" file, in the other bug.

After the update, the version 3.20.8 is manteined:
Sdfc4gk.png


Also, after the update, When I try to upload an image, I receive an "Internal Server Error":
GE0ZVoP.png


But I have no error in the php-fpm and nginx log.

I don't know if I'm doing something wrong in the update process of this is part of this bug.

Thanks. :)
 

Rodolfo

⭐ Chevereto Godlike
Chevereto Staff
Administrator
There are two different issues here.

#1 is related to the update procedure, as you may notice the error now reads php:img which indicates the PHP user. I believe that the problem is that you are using the HTTP API and not the CLI API for carrying update under php-fpm. If you run php-fpm perhaps you are experiencing race conditions with the filesystem operations? Give it a try to the CLI update command as described here.

#2 This one needs debug

What is needed to do now is to debug to determine what's exactly the malfunction affecting your system so we can quickly assists you further. Note that you will require to understand our error reporting and follow our debug guide.

What you need is this one: https://v3-docs.chevereto.com/manual/troubleshooting/errors.html#http-500-internal-server-error

Is this something you feel comfortable doing by yourself? If so, let us know your findings.
 

zwame

Chevereto Member
There are two different issues here.
Sorry for just answering now. Yesterday, I tried to update Chevereto in different ways. The cli way, with the php temp folder in the same dataset, with the original and new "app/install/update/updater.php", etc.
It always failed.

#1 is related to the update procedure, as you may notice the error now reads php:img which indicates the PHP user. I believe that the problem is that you are using the HTTP API and not the CLI API for carrying update under php-fpm. If you run php-fpm perhaps you are experiencing race conditions with the filesystem operations? Give it a try to the CLI update command as described here.

Here is the output when I try to update Chevereto via Cli:
Code:
felix@webprojectos:~ % doas -u img php /var/www/img/cli.php -C update
* Checking for updates
> Update needed
* Downloading latest release
Fetching https://chevereto.com/api/download/latest
  100%[==================================================>] download
> chevereto_latest_9e63109d0c840a2ff1dd3f35.zip
* Extracting downloaded file

Aw, snap! Internal Server Error [debug @ error_log] - https://chv.to/debug

** errorId #be0f6983cba3b9db **
>> Exception [403]: Can't update /var/www/img/sdk/pup.js file - php:img>copy(pup.js): failed to open stream: No such file or directory
At /var/www/img/app/install/update/updater.php:132

Stack trace:
#0 /var/www/img/app/install/update/updater.php(227): CHV\extract('/var/www/img/app/install/update/temp/', Array)
#1 /var/www/img/app/update.php(22): require_once('/var/www/img/app/install/update/updater.php')
#2 /var/www/img/app/loader.php(230): require_once('/var/www/img/app/update.php')
#3 /var/www/img/cli.php(35): include_once('/var/www/img/app/loader.php')

{
    "status_code": 400,
    "error": {
        "message": "Can't update \/var\/www\/img\/sdk\/pup.js file - php:img>copy(pup.js): failed to open stream: No such file or directory",
        "code": 403
    },
    "status_txt": "Bad Request"
}

What I find strange is that the "/var/www/img/sdk/pup.js" exists:
Code:
felix@webprojectos:~ % doas ls -lah /var/www/img/sdk/
total 204
drwxr-x---  2 img  www     4B May  4  2019 .
drwxrwx---  9 img  www    15B Jul 19 00:40 ..
-rwxr-x---  1 img  www    50K Jul 19 00:00 pup.dev.js
-rwxr-x---  1 img  www    24K Jul 19 00:00 pup.js

Would it be best to try the update via "manual update", to try to have a "clean base", to future Chevereto updates?

#2 This one needs debug

What is needed to do now is to debug to determine what's exactly the malfunction affecting your system so we can quickly assists you further. Note that you will require to understand our error reporting and follow our debug guide.

What you need is this one: https://v3-docs.chevereto.com/manual/troubleshooting/errors.html#http-500-internal-server-error

Is this something you feel comfortable doing by yourself? If so, let us know your findings.

I will try to explain my findings the best way I can.

Like I said, yesterday, I tried to update Chevereto in different ways, but before that, I noticed something unusual with the Chevereto file permissions, and maybe, their dates.
These listings are from a ZFS Snapshot from before those attempts yesterday, I tried to update Chevereto in different ways. At that time, I had only tried to update Chevereto two times, the GUI way.
MfsfJPg.png


e79gvI2.png


I noticed that I had some files with 644 permissions and some files with 770 permissions. Different dates too, but maybe that is normal.
Then, I changed the root files to 640 permissions and the directories to 750 permissions.
After that, that "internal server error", when uploading files, got resolved. Here is an image that I uploaded today: https://img.zwame.pt/images/2021/07/19/AMD2.jpg

What I find strange is that I didn't change those files permissions. I don't know how that happened.
Is it possible, that this happened, in one of the attempts to update Chevereto? Is there a possibility that I have php Chevereto files from different releases?

As I asked before, Would it be best to try the update via "manual update", to try to have a "clean base", to future Chevereto updates?

Thank you for your support and I hope I'm proceeding well to help fix these bugs.
 

Rodolfo

⭐ Chevereto Godlike
Chevereto Staff
Administrator
I've noticed that the file I gave you has issues, the one in V3.20.10 should fix this issue for you.
 
Top