Giter Site home page Giter Site logo

Comments (8)

vitormattos avatar vitormattos commented on July 22, 2024 1

This is the point at code that throw this error:

$javaPath = $this->appConfig->getAppValue('java_path');
\exec($javaPath . ' -jar ' . $pdftkPath . " --version 2>&1", $version);
if (isset($version[0])) {
preg_match('/pdftk port to java (?<version>.*) a Handy Tool/', $version[0], $matches);
if (isset($matches['version'])) {
if ($matches['version'] === InstallService::PDFTK_VERSION) {
$return[] = (new ConfigureCheckHelper())
->setSuccessMessage('PDFtk version: ' . InstallService::PDFTK_VERSION)
->setResource('pdftk');
$return[] = (new ConfigureCheckHelper())
->setSuccessMessage('PDFtk path: ' . $pdftkPath)
->setResource('pdftk');
return $return;
}
$message = 'Necessary install the version ' . InstallService::PDFTK_VERSION;
$return[] = (new ConfigureCheckHelper())
->setErrorMessage($message)
->setResource('jsignpdf')
->setTip('Run occ libresign:install --jsignpdf');
}
}
return [
(new ConfigureCheckHelper())
->setErrorMessage('PDFtk binary is invalid: ' . $pdftkPath)
->setResource('pdftk')
->setTip('Run occ libresign:install --pdftk'),
];

You can try to mount the exec command with the path of downloaded files to check what's returned by --version.

Sounds that the return is empty or is an error in your case.

from libresign.

mashedkeyboard avatar mashedkeyboard commented on July 22, 2024

I'm having this same issue, but am seeing a correct output from that command:

curtispf@server:~$ sudo -u www-data java -jar /var/www/cloud/data/appdata_PATH/libresign/pdftk.jar  --version
pdftk port to java 3.3.3 a Handy Tool for Manipulating PDF Documents
Copyright (c) 2017-2018 Marc Vinyals - https://gitlab.com/pdftk-java/pdftk
Copyright (c) 2003-2013 Steward and Lee, LLC.
pdftk includes a modified version of the iText library.
Copyright (c) 1999-2009 Bruno Lowagie, Paulo Soares, et al.
This is free software; see the source code for copying conditions. There is
NO warranty, not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

from libresign.

vitormattos avatar vitormattos commented on July 22, 2024

The way to identify the version of pdftk that I implemented is this regex that is applied at first row:

/pdftk port to java (?<version>.*) a Handy Tool/

The first row is:
pdftk port to java 3.3.3 a Handy Tool for Manipulating PDF Documents

And the expected value for now is 3.3.3

The message PDFtk binary is invalid only is displayed when the return of --version is not a text or if the regex not match with the first row.

I think that will be necessary put more debugs/log points to identify what happening.

from libresign.

vitormattos avatar vitormattos commented on July 22, 2024

I put points of log to be possible follow the code execution. If possible, would be good if you apply this changes adding the log rows at your ConfigureCheckService.php.

To check the log output, you can use a tail with grep:

tail -f data/nextcloud.log |grep libresign

I will need the output of tail to be possible check what's happening.

