Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > de.comp.lang.php > #4282

Re: [little ot] PHP wExec convert -> Berechtigungsproblem

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups de.comp.lang.php
Subject Re: [little ot] PHP wExec convert -> Berechtigungsproblem
Date 2017-10-04 17:36 +0200
Organization PointedEars Software (PES)
Message-ID <2895336.aeNJFYEL58@PointedEars.de> (permalink)
References <oqti7v$3gp$1@news.albasani.net> <1923075.irdbgypaU6@PointedEars.de> <or23s5$q8o$1@news.albasani.net> <2584393.e9J7NaK4W3@PointedEars.de>

Show all headers | View raw


Thomas 'Ingrid' Lahn wrote:

> Jan Novak wrote:
>> Am 04.10.2017 um 01:55 schrieb Thomas 'PointedEars' Lahn:
>>> Jan Novak wrote:
>>>> ich möchte unter php diesen Befehl ausführen lassen (debian 9, PHP7,
>>>> apache2) :
>>>> exec('convert a.odt[0] a.jpg');
>>> Was tut das Deiner Meinung nach, wenn es funktioniert?
>> 
>> Es erstellt aus der 1. Seite der odt eine jpg Datei.
> 
> Aha.  Dass dafür “[0]” nötig ist, bezweifle ich zwar.
> 
> Aber das Problem hat nicht direkt etwas damit oder mit PHP zu tun,
> denn in meiner Textkonsole gibt dieselbe Fehlermeldung wie bei Dir
> in PHP (nur wegen LC_MESSAGES=en_US.UTF-8 auf Englisch [empfehlenswert]):
> 
> ---------------------------------------------------------------------------
> $ convert 'Definitionen.odt[0]' Definitionen.jpeg
> convert /tmp/magick-20501g45upgzP6sIA ->
> /home/****/_dirname/magick-20501g45upgzP6sIA.pdf using filter :
             ^^^^^^^^
> writer_pdf_Export mv: cannot stat '/tmp/magick-20501g45upgzP6sIA.pdf': No
> such file or directory convert: delegate failed `"soffice" --headless
> --convert-to pdf --outdir `dirname "%i"` "%i" 2> "%Z"; mv "%i.pdf" "%o"' @
> error/delegate.c/InvokeDelegate/1310. convert: unable to open image
> `/tmp/magick-20501vouTC_lcoBTU': No such file or directory @
> error/blob.c/OpenBlob/2709. convert: unable to open file
> `/tmp/magick-20501vouTC_lcoBTU': No such file or directory @
> error/constitute.c/ReadImage/540. convert: no images defined
> `Definitionen.jpeg' @ error/convert.c/ConvertImageCommand/3210.
> 
> $ convert Definitionen.odt Definitionen.jpeg
> convert /tmp/magick-25564EicGudXE8BFY ->
> /home/****/_dirname/magick-25564EicGudXE8BFY.pdf using filter :
             ^^^^^^^^
> writer_pdf_Export mv: cannot stat '/tmp/magick-25564EicGudXE8BFY.pdf': No
> such file or directory convert: delegate failed `"soffice" --headless
> --convert-to pdf --outdir `dirname "%i"` "%i" 2> "%Z"; mv "%i.pdf" "%o"' @
> error/delegate.c/InvokeDelegate/1310. convert: unable to open image
> `/tmp/magick-25564b4xXPIxJjY8B': No such file or directory @
> error/blob.c/OpenBlob/2709. convert: unable to open file
> `/tmp/magick-25564b4xXPIxJjY8B': No such file or directory @
> error/constitute.c/ReadImage/540. convert: no images defined
> `Definitionen.jpeg' @ error/convert.c/ConvertImageCommand/3210.
> ---------------------------------------------------------------------------
> 
> convert(1) selbst enthält anscheinend keinen Importfilter für
> OpenDocument Text:

So ist es.
 
> […]
> ---------------------------------------------------------------------------
> $ strace convert Definitionen.odt[0] Definitionen.jpeg 2>&1 | vim -
> […]
> stat("/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9//modules-Q16/coders/odt.la",
> 0x7ffe89b58b40) = -1 ENOENT (No such file or directory)
> ---------------------------------------------------------------------------
> […]
> 
> Das sieht für mich so aus, als ob ein ImageMagick-Modul für die
> Konvertierung von ODT nicht verfügbar ist.

