Page 1 of 1

mogrify is not preserving file permissions

Posted: 2016-02-07T05:48:19-07:00
by hei
Hi,

I'm using mogrify to crop images. These images are located in /tmp directory. Before using mogrify images have file permissions 600. After using mogrify file permissions changed to 644. This is a serious problem for me because now the images are world readable and I'm on a shared system.

Is this behaviour intended? How can I preserve file permissions?

More informations below:

Code: Select all

vagrant@vagrant-ubuntu-trusty-64:/vagrant$ mogrify --version
Version: ImageMagick 6.7.7-10 2014-03-06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

vagrant@vagrant-ubuntu-trusty-64:/vagrant$ chmod 600 red10x10.png
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ stat red10x10.png
  File: ‘red10x10.png’
  Size: 318       	Blocks: 8          IO Block: 4096   regular file
Device: 19h/25d	Inode: 3371        Links: 1
Access: (0600/-rw-------)  Uid: ( 1000/ vagrant)   Gid: ( 1000/ vagrant)
Access: 2016-02-07 13:42:54.000000000 +0100
Modify: 2016-02-07 13:42:54.000000000 +0100
Change: 2016-02-07 13:45:06.000000000 +0100
 Birth: -
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ mogrify -crop 10x10+0+0 red10x10.png
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ stat red10x10.png
  File: ‘red10x10.png’
  Size: 318       	Blocks: 8          IO Block: 4096   regular file
Device: 19h/25d	Inode: 3372        Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/ vagrant)   Gid: ( 1000/ vagrant)
Access: 2016-02-07 13:45:13.000000000 +0100
Modify: 2016-02-07 13:45:13.000000000 +0100
Change: 2016-02-07 13:45:13.000000000 +0100
 Birth: -

Re: mogrify is not preserving file permissions

Posted: 2016-02-07T06:39:40-07:00
by glennrp
You could run "umask 0077" before running "mogrify".

Re: mogrify is not preserving file permissions

Posted: 2016-02-08T10:01:22-07:00
by hei
Thanks, that helped!

Re: mogrify is not preserving file permissions

Posted: 2016-02-09T09:28:31-07:00
by glennrp
In fact, when running on a shared system, it might be a good idea to put the "umask 0077" in your .profile so that by default any file you write with any application will only be accessible to you, and you don't need to worry about forgetting to protect it.