Skip to content

Commit

Permalink
Adding debug logs for request creation and checkACL failure
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulrane50 committed Apr 29, 2022
1 parent 9701911 commit a55e786
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1024,13 +1024,15 @@ public static List<ACL> fixupACL(String path, List<Id> authInfo, List<ACL> acls)
if (ap == null) {
LOG.error("Missing AuthenticationProvider for {}", cid.getScheme());
} else if (ap.isAuthenticated()) {
LOG.debug("Authenticated successfully : {} {}", a, cid);
authIdValid = true;
rv.add(new ACL(a.getPerms(), cid));
}
}
// If the znode path contains open read access node path prefix, add (world:anyone, r)
if (X509AuthenticationConfig.getInstance().getZnodeGroupAclOpenReadAccessPathPrefixes().stream()
.anyMatch(path::startsWith)) {
LOG.debug("Found open read access");
rv.add(new ACL(ZooDefs.Perms.READ, ZooDefs.Ids.ANYONE_ID_UNSAFE));
}

Expand All @@ -1045,6 +1047,7 @@ public static List<ACL> fixupACL(String path, List<Id> authInfo, List<ACL> acls)
rv.add(a);
}
}
LOG.debug("returning rv : {}", rv);
return rv;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ public long fastForwardDataBase() throws IOException {
}

private void addCommittedProposal(TxnHeader hdr, Record txn, TxnDigest digest) {
LOG.debug("Creating a committed proposal request with null cnxn");
Request r = new Request(0, hdr.getCxid(), hdr.getType(), hdr, txn, hdr.getZxid());
r.setTxnDigest(digest);
addCommittedProposal(r);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,7 @@ long createSession(ServerCnxn cnxn, byte[] passwd, int timeout) {
ByteBuffer to = ByteBuffer.allocate(4);
to.putInt(timeout);
cnxn.setSessionId(sessionId);
LOG.debug("Creating a new request for session");
Request si = new Request(cnxn, sessionId, 0, OpCode.createSession, to, null);
submitRequest(si);
return sessionId;
Expand Down Expand Up @@ -1596,7 +1597,7 @@ public void processPacket(ServerCnxn cnxn, ByteBuffer incomingBuffer) throws IOE
new ServerAuthenticationProvider.ServerObjs(this, cnxn),
authPacket.getAuth());
} catch (RuntimeException e) {
LOG.warn("Caught runtime exception from AuthenticationProvider: {}", scheme, e);
LOG.warn("Caught runtime exception from AuthenticationProvider: {} {}", scheme, e);
authReturn = KeeperException.Code.AUTHFAILED;
}
}
Expand Down Expand Up @@ -1631,6 +1632,7 @@ public void processPacket(ServerCnxn cnxn, ByteBuffer incomingBuffer) throws IOE
cnxn.sendCloseSession();
cnxn.disableRecv();
} else {
LOG.debug("Creating a connection request with cnxn for session : {} auth info : {}", cnxn.getSessionId(), cnxn.getAuthInfo());
Request si = new Request(cnxn, cnxn.getSessionId(), h.getXid(), h.getType(), incomingBuffer, cnxn.getAuthInfo());
int length = incomingBuffer.limit();
if (isLargeRequest(length)) {
Expand Down Expand Up @@ -1937,16 +1939,19 @@ public void checkACL(ServerCnxn cnxn, List<ACL> acl, int perm, List<Id> ids, Str
LOG.debug("Permission requested: {} ", perm);
LOG.debug("ACLs for node: {}", acl);
LOG.debug("Client credentials: {}", ids);
LOG.debug("Cnxn : {}", cnxn);

if (acl == null || acl.size() == 0) {
return;
}
for (Id authId : ids) {
if (authId.getScheme().equals("super")) {
LOG.debug("Found super scheme returning from here");
return;
}
}
for (ACL a : acl) {
LOG.debug("Iterating ACLs: {}", a);
Id id = a.getId();
if ((a.getPerms() & perm) != 0) {
if (id.getScheme().equals("world") && id.getId().equals("anyone")) {
Expand All @@ -1955,6 +1960,7 @@ public void checkACL(ServerCnxn cnxn, List<ACL> acl, int perm, List<Id> ids, Str
ServerAuthenticationProvider ap = ProviderRegistry.getServerProvider(id.getScheme());
if (ap != null) {
for (Id authId : ids) {
LOG.debug("Iterating IDs : {}", authId);
if (authId.getScheme().equals(id.getScheme())
&& ap.matches(
new ServerAuthenticationProvider.ServerObjs(this, cnxn),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ public KeeperException.Code handleAuthentication(ServerObjs serverObjs, byte[] a

@Override
public boolean matches(ServerObjs serverObjs, MatchValues matchValues) {
LOG.debug("Server obj cnxn : {}", serverObjs.getCnxn());
if (serverObjs.getCnxn() != null) {
LOG.debug("Auth info in cnxn obj : {}", serverObjs.getCnxn().getAuthInfo());
} else {
LOG.debug("Found null cnxn");
}
for (Id id : serverObjs.getCnxn().getAuthInfo()) {
// Not checking for super user here because the check is already covered
// in checkAcl() in ZookeeperServer.class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@ protected void syncWithLeader(long newLeaderZxid) throws Exception {
continue;
}
packetsCommitted.remove();
LOG.debug("Creating request with empty cnxn and empty authinfo");
Request request = new Request(null, p.hdr.getClientId(), p.hdr.getCxid(), p.hdr.getType(), null, null);
request.setTxn(p.rec);
request.setHdr(p.hdr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ public void run() {
if (type == OpCode.sync) {
si = new LearnerSyncRequest(this, sessionId, cxid, type, bb, qp.getAuthinfo());
} else {
LOG.debug("Creating request with null cnxn and authinfo : {}", qp.getAuthinfo());
si = new Request(null, sessionId, cxid, type, bb, qp.getAuthinfo());
}
si.setOwner(this);
Expand Down

0 comments on commit a55e786

Please sign in to comment.