Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(4.x.x) Fix an issue with lock lifetime when changing permissions #2251

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/org/exist/security/PermissionFactory.java
Expand Up @@ -34,7 +34,6 @@
import org.exist.storage.txn.TransactionManager;
import org.exist.storage.txn.Txn;
import com.evolvedbinary.j8fu.function.ConsumerE;
import org.exist.util.LockException;
import org.exist.xmldb.XmldbURI;
import org.exist.xquery.XPathException;

Expand Down Expand Up @@ -125,8 +124,8 @@ public static void updatePermissions(final DBBroker broker, final XmldbURI pathU
throw new XPathException("Resource or collection '" + pathUri.toString() + "' does not exist.");
}

// keep a write lock in the transaction
transaction.acquireLock(doc.getUpdateLock(), LockMode.WRITE_LOCK);
// // keep a write lock in the transaction
// transaction.acquireLock(doc.getUpdateLock(), LockMode.WRITE_LOCK);

final Permission permissions = doc.getPermissions();
permissionModifier.accept(permissions);
Expand All @@ -140,8 +139,8 @@ public static void updatePermissions(final DBBroker broker, final XmldbURI pathU
transact.commit(transaction);
broker.flush();
} else {
// keep a write lock in the transaction
transaction.acquireLock(collection.getLock(), LockMode.WRITE_LOCK);
// // keep a write lock in the transaction
// transaction.acquireLock(collection.getLock(), LockMode.WRITE_LOCK);

final Permission permissions = collection.getPermissionsNoLock();
permissionModifier.accept(permissions);
Expand All @@ -155,7 +154,7 @@ public static void updatePermissions(final DBBroker broker, final XmldbURI pathU
collection.release(LockMode.WRITE_LOCK);
}
}
} catch(final XPathException | PermissionDeniedException | IOException | TriggerException | TransactionException | LockException e) {
} catch(final XPathException | PermissionDeniedException | IOException | TriggerException | TransactionException e) {
throw new PermissionDeniedException("Permission to modify permissions is denied for user '" + broker.getCurrentSubject().getName() + "' on '" + pathUri.toString() + "': " + e.getMessage(), e);
}
}
Expand Down