diff --git a/lib/Service/Install/ConfigureCheckService.php b/lib/Service/Install/ConfigureCheckService.php
index ccc79b20c..c73ca4dc5 100644
--- a/lib/Service/Install/ConfigureCheckService.php
+++ b/lib/Service/Install/ConfigureCheckService.php
@@ -131,13 +131,21 @@ class ConfigureCheckService {
         */
        public function checkPdftk(): array {
                $pdftkPath = $this->appConfig->getAppValue('pdftk_path');
+               \OC::$server->getLogger()->debug('Path of PDFTK', ['app' => 'libresign', 'pdftk_path' => $pdftkPath]);
                if ($pdftkPath) {
+                       \OC::$server->getLogger()->debug('PDFTK exists', ['app' => 'libresign']);
                        if (file_exists($pdftkPath)) {
                                $javaPath = $this->appConfig->getAppValue('java_path');
                                \exec($javaPath . ' -jar ' . $pdftkPath . " --version 2>&1", $version);
+                               \OC::$server->getLogger()->debug('executed command', ['app' => 'libresign', 'command' => $javaPath . ' -jar ' . $pdftkPath . " --version 2>&1"]);
+                               \OC::$server->getLogger()->debug('output of version', ['app' => 'libresign', 'version' => $version]);
+                               \OC::$server->getLogger()->debug('Exists first row', ['app' => 'libresign', 'exists' => isset($version[0]) ? 'yes': 'no']);
                                if (isset($version[0])) {
+                                       \OC::$server->getLogger()->debug('First row', ['app' => 'libresign', 'version' => $version[0]]);
                                        preg_match('/pdftk port to java (?<version>.*) a Handy Tool/', $version[0], $matches);
+                                       \OC::$server->getLogger()->debug('Return of regex', ['app' => 'libresign', 'version' => $matches]);
                                        if (isset($matches['version'])) {
+                                               \OC::$server->getLogger()->debug('Version identified', ['app' => 'libresign', 'version' => $matches['version']]);
                                                if ($matches['version'] === InstallService::PDFTK_VERSION) {
                                                        $return[] = (new ConfigureCheckHelper())
                                                                        ->setSuccessMessage('PDFtk version: ' . InstallService::PDFTK_VERSION)

from libresign.

Raymo111 avatar Raymo111 commented on July 22, 2024

@vitormattos I'm getting the same issue, here's the debug logs with those statements added:

{"reqId":"XXXXXXXX","level":0,"time":"2024-05-30T19:46:33+00:00","remoteAddr":"XX.XX.XX.XX","user":"raymo","app":"libresign","method":"GET","url":"/nextcloud/ocs/v2.php/apps/libresign/api/v1/admin/configure-check","message":"Path of PDFTK","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36","version":"29.0.1.1","data":{"app":"libresign","pdftk_path":"/data/data/appdata_ocuvueakr11p/libresign/pdftk.jar"}}
{"reqId":"XXXXXXXX","level":0,"time":"2024-05-30T19:46:33+00:00","remoteAddr":"XX.XX.XX.XX","user":"raymo","app":"libresign","method":"GET","url":"/nextcloud/ocs/v2.php/apps/libresign/api/v1/admin/configure-check","message":"PDFTK exists","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36","version":"29.0.1.1","data":{"app":"libresign"}}
{"reqId":"XXXXXXXX","level":0,"time":"2024-05-30T19:46:33+00:00","remoteAddr":"XX.XX.XX.XX","user":"raymo","app":"libresign","method":"GET","url":"/nextcloud/ocs/v2.php/apps/libresign/api/v1/admin/configure-check","message":"executed command","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36","version":"29.0.1.1","data":{"app":"libresign","command":" -jar /data/data/appdata_ocuvueakr11p/libresign/pdftk.jar --version 2>&1"}}
{"reqId":"XXXXXXXX","level":0,"time":"2024-05-30T19:46:33+00:00","remoteAddr":"XX.XX.XX.XX","user":"raymo","app":"libresign","method":"GET","url":"/nextcloud/ocs/v2.php/apps/libresign/api/v1/admin/configure-check","message":"output of version","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36","version":"29.0.1.1","data":{"app":"libresign","version":"[\"sh: 1: -jar: not found\"]"}}
{"reqId":"XXXXXXXX","level":0,"time":"2024-05-30T19:46:33+00:00","remoteAddr":"XX.XX.XX.XX","user":"raymo","app":"libresign","method":"GET","url":"/nextcloud/ocs/v2.php/apps/libresign/api/v1/admin/configure-check","message":"Exists first row","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36","version":"29.0.1.1","data":{"app":"libresign","exists":"yes"}}
{"reqId":"XXXXXXXX","level":0,"time":"2024-05-30T19:46:33+00:00","remoteAddr":"XX.XX.XX.XX","user":"raymo","app":"libresign","method":"GET","url":"/nextcloud/ocs/v2.php/apps/libresign/api/v1/admin/configure-check","message":"First row","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36","version":"29.0.1.1","data":{"app":"libresign","version":"sh: 1: -jar: not found"}}
{"reqId":"XXXXXXXX","level":0,"time":"2024-05-30T19:46:33+00:00","remoteAddr":"XX.XX.XX.XX","user":"raymo","app":"libresign","method":"GET","url":"/nextcloud/ocs/v2.php/apps/libresign/api/v1/admin/configure-check","message":"Return of regex","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36","version":"29.0.1.1","data":{"app":"libresign","version":"[]"}}

from libresign.

Raymo111 avatar Raymo111 commented on July 22, 2024

Seems like javaPath is empty, and indeed if I add this:

$javaPath = $this->appConfig->getAppValue('java_path');
+ \OC::$server->getLogger()->debug('java path', ['app' => 'libresign', 'javaPath' => $javaPath]);

I get

{"reqId":"XXXXXXXX","level":0,"time":"2024-05-30T19:53:14+00:00","remoteAddr":"XX.XX.XX.XX","user":"raymo","app":"libresign","method":"GET","url":"/nextcloud/ocs/v2.php/apps/libresign/api/v1/admin/configure-check","message":"java path","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36","version":"29.0.1.1","data":{"app":"libresign","javaPath":""}}

from libresign.

Raymo111 avatar Raymo111 commented on July 22, 2024

I can fix it by installing java instead of using OS java, (occ libresign:install --java).

I see in @stepcellwolf's screenshot that he also didn't run that. Perhaps the java check should set java_path if OS java is detected, or OS java shouldn't be allowed at all?

from libresign.

vitormattos avatar vitormattos commented on July 22, 2024

if OS java is detected, or OS java shouldn't be allowed at all?

Will be complex to check if have Java installed at OS to use this and also could have side effects using a java version that isn't the same that is used by LibreSign.

from libresign.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.