Minor cleanup of server handling and null DNs

This commit is contained in:
Mark Cavage 2011-11-07 17:12:59 -08:00
parent 75aba691f1
commit 28ddaaad69
2 changed files with 46 additions and 43 deletions

View File

@ -239,7 +239,7 @@ DN.prototype.parentOf = function(dn) {
if (typeof(dn) !== 'object')
dn = parse(dn);
if (this.rdns.length >= dn.rdns.length)
if (!this.rdns.length || this.rdns.length >= dn.rdns.length)
return false;
var diff = dn.rdns.length - this.rdns.length;

View File

@ -367,6 +367,7 @@ function Server(options) {
}
if (err) {
log.trace('%s sending error: %s', req.logId, err.stack || err);
sendError(err);
return after();
}
@ -444,7 +445,7 @@ function Server(options) {
});
this.__defineGetter__('url', function() {
var str;
if (options.certificate && options.key) {
if (this.server instanceof tls.Server) {
str = 'ldaps://';
} else {
str = 'ldap://';
@ -745,9 +746,11 @@ Server.prototype._getHandlerChain = function(req) {
var self = this;
var routes = this.routes;
for (var r in routes) {
if (routes.hasOwnProperty(r)) {
var keys = Object.keys(routes);
for (var i = 0; i < keys.length; i++) {
var r = keys[i];
var route = routes[r];
// Special cases are abandons, exops and unbinds, handle those first.
if (req.protocolOp === Protocol.LDAP_REQ_EXTENSION) {
if (r !== req.requestName)
@ -783,7 +786,8 @@ Server.prototype._getHandlerChain = function(req) {
// Otherwise, match via DN rules
assert.ok(req.dn);
assert.ok(route.dn);
if (r !== req.dn.toString() && (!route.dn.parentOf(req.dn)))
if (!route.dn.equals(req.dn) && !route.dn.parentOf(req.dn))
continue;
// We should be good to go.
@ -793,7 +797,6 @@ Server.prototype._getHandlerChain = function(req) {
handlers: route[op] || [defaultHandler]
};
}
}
// We're here, so nothing matched.
return {
@ -801,7 +804,7 @@ Server.prototype._getHandlerChain = function(req) {
handlers: [(req.protocolOp !== Protocol.LDAP_REQ_EXTENSION ?
noSuffixHandler : noExOpHandler)]
};
};
}
Server.prototype._mount = function(op, name, argv, notDN) {