I have a script that runs CPAN::Mini::Inject actions and has an App::Cache. It works fine, but sometimes i need to run it from different user accounts, which is when i run afoul of file permissions, since some files are automatically created with 0740 permissions.
Right now i'm using a crutch of system("chmod -R a+w .")
, but i'm not liking that.
Is there a way i can enforce, for the scope of the script, a global file mode of 0777 for all created files?
You can use the umask
built-in to change the default file mode. For instance umask 0
will change the default mode to 0777.
BUT, if files are being created with rights 0740, it probably means that CPAN::Mini::Inject is setting the permissions explicitly and the umask may not do any effect.
In that later case, you will have to dive into the module souce code, look for the place where permissions are set and see if you can overload it in anyway. Another option is to just submit a feature request to the author.
BTW, the CPAN::Mini module accepts a dirmode
option to set directory permissions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With