开发者

Is there a way to set global permissions for all files created by a perl script?

I have a script that runs CPAN::Mini::Inject a开发者_C百科ctions 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.


Have a look at umask.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