How can I set the umask from within java?

You can’t fiddle with the umask directly, since Java is an abstraction and the umask is POSIX-implementation specific. But you have the following API: File f; f.setExecutable(true); f.setReadable(false); f.setWritable(true); There are some more APIs available, check the docs. If you must have direct access to the umask, either do it via JNI and the chmod() … Read more

How can I get the Unix permission mask from a file? [duplicate]

os.stat is a wrapper around the stat(2) system call interface. >>> import os >>> from stat import * >>> os.stat(“test.txt”) # returns 10-tupel, you really want the 0th element … posix.stat_result(st_mode=33188, st_ino=57197013, \ st_dev=234881026L, st_nlink=1, st_uid=501, st_gid=20, st_size=0, \ st_atime=1300354697, st_mtime=1300354697, st_ctime=1300354697) >>> os.stat(“test.txt”)[ST_MODE] # this is an int, but we like octal … 33188 … Read more

shutil.rmtree fails on Windows with ‘Access is denied’ [duplicate]

Check this question out: What user do python scripts run as in windows? Apparently the answer is to change the file/folder to not be read-only and then remove it. Here’s onerror() handler from pathutils.py mentioned by @Sridhar Ratnakumar in comments: def onerror(func, path, exc_info): “”” Error handler for “shutil.rmtree“. If the error is due to … Read more

java.security.AccessControlException: Access denied (java.io.FilePermission

Within your <jre location>\lib\security\java.policy try adding: grant { permission java.security.AllPermission; }; And see if it allows you. If so, you will have to add more granular permissions. See: Java 8 Documentation for java.policy files and http://java.sun.com/developer/onlineTraining/Programming/JDCBook/appA.html

What user do python scripts run as in windows? [duplicate]

We’ve had issues removing files and directories on Windows, even if we had just copied them, if they were set to ‘readonly’. shutil.rmtree() offers you sort of exception handlers to handle this situation. You call it and provide an exception handler like this: import errno, os, stat, shutil def handleRemoveReadonly(func, path, exc): excvalue = exc[1] … Read more

How to give Read/Write permissions to a Folder during installation using .NET

I guess my other post was deleted for being a little too general, so I’ve refined it below: The thing to do is make a custom action. It’s pretty straightforward, check out the MSDN walkthrough for writing a C# custom action here. You’ll put your permission-changing code inside the Install method: Follow the first few … Read more

tech