diff options
author | Stefan Metzmacher <metze@samba.org> | 2014-02-17 11:57:52 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2014-02-21 12:48:31 +0100 |
commit | 9677fae6aab26d2bf0884dc31516d2dcd8840c03 (patch) | |
tree | a11c9f461d764b0691f346f8dc79975ac305cfb4 /source3/lib | |
parent | 52ccb40d595fc80bfa53b0b9cd75ffb902369681 (diff) | |
download | samba-9677fae6aab26d2bf0884dc31516d2dcd8840c03.tar.gz samba-9677fae6aab26d2bf0884dc31516d2dcd8840c03.tar.xz samba-9677fae6aab26d2bf0884dc31516d2dcd8840c03.zip |
s3:lib/ctdbd_conn: let release_ip_handler return bool
If it returns true the passed ip address matched and we
let a nested ctdb operation fail with NT_STATUS_ADDRESS_CLOSED.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/ctdbd_conn.c | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index 6ab4bbe7046..4d903248b99 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -59,7 +59,7 @@ struct ctdbd_connection { struct ctdb_packet_context *pkt; struct tevent_fd *fde; - void (*release_ip_handler)(const char *ip_addr, void *private_data); + bool (*release_ip_handler)(const char *ip_addr, void *private_data); void *release_ip_priv; }; @@ -428,10 +428,23 @@ static NTSTATUS ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid, if ((conn->release_ip_handler != NULL) && (msg->srvid == CTDB_SRVID_RELEASE_IP)) { + bool ret; + /* must be dispatched immediately */ DEBUG(10, ("received CTDB_SRVID_RELEASE_IP\n")); - conn->release_ip_handler((const char *)msg->data, - conn->release_ip_priv); + ret = conn->release_ip_handler((const char *)msg->data, + conn->release_ip_priv); + if (ret) { + /* + * We need to release the ip, + * so return an error to the upper layers. + * + * We make sure we don't trigger this again. + */ + conn->release_ip_handler = NULL; + conn->release_ip_priv = NULL; + return NT_STATUS_ADDRESS_CLOSED; + } TALLOC_FREE(hdr); goto next_pkt; } @@ -630,10 +643,21 @@ static NTSTATUS ctdb_handle_message(uint8_t *buf, size_t length, if ((conn->release_ip_handler != NULL) && (msg->srvid == CTDB_SRVID_RELEASE_IP)) { + bool ret; + /* must be dispatched immediately */ DEBUG(10, ("received CTDB_SRVID_RELEASE_IP\n")); - conn->release_ip_handler((const char *)msg->data, - conn->release_ip_priv); + ret = conn->release_ip_handler((const char *)msg->data, + conn->release_ip_priv); + if (ret) { + /* + * We need to release the ip. + * + * We make sure we don't trigger this again. + */ + conn->release_ip_handler = NULL; + conn->release_ip_priv = NULL; + } TALLOC_FREE(buf); return NT_STATUS_OK; } @@ -1692,7 +1716,7 @@ static void smbd_ctdb_canonicalize_ip(const struct sockaddr_storage *in, NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn, const struct sockaddr_storage *_server, const struct sockaddr_storage *_client, - void (*release_ip_handler)(const char *ip_addr, + bool (*release_ip_handler)(const char *ip_addr, void *private_data), void *private_data) { |