* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: message.c,v 1.28.4.1 2001/01/09 22:53:00 bwelling Exp $ */
+/* $Id: message.c,v 1.28.4.2 2003/08/29 07:08:32 marka Exp $ */
/*
* Subroutines for dealing with message objects.
#include <stddef.h>
#include <isc/buffer.h>
+#include <isc/random.h>
#include <isc/string.h>
#include <isc/util.h>
if (result == ISC_R_SUCCESS)
/* XXXTL Write the ID of the authentication key we're using. */
- result = omapi_connection_putuint32(connection, 0);
+ result = omapi_connection_putuint32(connection, p->authid);
if (result == ISC_R_SUCCESS)
result = omapi_connection_putuint32(connection, authlen);
* Set and write the transaction ID.
*/
m->id = p->next_xid++;
+ if (m->id == 0)
+ m->id = p->next_xid++;
result = omapi_connection_putuint32(connection, m->id);
}
dst_context_destroy(&protocol->dstctx);
}
+ if (protocol->verify_result == ISC_R_SUCCESS &&
+ protocol->authid != 0)
+ if (protocol->authid != message->authid)
+ result = OMAPI_R_BADAUTHID;
+
if (protocol->verify_result != ISC_R_SUCCESS) {
if (connection->is_client) {
INSIST(m != NULL);
return (send_status(po,
protocol->verify_result,
message->id,
+ protocol->authid,
"failed to verify "
"signature"));
}
if (m != NULL) {
return (send_status(po, OMAPI_R_INVALIDARG,
- message->id,
+ message->id, protocol->authid,
"OPEN can't be a response"));
}
} else if (result == ISC_R_NOTFOUND)
type = NULL;
else
- return (send_status(po, result, message->id,
+ return (send_status(po, result, message->id,
+ protocol->authid,
isc_result_totext(result)));
/*
create = 0;
else
return (send_status(po, result, message->id,
+ protocol->authid,
isc_result_totext(result)));
/*
update = 0;
else
return (send_status(po, result, message->id,
+ protocol->authid,
isc_result_totext(result)));
/*
exclusive = 0;
else
return (send_status(po, result, message->id,
+ protocol->authid,
isc_result_totext(result)));
/*
#ifdef notyet /* not for 9.0.0 */
if (type != omapi_type_protocol && protocol->key == NULL)
return (send_status(po, ISC_R_NOPERM, message->id,
+ protocol->authid,
"unauthorized access"));
#endif /* notyet */
if (create != 0)
return (send_status(po, OMAPI_R_INVALIDARG,
message->id,
+ protocol->authid,
"type required on create"));
goto refresh;
if (message->object == NULL)
return (send_status(po, ISC_R_NOTFOUND, message->id,
+ protocol->authid,
"no lookup key specified"));
/*
if (result == ISC_R_NOTIMPLEMENTED)
return (send_status(po, result, message->id,
+ protocol->authid,
"unsearchable object type"));
if (result != ISC_R_SUCCESS &&
result != ISC_R_NOTFOUND &&
result != OMAPI_R_NOKEYS)
return (send_status(po, result, message->id,
+ protocol->authid,
"object lookup failed"));
/*
*/
if (result == ISC_R_NOTFOUND && create == 0) {
return (send_status(po, ISC_R_NOTFOUND, message->id,
+ protocol->authid,
"no object matches specification"));
}
if (result == ISC_R_SUCCESS && create != 0 && exclusive != 0) {
OBJECT_DEREF(&object);
return (send_status(po, ISC_R_EXISTS, message->id,
+ protocol->authid,
"specified object already exists"));
}
result = object_methodcreate(type, &object);
if (result != ISC_R_SUCCESS)
return (send_status(po, result, message->id,
+ protocol->authid,
"can't create new object"));
}
if (result != ISC_R_SUCCESS) {
OBJECT_DEREF(&object);
return (send_status(po, result, message->id,
+ protocol->authid,
"can't update object"));
}
}
#ifdef notyet /* not for 9.0.0 */
if (protocol->key == NULL)
return (send_status(po, ISC_R_NOPERM, message->id,
+ protocol->authid,
"unauthorized access"));
#endif /* notyet */
result = handle_lookup(&object, message->h);
if (result != ISC_R_SUCCESS)
return (send_status(po, result, message->id,
+ protocol->authid,
"no matching handle"));
send:
- result = send_update(po, message->id, object);
+ result = send_update(po, message->id, protocol->authid, object);
OBJECT_DEREF(&object);
return (result);
if (! connection->is_client)
return (send_status(po, OMAPI_R_INVALIDARG,
message->id,
+ protocol->authid,
"OMAPI_OP_UPDATE is not a "
"valid server operation"));
result = handle_lookup(&object, message->h);
if (result != ISC_R_SUCCESS)
return (send_status(po, result, message->id,
+ protocol->authid,
"no matching handle"));
}
if (result != ISC_R_SUCCESS) {
if (message->rid == 0)
return (send_status(po, result, message->id,
+ protocol->authid,
"can't update object"));
if (m != NULL)
object_signal((omapi_object_t *)m,
if (message->rid == 0)
result = send_status(po, ISC_R_SUCCESS, message->id,
+ protocol->authid,
NULL);
if (m != NULL)
case OMAPI_OP_NOTIFY:
return (send_status(po, ISC_R_NOTIMPLEMENTED, message->id,
+ protocol->authid,
"notify not implemented yet"));
case OMAPI_OP_STATUS:
if (! connection->is_client)
return (send_status(po, OMAPI_R_INVALIDARG,
message->id,
+ protocol->authid,
"OMAPI_OP_STATUS is not a "
"valid server operation"));
if (protocol->key == NULL)
return (send_status(po, ISC_R_NOPERM, message->id,
+ protocol->authid,
"unauthorized delete"));
result = handle_lookup(&object, message->h);
if (result != ISC_R_SUCCESS)
return (send_status(po, result, message->id,
+ protocol->authid,
"no matching handle"));
result = object_methodexpunge(object->type, object);
if (result == ISC_R_NOTIMPLEMENTED)
return (send_status(po, ISC_R_NOTIMPLEMENTED,
message->id,
+ protocol->authid,
"no remove method for object"));
OBJECT_DEREF(&object);
- return (send_status(po, result, message->id, NULL));
+ return (send_status(po, result, message->id,
+ protocol->authid, NULL));
}
return (ISC_R_NOTIMPLEMENTED);
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: protocol.c,v 1.32.4.1 2001/01/09 22:53:03 bwelling Exp $ */
+/* $Id: protocol.c,v 1.32.4.2 2003/08/29 07:08:32 marka Exp $ */
/*
* Functions supporting the object management protocol.
#include <isc/buffer.h>
#include <isc/mem.h>
+#include <isc/random.h>
#include <isc/string.h>
#include <isc/util.h>
* Make up an initial transaction ID for this connection.
* XXXDCL better generator than random()?
*/
- p->next_xid = random();
+ isc_random_get(&p->next_xid);
result = connection_send(connection);
isc_result_t
send_status(omapi_object_t *po, isc_result_t waitstatus,
- unsigned int rid, const char *msg)
+ unsigned int rid, unsigned int authid, const char *msg)
{
isc_result_t result;
omapi_object_t *message = NULL;
if (result == ISC_R_SUCCESS)
result = omapi_object_setinteger(message, "rid", (int)rid);
+ if (result == ISC_R_SUCCESS)
+ result = omapi_object_setinteger(message, "authid",
+ (int)authid);
+
if (result == ISC_R_SUCCESS)
result = omapi_object_setinteger(message, "result",
(int)waitstatus);
}
isc_result_t
-send_update(omapi_object_t *po, unsigned int rid, omapi_object_t *object) {
+send_update(omapi_object_t *po, unsigned int rid, unsigned int authid,
+ omapi_object_t *object)
+{
isc_result_t result;
omapi_object_t *message = NULL;
result = omapi_object_setinteger(message, "rid", (int)rid);
+ if (result == ISC_R_SUCCESS)
+ result = omapi_object_setinteger(message, "authid",
+ (int)authid);
+
if (result == ISC_R_SUCCESS)
result = object_gethandle(&handle, object);
*/
/* XXXDCL authid is unused */
connection_getuint32(connection, &protocol->message->authid);
+ if (protocol->authid == 0)
+ protocol->authid = protocol->message->authid;
/* XXXTL bind the authenticator here! */
connection_getuint32(connection, &protocol->message->authlen);
connection_getuint32(connection, &protocol->message->op);