'Not Authorized' error due to default ImageMagick policy.xml

Created on 18 September 2019, almost 5 years ago
Updated 6 May 2023, about 1 year ago

Thanks for this useful module, just wanted to add an issue describing a minor problem I had getting this module set up in case others have the same problem. Perhaps a note could be added to the documentation for this module as I think this could be a common problem for installs that have never configured ImageMagick to read PDFs before.

Received a 'not authorized' error when attempting to use this module for the first time on Ubuntu with Nginx. At first thought it had to do with file permissions, but it turned out to be a default policy setting in ImageMagick (at least on my version of ubuntu) that disallows reading PDF files.

In:
/etc/ImageMagick-6/policy.xml

Change:
<policy domain="coder" rights="none" pattern="PDF" />
To:
<policy domain="coder" rights="read" pattern="PDF" />

Save, then restart php-fpm (if using fpm) or nginx/apache, f.x.

sudo service php7.2-fpm restart
sudo service nginx restart

or similar depending on your OS

Fixed the issue for me.

Example error from drupal included below:

Drupal\Core\Entity\EntityStorageException: not authorized `/var/www/intranet/web/sites/default/files/2019-09/test.pdf' @ error/constitute.c/ReadImage/412 in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 847 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Drupal\media_pdf_thumbnail\Manager\MediaPdfThumbnailImagickManager->generateImage('/var/www/intranet/web/sites/default/files/2019-09/test.pdf', '/var/www/intranet/web/sites/default/files/2019-09/test.pdf.png') (Line: 79)
  Drupal\media_pdf_thumbnail\Manager\MediaPdfThumbnailImageManager->createThumbnail(Object) (Line: 39)
  media_pdf_thumbnail_media_presave(Object)
  call_user_func_array('media_pdf_thumbnail_media_presave', Array) (Line: 403)

...

πŸ› Bug report
Status

Closed: works as designed

Version

1.9

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States vcole@midcolumbialibraries.org

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024