Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert command always taking policy from global policy.xml file instead of custom path #22

Closed
hctpbl opened this issue Oct 9, 2018 · 2 comments

Comments

@hctpbl
Copy link

hctpbl commented Oct 9, 2018

Description

I use ImageMagick to convert pdf files to png, the ImageMagick version I am using (6.8.9-9) ships with a default policy.xml file that has no permissions for reading PDF files. I changed that policy.xml file and everything is working correctly, but I want to be able to have my own policy.xml file in a path of my choice that I can ship with my project, so I can deploy the project in a new server without having to configure the server's default policy.xml file every time.

According to ImageMagick v6 documentation the policy will be looked for in the following locations (I'm using the precompiled binary installation for Ubuntu 16.04):

$MAGICK_CONFIGURE_PATH
$MAGICK_HOME/etc/ImageMagick-6 
$MAGICK_HOME/share/ImageMagick-6 
$PREFIX/share/ImageMagick-6 
$XDG_CACHE_HOME/ImageMagick
$HOME/.config/ImageMagick/
<client path>/etc/ImageMagick
<current directory>

So I set the env variable MAGICK_CONFIGURE_PATH to the path I put my policy file on. I would expect the convert command to find it there and use that policy to execute, but it seems to be using the one in /etc/ImageMagick-6 anyway. The policy file is correctly found when using the command to list the policy:

$convert -list policy

Path: /home/<user>/path/to/file/policy.xml
  Policy: undefined
    rights: None 
  Policy: Coder
    rights: None 
    pattern: EPHEMERAL
  Policy: Coder
    rights: None 
    pattern: URL
  Policy: Coder
    rights: None 
    pattern: HTTPS
  Policy: Coder
    rights: None 
    pattern: MVG
  Policy: Coder
    rights: None 
    pattern: MSL
  Policy: Coder
    rights: None 
    pattern: TEXT
  Policy: Coder
    rights: None 
    pattern: SHOW
  Policy: Coder
    rights: None 
    pattern: WIN
  Policy: Coder
    rights: None 
    pattern: PLT
  Policy: Path
    rights: None 
    pattern: @*
  Policy: Coder
    rights: None 
    pattern: PS
  Policy: Coder
    rights: None 
    pattern: EPS
  Policy: Coder
    rights: Read 
    pattern: PDF
  Policy: Coder
    rights: None 
    pattern: XPS

Path: /etc/ImageMagick-6/policy.xml
  Policy: undefined
    rights: None 
  Policy: Coder
    rights: None 
    pattern: EPHEMERAL
  Policy: Coder
    rights: None 
    pattern: URL
  Policy: Coder
    rights: None 
    pattern: HTTPS
  Policy: Coder
    rights: None 
    pattern: MVG
  Policy: Coder
    rights: None 
    pattern: MSL
  Policy: Coder
    rights: None 
    pattern: TEXT
  Policy: Coder
    rights: None 
    pattern: SHOW
  Policy: Coder
    rights: None 
    pattern: WIN
  Policy: Coder
    rights: None 
    pattern: PLT
  Policy: Path
    rights: None 
    pattern: @*
  Policy: Coder
    rights: None 
    pattern: PS
  Policy: Coder
    rights: None 
    pattern: EPS
  Policy: Coder
    rights: None 
    pattern: PDF
  Policy: Coder
    rights: None 
    pattern: XPS

Path: [built-in]
  Policy: Undefined
    rights: None 

But I get a not authorized error. If I change the policy file in /etc/ImageMagick-6/policy.xml to allow reading PDF files, my convert command works.

I have also tried to place the policy file in the <current directory> from where I call the convert command, it also appears when I execute convert -list policy, but I still get the not authorized error unless I changed the global policy file.

System Configuration

  • ImageMagick version: 6.8.9-9
  • Environment (Operating system, version and so on): Ubuntu 16.04.4
@hctpbl hctpbl closed this as completed Oct 9, 2018
@dlemstra
Copy link
Member

dlemstra commented Oct 9, 2018

@hctpbl Might be nice for future users to know why you closed this issue.

@hctpbl
Copy link
Author

hctpbl commented Oct 9, 2018

Hey @dlemstra, I just closed it because I also opened an issue on the main ImageMagick repo: ImageMagick/ImageMagick#1342

I didn't know whether to leave this one or the other one, and I didn't want it to be duplicated, but I saw v6 issues on the main repo so I left it there. I would appreciate any guidance on where to put this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants