LibreSign / libresign

✍️ Nextcloud app to sign PDF documents
https://libresign.coop
GNU Affero General Public License v3.0
452 stars 51 forks source link

Internal Error on Fresh Install #1341

Closed tonytonyistony closed 1 year ago

tonytonyistony commented 1 year ago

Describe the bug After installing the app, I send a signing request to another non-admin user and when they attempt to sign it they get an error saying "Internal Error, Contact Admin"

To Reproduce Steps to reproduce the behavior:

Expected behavior PDF becomes signed

Screenshots image image

Environment information (please complete the following information):

[libresign] Error: 
[{"file":"\/var\/www\/nextcloud\/apps\/libresign\/vendor\/jsignpdf\/jsignpdf-php\/src\/JSignPDF.php","line":29,"function":"sign","class":"Jeidison\\JSignPDF\\Sign\\JSignService","type":"->"},
{"file":"\/var\/www\/nextcloud\/apps\/libresign\/lib\/Handler\/JSignPdfHandler.php","line":83,"function":"sign","class":"Jeidison\\JSignPDF\\JSignPDF","type":"->"},
{"file":"\/var\/www\/nextcloud\/apps\/libresign\/lib\/Handler\/Pkcs12Handler.php","line":126,"function":"sign","class":"OCA\\Libresign\\Handler\\JSignPdfHandler","type":"->"},
{"file":"\/var\/www\/nextcloud\/apps\/libresign\/lib\/Service\/SignFileService.php","line":606,"function":"sign","class":"OCA\\Libresign\\Handler\\Pkcs12Handler","type":"->"},
{"file":"\/var\/www\/nextcloud\/apps\/libresign\/lib\/Controller\/SignFileController.php","line":202,"function":"sign","class":"OCA\\Libresign\\Service\\SignFileService","type":"->"},
{"file":"\/var\/www\/nextcloud\/apps\/libresign\/lib\/Controller\/SignFileController.php","line":180,"function":"sign","class":"OCA\\Libresign\\Controller\\SignFileController","type":"->"},
{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":225,"function":"signUsingUuid","class":"OCA\\Libresign\\Controller\\SignFileController","type":"->"},
{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":133,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},
{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/App.php","line":172,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},
{"file":"\/var\/www\/nextcloud\/lib\/private\/Route\/Router.php","line":298,"function":"main","class":"OC\\AppFramework\\App","type":"::"},
{"file":"\/var\/www\/nextcloud\/lib\/base.php","line":1047,"function":"match","class":"OC\\Route\\Router","type":"->"},
{"file":"\/var\/www\/nextcloud\/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}]
POST /apps/libresign/api/0.1/sign/uuid/74ed5f93-0024-4a2a-b741-2d5fb3a97fd8
[libresign] Error: Error to sign PDF. ["sh: 1: : Permission denied"]
POST /apps/libresign/api/0.1/sign/uuid/74ed5f93-0024-4a2a-b741-2d5fb3a97fd8
vitormattos commented 1 year ago

Hi, Sounds that a permission problem. Check the owner and group of files inside /data/appdata_/libresign is the same of all other PHP files of Nextcloud. Check the owner and group of all files inside /data folder too.

vitormattos commented 1 year ago

Was this row that throw this error:

https://github.com/JSignPdf/jsignpdf-php/blob/fa302ee5333a8643cf49c60ce33189aa86961350/src/Sign/JSignService.php#L27

You can add a row before the row 27 with this code to see the full command executed:

throw new Exception($commandSign);

And try to run the command handmade verifying the arguments and if the permission of all files is ok.

This error isn't an expected behavior.

tonytonyistony commented 1 year ago

This is what popped in the logs after addng that line of code. image It may be notable to mention that my appdata and data folders are hosted on an external NFS NAS mount Below is my NFS Share settings. NC Fstab 192.168.1.1:/mnt/user/nextcloud /mnt/nextcloud nfs4 defaults 0 0 Unraid NAS "/mnt/user/nextcloud" -fsid=102,async,no_subtree_check *(rw,sec=sys,insecure,anongid=100,anonuid=99,all_squash)

I worked on my NAS setup a bit and changed some permission settings. NC Fstab - unchanged Unraid NAS Set to private "/mnt/user/nextcloud" -fsid=102,async,no_subtree_check 192.168.1.2(sec=sys,rw,sync,no_root_squash)

chmod www-data:www-data /mnt/nextcloud chown 0770 /mnt/nextcloud

image

I reran the signing process and still no change.

tonytonyistony commented 1 year ago

I re-ran the permission settings specified by nextcloud to make sure the permissions werent out of whack.

image

No change.

I also went in and tried changing the users password to see if there was a problem with a special character and I received another error.

image

tonytonyistony commented 1 year ago

Some folder stats for app and appdata

administrator@nextcloud:/var/www/nextcloud$ stat /mnt/nextcloud/appdata_ocwkjvx9ohjj/libresign
  File: /mnt/nextcloud/appdata_ocwkjvx9ohjj/libresign
  Size: 298         Blocks: 0          IO Block: 32768  directory
Device: 38h/56d Inode: 18302628892079439156  Links: 1
Access: (0750/drwxr-x---)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 04:53:09.283864976 +0000
Modify: 2023-01-05 04:54:20.652372532 +0000
Change: 2023-01-05 21:57:15.795952810 +0000
 Birth: -
administrator@nextcloud:/var/www/nextcloud$ stat /mnt/nextcloud/appdata_ocwkjvx9ohjj/libresign/*
  File: /mnt/nextcloud/appdata_ocwkjvx9ohjj/libresign/cfssl
  Size: 13336752    Blocks: 26056      IO Block: 1048576 regular file
Device: 38h/56d Inode: 18302628892079151688  Links: 1
Access: (0640/-rw-r-----)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 04:53:09.885869258 +0000
Modify: 2023-01-05 04:53:11.479880593 +0000
Change: 2023-01-05 21:47:50.276888410 +0000
 Birth: -
  File: /mnt/nextcloud/appdata_ocwkjvx9ohjj/libresign/cfssl_config
  Size: 125         Blocks: 0          IO Block: 32768  directory
Device: 38h/56d Inode: 18302628902825121895  Links: 1
Access: (0750/drwxr-x---)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 04:54:20.652372532 +0000
Modify: 2023-01-05 04:54:21.152376089 +0000
Change: 2023-01-05 21:57:15.906953609 +0000
 Birth: -
  File: /mnt/nextcloud/appdata_ocwkjvx9ohjj/libresign/cfssljson
  Size: 7646320     Blocks: 14936      IO Block: 1048576 regular file
Device: 38h/56d Inode: 18302628892079151738  Links: 1
Access: (0640/-rw-r-----)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 04:53:11.662881894 +0000
Modify: 2023-01-05 04:53:13.237893094 +0000
Change: 2023-01-05 21:47:50.279888432 +0000
 Birth: -
  File: /mnt/nextcloud/appdata_ocwkjvx9ohjj/libresign/checksums_java_17.0.5_8.txt
  Size: 115         Blocks: 8          IO Block: 1048576 regular file
Device: 38h/56d Inode: 18302628892079151719  Links: 1
Access: (0640/-rw-r-----)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 04:53:10.305872244 +0000
Modify: 2023-01-05 04:53:10.306872252 +0000
Change: 2023-01-05 21:47:50.278888424 +0000
 Birth: -
  File: /mnt/nextcloud/appdata_ocwkjvx9ohjj/libresign/checksums_libresign-cli_0.0.4.txt
  Size: 282         Blocks: 8          IO Block: 1048576 regular file
Device: 38h/56d Inode: 18302628892079151717  Links: 1
Access: (0640/-rw-r-----)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 04:53:09.917869485 +0000
Modify: 2023-01-05 04:53:09.918869492 +0000
Change: 2023-01-05 21:47:50.277888417 +0000
 Birth: -
  File: /mnt/nextcloud/appdata_ocwkjvx9ohjj/libresign/checksums_libresign-cli_1.6.3.txt
  Size: 2430        Blocks: 8          IO Block: 1048576 regular file
Device: 38h/56d Inode: 18302628892079438609  Links: 1
Access: (0640/-rw-r-----)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 04:53:09.863869101 +0000
Modify: 2023-01-05 04:53:09.864869108 +0000
Change: 2023-01-05 21:47:50.275888403 +0000
 Birth: -
  File: /mnt/nextcloud/appdata_ocwkjvx9ohjj/libresign/java
  Size: 98          Blocks: 0          IO Block: 32768  directory
Device: 38h/56d Inode: 18302628894859408974  Links: 1
Access: (0750/drwxr-x---)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 04:53:09.335865346 +0000
Modify: 2023-01-05 04:53:15.226907239 +0000
Change: 2023-01-05 21:57:15.799952838 +0000
 Birth: -
  File: /mnt/nextcloud/appdata_ocwkjvx9ohjj/libresign/jsignpdf-2.2.0
  Size: 136         Blocks: 0          IO Block: 32768  directory
Device: 38h/56d Inode: 18302628896664090541  Links: 1
Access: (0750/drwxr-x---)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 04:53:12.583888444 +0000
Modify: 2023-01-05 04:53:13.299893535 +0000
Change: 2023-01-05 21:57:15.899953559 +0000
 Birth: -
  File: /mnt/nextcloud/appdata_ocwkjvx9ohjj/libresign/jsignpdf-2.2.0.zip
  Size: 19018870    Blocks: 37152      IO Block: 1048576 regular file
Device: 38h/56d Inode: 18302628892079438599  Links: 1
Access: (0640/-rw-r-----)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 04:53:09.366865566 +0000
Modify: 2023-01-05 04:53:12.500887853 +0000
Change: 2023-01-05 21:47:50.275888403 +0000
 Birth: -
  File: /mnt/nextcloud/appdata_ocwkjvx9ohjj/libresign/libresign-cli
  Size: 3741988     Blocks: 7312       IO Block: 1048576 regular file
Device: 38h/56d Inode: 18302628892079151718  Links: 1
Access: (0640/-rw-r-----)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 04:53:09.935869613 +0000
Modify: 2023-01-05 04:53:10.805875800 +0000
Change: 2023-01-05 21:47:50.277888417 +0000
 Birth: -
administrator@nextcloud:/var/www/nextcloud$ stat /var/www/nextcloud/apps/libresign
  File: /var/www/nextcloud/apps/libresign
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: fd00h/64768d    Inode: 16048       Links: 11
Access: (0750/drwxr-x---)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 21:46:04.007300795 +0000
Modify: 2023-01-05 04:52:45.028913532 +0000
Change: 2023-01-05 21:45:40.739166867 +0000
 Birth: -
administrator@nextcloud:/var/www/nextcloud$ stat /var/www/nextcloud/apps/libresign/*
  File: /var/www/nextcloud/apps/libresign/appinfo
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: fd00h/64768d    Inode: 16051       Links: 2
Access: (0750/drwxr-x---)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 21:46:04.007300795 +0000
Modify: 2023-01-05 04:52:44.944912950 +0000
Change: 2023-01-05 21:45:40.739166867 +0000
 Birth: -
  File: /var/www/nextcloud/apps/libresign/cfssl
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: fd00h/64768d    Inode: 16054       Links: 2
Access: (0750/drwxr-x---)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 21:46:04.007300795 +0000
Modify: 2023-01-05 04:52:44.944912950 +0000
Change: 2023-01-05 21:45:40.739166867 +0000
 Birth: -
  File: /var/www/nextcloud/apps/libresign/CHANGELOG.md
  Size: 21612       Blocks: 48         IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 16049       Links: 1
Access: (0640/-rw-r-----)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 04:52:44.940912922 +0000
Modify: 2023-01-05 04:52:45.188914640 +0000
Change: 2023-01-05 21:46:04.035300958 +0000
 Birth: -
  File: /var/www/nextcloud/apps/libresign/img
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: fd00h/64768d    Inode: 16056       Links: 2
Access: (0750/drwxr-x---)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 21:46:04.007300795 +0000
Modify: 2023-01-05 04:52:44.944912950 +0000
Change: 2023-01-05 21:45:40.739166867 +0000
 Birth: -
  File: /var/www/nextcloud/apps/libresign/js
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: fd00h/64768d    Inode: 16067       Links: 3
Access: (0750/drwxr-x---)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 21:46:04.007300795 +0000
Modify: 2023-01-05 04:52:44.992913282 +0000
Change: 2023-01-05 21:45:40.739166867 +0000
 Birth: -
  File: /var/www/nextcloud/apps/libresign/l10n
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: fd00h/64768d    Inode: 16176       Links: 2
Access: (0750/drwxr-x---)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 21:46:04.007300795 +0000
Modify: 2023-01-05 04:52:45.016913449 +0000
Change: 2023-01-05 21:45:40.739166867 +0000
 Birth: -
  File: /var/www/nextcloud/apps/libresign/lib
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: fd00h/64768d    Inode: 16992       Links: 16
Access: (0750/drwxr-x---)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 21:46:04.007300795 +0000
Modify: 2023-01-05 04:52:45.028913532 +0000
Change: 2023-01-05 21:45:40.739166867 +0000
 Birth: -
  File: /var/www/nextcloud/apps/libresign/LICENSE
  Size: 34454       Blocks: 72         IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 16050       Links: 1
Access: (0640/-rw-r-----)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 04:52:44.940912922 +0000
Modify: 2023-01-05 04:52:45.188914640 +0000
Change: 2023-01-05 21:46:04.047301028 +0000
 Birth: -
  File: /var/www/nextcloud/apps/libresign/templates
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: fd00h/64768d    Inode: 17090       Links: 2
Access: (0750/drwxr-x---)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 21:46:04.007300795 +0000
Modify: 2023-01-05 04:52:45.028913532 +0000
Change: 2023-01-05 21:45:40.739166867 +0000
 Birth: -
  File: /var/www/nextcloud/apps/libresign/tests
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: fd00h/64768d    Inode: 17096       Links: 3
Access: (0750/drwxr-x---)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 21:46:04.007300795 +0000
Modify: 2023-01-05 04:52:45.028913532 +0000
Change: 2023-01-05 21:45:40.739166867 +0000
 Birth: -
  File: /var/www/nextcloud/apps/libresign/vendor
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: fd00h/64768d    Inode: 17099       Links: 14
Access: (0750/drwxr-x---)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2023-01-05 21:46:04.007300795 +0000
Modify: 2023-01-05 04:52:45.108914085 +0000
Change: 2023-01-05 21:45:40.739166867 +0000
 Birth: -
vitormattos commented 1 year ago

Hi @tonytonyistony I didn't understood if is correct in your environment the path of java and jsignpdf inside your libresign app data folder. Could you check if the returned java and jsignpdf path by command that I shared is ok?

vitormattos commented 1 year ago

Closing. Reason: can't reproduce, no interaction with more details by more than a month and was a report of an old version.