summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2012-02-16 08:43:35 -0500
committerStephen Gallagher <sgallagh@redhat.com>2012-02-17 11:10:07 -0500
commitacbc134c063e92a8db1237e1444ad4ada5f54ff8 (patch)
tree4bd4340febaef820a4c6cd234a5f70e658675974
parentf5d4b05027acce06e3509ecb68869d1c7ef37180 (diff)
downloadsssd-acbc134c063e92a8db1237e1444ad4ada5f54ff8.tar.gz
sssd-acbc134c063e92a8db1237e1444ad4ada5f54ff8.tar.bz2
sssd-acbc134c063e92a8db1237e1444ad4ada5f54ff8.zip
NSS: Always return the same protocol that was requested
https://fedorahosted.org/sssd/ticket/1160
-rw-r--r--src/responder/nss/nsssrv_private.h3
-rw-r--r--src/responder/nss/nsssrv_services.c32
2 files changed, 26 insertions, 9 deletions
diff --git a/src/responder/nss/nsssrv_private.h b/src/responder/nss/nsssrv_private.h
index c6526595..c9fb0d0a 100644
--- a/src/responder/nss/nsssrv_private.h
+++ b/src/responder/nss/nsssrv_private.h
@@ -70,6 +70,9 @@ struct nss_dom_ctx {
/* Netgroup-specific */
struct getent_ctx *netgr;
+
+ /* Service-specific */
+ const char *protocol;
};
struct setent_step_ctx {
diff --git a/src/responder/nss/nsssrv_services.c b/src/responder/nss/nsssrv_services.c
index 2f2a25c2..13d142e4 100644
--- a/src/responder/nss/nsssrv_services.c
+++ b/src/responder/nss/nsssrv_services.c
@@ -591,6 +591,7 @@ static errno_t
fill_service(struct sss_packet *packet,
struct sss_domain_info *dom,
struct nss_ctx *nctx,
+ const char *protocol,
struct ldb_message **msgs,
unsigned int *count)
{
@@ -603,7 +604,7 @@ fill_service(struct sss_packet *packet,
struct ldb_message_element *el;
TALLOC_CTX *tmp_ctx = NULL;
const char *orig_name;
- char *orig_proto;
+ const char *orig_proto;
struct sized_string cased_name;
struct sized_string cased_proto;
uint16_t port;
@@ -662,16 +663,23 @@ fill_service(struct sss_packet *packet,
}
/* Get the service protocol.
+ * Use the requested protocol if present,
+ * otherwise take the first protocol returned
+ * by the sysdb.
* If more than one is available, select the
* first in the message.
*/
- el = ldb_msg_find_element(msg, SYSDB_SVC_PROTO);
- if (el->num_values == 0) {
- ret = EINVAL;
- num = 0;
- goto done;
+ if (protocol) {
+ orig_proto = protocol;
+ } else {
+ el = ldb_msg_find_element(msg, SYSDB_SVC_PROTO);
+ if (el->num_values == 0) {
+ ret = EINVAL;
+ num = 0;
+ goto done;
+ }
+ orig_proto = (const char *)el->values[0].data;
}
- orig_proto = (char *)el->values[0].data;
tmpstr = sss_get_cased_name(tmp_ctx, orig_proto, dom->case_sensitive);
if (tmpstr == NULL) {
@@ -817,6 +825,8 @@ int nss_cmd_getservbyname(struct cli_ctx *cctx)
goto done;
}
+ dctx->protocol = service_protocol;
+
DEBUG(SSSDBG_TRACE_FUNC,
("Requesting info for service [%s:%s] from [%s]\n",
service_name,
@@ -999,7 +1009,9 @@ nss_cmd_getserv_done(struct tevent_req *req)
i = dctx->res->count;
ret = fill_service(cmdctx->cctx->creq->out,
dctx->domain,
- nctx, dctx->res->msgs,
+ nctx,
+ dctx->protocol,
+ dctx->res->msgs,
&i);
}
if (ret != EOK) {
@@ -1130,6 +1142,8 @@ int nss_cmd_getservbyport(struct cli_ctx *cctx)
goto done;
}
+ dctx->protocol = service_protocol;
+
DEBUG(SSSDBG_TRACE_FUNC,
("Requesting info for service on port [%lu/%s]\n",
port, service_protocol ? service_protocol : "<ANY>"));
@@ -1770,7 +1784,7 @@ retservent(struct cli_ctx *cctx, int num)
ret = fill_service(cctx->creq->out,
pdom->domain,
- nctx, msgs,
+ nctx, NULL, msgs,
&n);
cctx->svcent_cur += n;