java.lang.Object
java.io.File
net.i2p.util.SecureDirectory
- All Implemented Interfaces:
Serializable, Comparable<File>
- Direct Known Subclasses:
SecureFile
Same as File but sets the file mode after
mkdir() so it can be read and written by the owner only (i.e. 700 on linux) As of 0.8.2, just use SecureFile instead of this.- See Also:
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanWhether a newly created directory gets group read/write/execute (770) instead of owner-only (700).protected static final booleanWhether the OS is not Windows.Fields inherited from class File
pathSeparator, pathSeparatorChar, separator, separatorCharConstructor Summary
ConstructorsConstructorDescriptionSecureDirectory(File parent, String child) SecureDirectory, owner-only (700) on creation.SecureDirectory(File parent, String child, boolean groupPerms) Records whether mkdir should make this child directory group-accessible rather than owner-only.SecureDirectory(String pathname) SecureDirectory, owner-only (700) on creation.SecureDirectory(String pathname, boolean groupPerms) Records whether mkdir should make this path group-accessible rather than owner-only.SecureDirectory(String parent, String child) SecureDirectory, owner-only (700) on creation.SecureDirectory(String parent, String child, boolean groupPerms) Records whether mkdir should make this child path group-accessible rather than owner-only.Method Summary
Public MethodsModifier and TypeMethodDescriptionbooleanmkdir()Sets directory mode on creation: 700 by default, or 770 when the directory was requested group-accessible.booleanmkdirs()Sets directory mode on creation: 700 by default, or 770 when the directory was requested group-accessible.protected voidsetPerms()Tries to set the permissions to 700 (or 770 when this directory was requested group-accessible), ignores errors.Methods inherited from class File
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toPath, toString, toURI
Field Details
isNotWindows
protected static final boolean isNotWindowsWhether the OS is not Windows._groupPerms
private final boolean _groupPermsWhether a newly created directory gets group read/write/execute (770) instead of owner-only (700). Set by the constructor overloads that take this flag; a directory is only ever widened at creation time, never after.
Constructor Details
SecureDirectory
SecureDirectory, owner-only (700) on creation.- Parameters:
pathname- the directory path; perms are set when mkdir() creates it
SecureDirectory
Records whether mkdir should make this path group-accessible rather than owner-only.- Parameters:
pathname- the directory to create if absent and lock downgroupPerms- true to create the directory group-accessible (770) instead of owner-only (700)
SecureDirectory
SecureDirectory
SecureDirectory
SecureDirectory
Method Details
mkdir
mkdirs
setPerms
protected void setPerms()Tries to set the permissions to 700 (or 770 when this directory was requested group-accessible), ignores errors.Uses the
PosixFilePermissionAPI rather thanFile.setReadable(boolean, boolean): theFilesetters take anownerOnlyflag, so there is no way to grant the group without also granting others —setReadable(true, false)yields 777, not 770.SecureFileOutputStream.setGroupPerms()sets file permissions the same way for the same reason.The execute bit matters as much as read here: a group can read a file inside a directory it cannot traverse, so a group-traversable parent is what actually makes group-readable log files reachable.