Damit hat es nichts zu tun.  Die “delegates” sind in

  /etc/ImageMagick-6/delegates.xml

definiert.  Offenbar wird darin

  <delegate decode="odt" command="&quot;soffice&quot; --headless --convert-to pdf --outdir `dirname &quot;%i&quot;` &quot;%i&quot; 2&gt; &quot;%Z&quot;; mv &quot;
%i.pdf&quot; &quot;%o&quot;"/>

insbesondere (XML expandiert)

  `dirname "%i"`

falsch interpretiert.

Denn wie man sieht, steht in der Fehlermeldung statt des Verzeichnispfade
der Quelldatei (was der Befehl dirname(1) ausgeben sollte) “_dirname”.

Wenn man

  `dirname "%i"`

durch

  /tmp

ersetzt, funktioniert es.  Deshalb funktioniert bei mir auch die Lösung
in zwei Schritten.

Wenn man “${TMPDIR:-/tmp}” verwendet, dann funktioniert es nicht,
weil das zu “__TMPDIR:-/tmp_” wird.  Damit ist klar, dass ein übereifriger
Ersetzungsvorgang durch convert(1) zumindest für das Problem bei mir
verantwortlich ist.
 
> Offenbar funktioniert aber nur der Aufruf von soffice(1) aus convert(1)
> heraus nicht richtig,

So ist es.

Siehe auch:

<https://www.imagemagick.org/discourse-server/viewtopic.php?t=27543>

Offensichtlich ist es ein schon sehr lange bekannter und nicht gefixter Bug.

> Eher handelt es sich also um einen Bug in ImageMagick.

Bei mir, nicht bei Jan.

Er sollte stattdessen entweder die Zwei-Schritt-Lösung wählen, m PHP-User
Schreibberechtigung auf das Quellverzeichnis geben oder die delegates.xml
auf dem Server ändern, so dass die temporäre PDF-Datei in /tmp
geschrieben wird und nicht ins Quellverzeichnis.  Ich schlage ersteres vor.

> Mittelfristig könnte es helfen, das Debian-Paket zu installieren,
> welches die fe lende Datei “odt.la” enthält.

Gibt es wahrscheinlich nicht; ich habe jedenfalls kein solches gefunden.

> Langfristig sollte man[tm] die irreführende convert-Fehlermeldung
> als ImageMagick-Bug melden.

[x] TODO

-- 
PointedEars
Zend Certified PHP Engineer <http://www.zend.com/en/yellow-pages/ZEND024953>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Back to de.comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

[little ot] PHP wExec convert -> Berechtigungsproblem Jan Novak <repcom@gmail.com> - 2017-10-02 16:25 +0200
  Re: [little ot] PHP wExec convert -> Berechtigungsproblem Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2017-10-02 16:45 +0000
    Re: [little ot] PHP wExec convert -> Berechtigungsproblem Jan Novak <repcom@gmail.com> - 2017-10-03 10:24 +0200
      Re: [little ot] PHP wExec convert -> Berechtigungsproblem Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2017-10-03 11:14 +0000
        Re: [little ot] PHP wExec convert -> Berechtigungsproblem Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-10-04 01:53 +0200
  Re: [little ot] PHP wExec convert -> Berechtigungsproblem Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-10-04 01:55 +0200
    Re: [little ot] PHP wExec convert -> Berechtigungsproblem Jan Novak <repcom@gmail.com> - 2017-10-04 09:50 +0200
      Re: [little ot] PHP wExec convert -> Berechtigungsproblem Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-10-04 16:49 +0200
        Re: [little ot] PHP wExec convert -> Berechtigungsproblem Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-10-04 17:36 +0200
          Re: [little ot] PHP wExec convert -> Berechtigungsproblem Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-10-04 18:11 +0200
    Re: [little ot] PHP wExec convert -> Berechtigungsproblem Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2017-10-04 08:15 +0000
  Re: [little ot] PHP wExec convert -> Berechtigungsproblem Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-10-05 00:52 +0200

csiph-web