summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-01-08 00:59:32 -0500
committerJakub Hrozek <jhrozek@redhat.com>2013-01-15 10:53:03 +0100
commit681742138b2afbbefa7f14de937beb438409208e (patch)
tree8261b14012f0d994cfdd91005a237581ae8a400a
parent740870643f337ce70d85f25f9ed057cd1f91028c (diff)
downloadsssd-681742138b2afbbefa7f14de937beb438409208e.tar.gz
sssd-681742138b2afbbefa7f14de937beb438409208e.tar.bz2
sssd-681742138b2afbbefa7f14de937beb438409208e.zip
Add domain arguments to sysdb services functions
also fix sysdb_svc_add declarations
-rw-r--r--src/db/sysdb_services.c38
-rw-r--r--src/db/sysdb_services.h16
-rw-r--r--src/providers/ldap/ldap_id_services.c4
-rw-r--r--src/providers/ldap/sdap_reinit.c5
-rw-r--r--src/providers/proxy/proxy_services.c4
-rw-r--r--src/responder/nss/nsssrv_services.c12
-rw-r--r--src/tests/sysdb-tests.c24
-rw-r--r--src/tools/sss_cache.c5
8 files changed, 59 insertions, 49 deletions
diff --git a/src/db/sysdb_services.c b/src/db/sysdb_services.c
index 2ac8d9a4..b8ac9ef7 100644
--- a/src/db/sysdb_services.c
+++ b/src/db/sysdb_services.c
@@ -26,15 +26,6 @@
#include "db/sysdb_private.h"
#include "db/sysdb_services.h"
-errno_t
-sysdb_svc_add(TALLOC_CTX *mem_ctx,
- struct sysdb_ctx *sysdb,
- const char *primary_name,
- int port,
- const char **aliases,
- const char **protocols,
- struct ldb_dn **dn);
-
static errno_t
sysdb_svc_update(struct sysdb_ctx *sysdb,
struct ldb_dn *dn,
@@ -50,6 +41,7 @@ sysdb_svc_remove_alias(struct sysdb_ctx *sysdb,
errno_t
sysdb_getservbyname(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *name,
const char *proto,
struct ldb_result **_res)
@@ -89,7 +81,7 @@ sysdb_getservbyname(TALLOC_CTX *mem_ctx,
goto done;
}
- ret = sysdb_search_services(mem_ctx, sysdb, subfilter,
+ ret = sysdb_search_services(mem_ctx, sysdb, domain, subfilter,
attrs, &msgs_count, &msgs);
if (ret == EOK) {
res = talloc_zero(mem_ctx, struct ldb_result);
@@ -111,6 +103,7 @@ done:
errno_t
sysdb_getservbyport(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
int port,
const char *proto,
struct ldb_result **_res)
@@ -148,7 +141,7 @@ sysdb_getservbyport(TALLOC_CTX *mem_ctx,
goto done;
}
- ret = sysdb_search_services(mem_ctx, sysdb, subfilter,
+ ret = sysdb_search_services(mem_ctx, sysdb, domain, subfilter,
attrs, &msgs_count, &msgs);
if (ret == EOK) {
res = talloc_zero(mem_ctx, struct ldb_result);
@@ -208,7 +201,7 @@ sysdb_store_service(struct sysdb_ctx *sysdb,
* properly. Last entry saved to the cache should
* always "win".
*/
- ret = sysdb_getservbyport(tmp_ctx, sysdb, port, NULL, &res);
+ ret = sysdb_getservbyport(tmp_ctx, sysdb, domain, port, NULL, &res);
if (ret != EOK && ret != ENOENT) {
goto done;
} else if (ret != ENOENT) {
@@ -274,7 +267,7 @@ sysdb_store_service(struct sysdb_ctx *sysdb,
* need to update existing entries or modify
* aliases.
*/
- ret = sysdb_getservbyname(tmp_ctx, sysdb, primary_name, NULL, &res);
+ ret = sysdb_getservbyname(tmp_ctx, sysdb, domain, primary_name, NULL, &res);
if (ret != EOK && ret != ENOENT) {
goto done;
} else if (ret != ENOENT) { /* Found entries */
@@ -358,7 +351,7 @@ sysdb_store_service(struct sysdb_ctx *sysdb,
ret = sysdb_svc_update(sysdb, update_dn, port, aliases, protocols);
} else {
/* Add a new entry */
- ret = sysdb_svc_add(tmp_ctx, sysdb, primary_name, port,
+ ret = sysdb_svc_add(tmp_ctx, sysdb, domain, primary_name, port,
aliases, protocols, &update_dn);
}
if (ret != EOK) goto done;
@@ -438,6 +431,7 @@ sysdb_svc_dn(struct sysdb_ctx *sysdb, TALLOC_CTX *mem_ctx,
errno_t
sysdb_svc_add(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *primary_name,
int port,
const char **aliases,
@@ -460,7 +454,7 @@ sysdb_svc_add(TALLOC_CTX *mem_ctx,
}
/* svc dn */
- msg->dn = sysdb_svc_dn(sysdb, msg, sysdb->domain->name, primary_name);
+ msg->dn = sysdb_svc_dn(sysdb, msg, domain->name, primary_name);
if (!msg->dn) {
ret = ENOMEM;
goto done;
@@ -643,6 +637,7 @@ done:
errno_t
sysdb_svc_delete(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *name,
int port,
const char *proto)
@@ -667,7 +662,7 @@ sysdb_svc_delete(struct sysdb_ctx *sysdb,
in_transaction = true;
if (name) {
- ret = sysdb_getservbyname(tmp_ctx, sysdb, name, proto, &res);
+ ret = sysdb_getservbyname(tmp_ctx, sysdb, domain, name, proto, &res);
if (ret != EOK && ret != ENOENT) goto done;
if (ret == ENOENT) {
/* Doesn't exist in the DB. Nothing to do */
@@ -675,7 +670,7 @@ sysdb_svc_delete(struct sysdb_ctx *sysdb,
goto done;
}
} else {
- ret = sysdb_getservbyport(tmp_ctx, sysdb, port, proto, &res);
+ ret = sysdb_getservbyport(tmp_ctx, sysdb, domain, port, proto, &res);
if (ret != EOK && ret != ENOENT) goto done;
if (ret == ENOENT) {
/* Doesn't exist in the DB. Nothing to do */
@@ -721,6 +716,7 @@ done:
errno_t
sysdb_enumservent(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
struct ldb_result **_res)
{
errno_t ret;
@@ -735,7 +731,7 @@ sysdb_enumservent(TALLOC_CTX *mem_ctx,
return ENOMEM;
}
- ret = sysdb_search_services(mem_ctx, sysdb, "",
+ ret = sysdb_search_services(mem_ctx, sysdb, domain, "",
attrs, &msgs_count, &msgs);
if (ret == EOK) {
res = talloc_zero(mem_ctx, struct ldb_result);
@@ -756,6 +752,7 @@ done:
errno_t
sysdb_set_service_attr(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *name,
struct sysdb_attrs *attrs,
int mod_op)
@@ -769,7 +766,7 @@ sysdb_set_service_attr(struct sysdb_ctx *sysdb,
return ENOMEM;
}
- dn = sysdb_svc_dn(sysdb, tmp_ctx, sysdb->domain->name, name);
+ dn = sysdb_svc_dn(sysdb, tmp_ctx, domain->name, name);
if (!dn) {
ret = ENOMEM;
goto done;
@@ -784,6 +781,7 @@ done:
errno_t sysdb_search_services(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *sub_filter,
const char **attrs,
size_t *msgs_count,
@@ -800,7 +798,7 @@ errno_t sysdb_search_services(TALLOC_CTX *mem_ctx,
}
basedn = ldb_dn_new_fmt(tmp_ctx, sysdb->ldb,
- SYSDB_TMPL_SVC_BASE, sysdb->domain->name);
+ SYSDB_TMPL_SVC_BASE, domain->name);
if (!basedn) {
DEBUG(SSSDBG_OP_FAILURE, ("Failed to build base dn\n"));
ret = ENOMEM;
diff --git a/src/db/sysdb_services.h b/src/db/sysdb_services.h
index 467a6584..2ec9a3b6 100644
--- a/src/db/sysdb_services.h
+++ b/src/db/sysdb_services.h
@@ -48,6 +48,7 @@
errno_t
sysdb_getservbyname(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *name,
const char *proto,
struct ldb_result **_res);
@@ -55,6 +56,7 @@ sysdb_getservbyname(TALLOC_CTX *mem_ctx,
errno_t
sysdb_getservbyport(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
int port,
const char *proto,
struct ldb_result **_res);
@@ -62,6 +64,7 @@ sysdb_getservbyport(TALLOC_CTX *mem_ctx,
errno_t
sysdb_enumservent(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
struct ldb_result **_res);
errno_t
@@ -81,19 +84,32 @@ sysdb_svc_dn(struct sysdb_ctx *sysdb, TALLOC_CTX *mem_ctx,
const char *domain, const char *name);
errno_t
+sysdb_svc_add(TALLOC_CTX *mem_ctx,
+ struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
+ const char *primary_name,
+ int port,
+ const char **aliases,
+ const char **protocols,
+ struct ldb_dn **dn);
+
+errno_t
sysdb_svc_delete(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *name,
int port,
const char *proto);
errno_t
sysdb_set_service_attr(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *name,
struct sysdb_attrs *attrs,
int mod_op);
errno_t sysdb_search_services(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *sub_filter,
const char **attrs,
size_t *msgs_count,
diff --git a/src/providers/ldap/ldap_id_services.c b/src/providers/ldap/ldap_id_services.c
index b0291351..1a2a7b6b 100644
--- a/src/providers/ldap/ldap_id_services.c
+++ b/src/providers/ldap/ldap_id_services.c
@@ -243,7 +243,7 @@ services_get_done(struct tevent_req *subreq)
/* Ensure that this entry is removed from the sysdb */
switch(state->filter_type) {
case BE_FILTER_NAME:
- ret = sysdb_svc_delete(state->sysdb, state->name,
+ ret = sysdb_svc_delete(state->sysdb, state->domain, state->name,
0, state->protocol);
if (ret != EOK) {
tevent_req_error(req, ret);
@@ -258,7 +258,7 @@ services_get_done(struct tevent_req *subreq)
return;
}
- ret = sysdb_svc_delete(state->sysdb, NULL,
+ ret = sysdb_svc_delete(state->sysdb, state->domain, NULL,
port, state->protocol);
if (ret != EOK) {
tevent_req_error(req, ret);
diff --git a/src/providers/ldap/sdap_reinit.c b/src/providers/ldap/sdap_reinit.c
index dd49c7b8..3fba9360 100644
--- a/src/providers/ldap/sdap_reinit.c
+++ b/src/providers/ldap/sdap_reinit.c
@@ -163,7 +163,8 @@ static errno_t sdap_reinit_clear_usn(struct sysdb_ctx *sysdb,
msgs_num = 0;
/* reset services' usn */
- ret = sysdb_search_services(tmp_ctx, sysdb, "", attrs, &msgs_num, &msgs);
+ ret = sysdb_search_services(tmp_ctx, sysdb, domain,
+ "", attrs, &msgs_num, &msgs);
sdap_delete_msgs_usn(sysdb, msgs, msgs_num);
talloc_zfree(msgs);
msgs_num = 0;
@@ -290,7 +291,7 @@ static errno_t sdap_reinit_delete_records(struct sysdb_ctx *sysdb,
msgs_num = 0;
/* purge untouched services */
- ret = sysdb_search_services(tmp_ctx, sysdb, "(!("SYSDB_USN"=*))",
+ ret = sysdb_search_services(tmp_ctx, sysdb, domain, "(!("SYSDB_USN"=*))",
attrs, &msgs_num, &msgs);
sdap_delete_msgs_dn(sysdb, msgs, msgs_num);
talloc_zfree(msgs);
diff --git a/src/providers/proxy/proxy_services.c b/src/providers/proxy/proxy_services.c
index 3b79f81b..e9f3b3f5 100644
--- a/src/providers/proxy/proxy_services.c
+++ b/src/providers/proxy/proxy_services.c
@@ -117,7 +117,7 @@ get_serv_byname(struct proxy_id_ctx *ctx,
if (status == NSS_STATUS_NOTFOUND) {
/* Make sure we remove it from the cache */
- ret = sysdb_svc_delete(sysdb, name, 0, protocol);
+ ret = sysdb_svc_delete(sysdb, dom, name, 0, protocol);
} else {
/* Results found. Save them into the cache */
@@ -171,7 +171,7 @@ get_serv_byport(struct proxy_id_ctx *ctx,
if (status == NSS_STATUS_NOTFOUND) {
/* Make sure we remove it from the cache */
- ret = sysdb_svc_delete(sysdb, NULL, port, protocol);
+ ret = sysdb_svc_delete(sysdb, dom, NULL, port, protocol);
} else {
/* Results found. Save them into the cache */
ret = proxy_save_service(sysdb, dom, result,
diff --git a/src/responder/nss/nsssrv_services.c b/src/responder/nss/nsssrv_services.c
index e56ad93a..dd12fa41 100644
--- a/src/responder/nss/nsssrv_services.c
+++ b/src/responder/nss/nsssrv_services.c
@@ -211,7 +211,7 @@ getserv_send(TALLOC_CTX *mem_ctx,
SVC_PROTO_CASED ? SVC_PROTO_CASED : "<ANY>",
dom->name));
- ret = sysdb_getservbyname(state, sysdb,
+ ret = sysdb_getservbyname(state, sysdb, dom,
SVC_NAME_CASED,
SVC_PROTO_CASED,
&state->res);
@@ -252,7 +252,7 @@ getserv_send(TALLOC_CTX *mem_ctx,
SVC_PROTO_CASED ? SVC_PROTO_CASED : "<ANY>",
dom->name));
- ret = sysdb_getservbyport(state, sysdb, port,
+ ret = sysdb_getservbyport(state, sysdb, dom, port,
SVC_PROTO_CASED,
&state->res);
}
@@ -495,7 +495,7 @@ static void lookup_service_done(struct tevent_req *subreq)
SVC_PROTO_CASED ? SVC_PROTO_CASED : "<ANY>",
dom->name));
- ret = sysdb_getservbyname(state, sysdb,
+ ret = sysdb_getservbyname(state, sysdb, dom,
SVC_NAME_CASED,
SVC_PROTO_CASED,
&state->res);
@@ -506,7 +506,7 @@ static void lookup_service_done(struct tevent_req *subreq)
SVC_PROTO_CASED ? SVC_PROTO_CASED : "<ANY>",
dom->name));
- ret = sysdb_getservbyport(state, sysdb,
+ ret = sysdb_getservbyport(state, sysdb, dom,
state->port,
SVC_PROTO_CASED,
&state->res);
@@ -1384,7 +1384,7 @@ lookup_servent_send(TALLOC_CTX *mem_ctx,
goto immediate;
}
- ret = sysdb_enumservent(state, sysdb, &state->res);
+ ret = sysdb_enumservent(state, sysdb, dom, &state->res);
/* Whatever the result, we're done, so report it */
goto immediate;
}
@@ -1446,7 +1446,7 @@ lookup_servent_done(struct tevent_req *subreq)
goto done;
}
- ret = sysdb_enumservent(state, sysdb, &state->res);
+ ret = sysdb_enumservent(state, sysdb, state->dom, &state->res);
/* Whatever the result, we're done, so report it */
done:
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index 7735316b..f68ef249 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -3869,14 +3869,15 @@ void services_check_match(struct sysdb_test_ctx *test_ctx,
if (by_name) {
/* Look up the service by name */
- ret = sysdb_getservbyname(test_ctx, test_ctx->sysdb, primary_name,
+ ret = sysdb_getservbyname(test_ctx, test_ctx->sysdb,
+ test_ctx->domain, primary_name,
NULL, &res);
fail_if(ret != EOK, "sysdb_getservbyname error [%s]\n",
strerror(ret));
} else {
/* Look up the newly-added service by port */
ret = sysdb_getservbyport(test_ctx, test_ctx->sysdb,
- port, NULL, &res);
+ test_ctx->domain, port, NULL, &res);
fail_if(ret != EOK, "sysdb_getservbyport error [%s]\n",
strerror(ret));
}
@@ -3927,15 +3928,6 @@ void services_check_match(struct sysdb_test_ctx *test_ctx,
services_check_match(test_ctx, false, primary_name, port, aliases, protocols); \
} while(0);
-errno_t
-sysdb_svc_add(TALLOC_CTX *mem_ctx,
- struct sysdb_ctx *sysdb,
- const char *primary_name,
- int port,
- const char **aliases,
- const char **protocols,
- struct ldb_dn **dn);
-
START_TEST(test_sysdb_add_services)
{
errno_t ret;
@@ -3977,7 +3969,7 @@ START_TEST(test_sysdb_add_services)
ret = sysdb_transaction_start(test_ctx->sysdb);
fail_if(ret != EOK);
- ret = sysdb_svc_add(NULL, test_ctx->sysdb,
+ ret = sysdb_svc_add(NULL, test_ctx->sysdb, test_ctx->domain,
primary_name, port,
aliases, protocols,
NULL);
@@ -4002,7 +3994,8 @@ START_TEST(test_sysdb_add_services)
* doesn't like adding and deleting the same entry in a
* single transaction.
*/
- ret = sysdb_svc_delete(test_ctx->sysdb, primary_name, 0, NULL);
+ ret = sysdb_svc_delete(test_ctx->sysdb, test_ctx->domain,
+ primary_name, 0, NULL);
fail_if(ret != EOK);
talloc_free(test_ctx);
@@ -4118,7 +4111,8 @@ START_TEST(test_sysdb_store_services)
* doesn't like adding and deleting the same entry in a
* single transaction.
*/
- ret = sysdb_svc_delete(test_ctx->sysdb, NULL, altport, NULL);
+ ret = sysdb_svc_delete(test_ctx->sysdb, test_ctx->domain,
+ NULL, altport, NULL);
fail_if(ret != EOK);
talloc_free(test_ctx);
@@ -4169,7 +4163,7 @@ START_TEST(test_sysdb_svc_remove_alias)
ret = sysdb_transaction_start(test_ctx->sysdb);
fail_if(ret != EOK);
- ret = sysdb_svc_add(NULL, test_ctx->sysdb,
+ ret = sysdb_svc_add(NULL, test_ctx->sysdb, test_ctx->domain,
primary_name, port,
aliases, protocols,
NULL);
diff --git a/src/tools/sss_cache.c b/src/tools/sss_cache.c
index afdff791..15dcf7e1 100644
--- a/src/tools/sss_cache.c
+++ b/src/tools/sss_cache.c
@@ -307,7 +307,8 @@ static bool invalidate_entries(TALLOC_CTX *ctx,
break;
case TYPE_SERVICE:
type_string = "service";
- ret = sysdb_search_services(ctx, sysdb, filter, attrs, &msg_count, &msgs);
+ ret = sysdb_search_services(ctx, sysdb, dinfo,
+ filter, attrs, &msg_count, &msgs);
break;
case TYPE_AUTOFSMAP:
type_string = "autofs map";
@@ -378,7 +379,7 @@ static errno_t invalidate_entry(TALLOC_CTX *ctx, struct sysdb_ctx *sysdb,
sys_attrs, SYSDB_MOD_REP);
break;
case TYPE_SERVICE:
- ret = sysdb_set_service_attr(sysdb, name,
+ ret = sysdb_set_service_attr(sysdb, domain, name,
sys_attrs, SYSDB_MOD_REP);
break;
case TYPE_AUTOFSMAP: