Skip to content

Commit

Permalink
Merge pull request #1746 from gbehrmann/fix/2.10/rb8382
Browse files Browse the repository at this point in the history
chimera: Fix path resolution on delete
  • Loading branch information
paulmillar committed Jul 14, 2015
2 parents 60fbf34 + c781e18 commit e34f829
Showing 1 changed file with 25 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -384,36 +384,38 @@ public void deleteEntry(Subject subject, String path)
throws CacheException
{
try {
if (!Subjects.isRoot(subject)) {
File file = new File(path);
String parentPath = file.getParent();
File filePath = new File(path);

if (parentPath != null) {
ExtendedInode inode = new ExtendedInode(pathToInode(subject, path));
FsInode inodeParent = _fs.path2inode(parentPath);
String parentPath = filePath.getParent();
if (parentPath == null) {
throw new CacheException("Cannot delete file system root.");
}

FileAttributes parentAttributes =
getFileAttributesForPermissionHandler(inodeParent);
FileAttributes fileAttributes =
getFileAttributesForPermissionHandler(inode);
ExtendedInode parent = new ExtendedInode(pathToInode(subject, parentPath));
String name = filePath.getName();

if (inode.isDirectory()) {
if (_permissionHandler.canDeleteDir(subject,
parentAttributes,
fileAttributes) != ACCESS_ALLOWED) {
throw new PermissionDeniedCacheException("Access denied: " + path);
}
} else {
if (_permissionHandler.canDeleteFile(subject,
parentAttributes,
fileAttributes) != ACCESS_ALLOWED) {
throw new PermissionDeniedCacheException("Access denied: " + path);
}
if (!Subjects.isRoot(subject)) {
ExtendedInode inode = parent.inodeOf(name);

FileAttributes parentAttributes = getFileAttributesForPermissionHandler(parent);
FileAttributes fileAttributes = getFileAttributesForPermissionHandler(inode);

if (inode.isDirectory()) {
if (_permissionHandler.canDeleteDir(subject,
parentAttributes,
fileAttributes) != ACCESS_ALLOWED) {
throw new PermissionDeniedCacheException("Access denied: " + path);
}
} else {
if (_permissionHandler.canDeleteFile(subject,
parentAttributes,
fileAttributes) != ACCESS_ALLOWED) {
throw new PermissionDeniedCacheException("Access denied: " + path);
}
}
}

_fs.remove(path);
_fs.remove(parent, name);
}catch(FileNotFoundHimeraFsException fnf) {
throw new FileNotFoundCacheException("No such file or directory: " + path);
}catch(DirNotEmptyHimeraFsException e) {
Expand Down

0 comments on commit e34f829

Please sign in to comment.