summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/db/sysdb.h24
-rw-r--r--server/db/sysdb_search.c68
-rw-r--r--server/infopipe/infopipe_users.c6
-rw-r--r--server/responder/nss/nsssrv_cmd.c42
-rw-r--r--server/responder/pam/pam_LOCAL_domain.c6
-rw-r--r--server/tools/sss_useradd.c9
6 files changed, 60 insertions, 95 deletions
diff --git a/server/db/sysdb.h b/server/db/sysdb.h
index e7da90b0..480102d9 100644
--- a/server/db/sysdb.h
+++ b/server/db/sysdb.h
@@ -188,58 +188,50 @@ int sysdb_init(TALLOC_CTX *mem_ctx,
* therefore they cannot be called within a transaction */
int sysdb_getpwnam(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
- const char *domain,
+ struct sss_domain_info *domain,
const char *name,
- bool legacy,
sysdb_callback_t fn, void *ptr);
int sysdb_getpwuid(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
- const char *domain,
+ struct sss_domain_info *domain,
uid_t uid,
- bool legacy,
sysdb_callback_t fn, void *ptr);
int sysdb_enumpwent(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
- const char *domain,
- bool legacy,
+ struct sss_domain_info *domain,
const char *expression,
sysdb_callback_t fn, void *ptr);
int sysdb_getgrnam(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
- const char *domain,
+ struct sss_domain_info *domain,
const char *name,
- bool legacy,
sysdb_callback_t fn, void *ptr);
int sysdb_getgrgid(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
- const char *domain,
+ struct sss_domain_info *domain,
gid_t gid,
- bool legacy,
sysdb_callback_t fn, void *ptr);
int sysdb_enumgrent(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
- const char *domain,
- bool legacy,
+ struct sss_domain_info *domain,
sysdb_callback_t fn, void *ptr);
int sysdb_initgroups(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
- const char *domain,
+ struct sss_domain_info *domain,
const char *name,
- bool legacy,
sysdb_callback_t fn, void *ptr);
int sysdb_get_user_attr(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
- const char *domain,
+ struct sss_domain_info *domain,
const char *name,
const char **attributes,
- bool legacy,
sysdb_callback_t fn, void *ptr);
diff --git a/server/db/sysdb_search.c b/server/db/sysdb_search.c
index 24ee5cf1..15a7d457 100644
--- a/server/db/sysdb_search.c
+++ b/server/db/sysdb_search.c
@@ -32,9 +32,9 @@ struct sysdb_search_ctx {
struct sysdb_ctx *ctx;
struct sysdb_req *req;
+ struct sss_domain_info *domain;
+
const char *expression;
- const char *domain;
- bool legacy;
sysdb_callback_t callback;
void *ptr;
@@ -49,8 +49,7 @@ struct sysdb_search_ctx {
};
static struct sysdb_search_ctx *init_src_ctx(TALLOC_CTX *mem_ctx,
- const char *domain,
- bool legacy,
+ struct sss_domain_info *domain,
struct sysdb_ctx *ctx,
sysdb_callback_t fn,
void *ptr)
@@ -69,12 +68,7 @@ static struct sysdb_search_ctx *init_src_ctx(TALLOC_CTX *mem_ctx,
talloc_free(sctx);
return NULL;
}
- sctx->domain = talloc_strdup(sctx, domain);
- if (!sctx->domain) {
- talloc_free(sctx);
- return NULL;
- }
- sctx->legacy = legacy;
+ sctx->domain = domain;
return sctx;
}
@@ -179,7 +173,7 @@ static void user_search(struct sysdb_req *sysreq, void *ptr)
sctx->req = sysreq;
base_dn = ldb_dn_new_fmt(sctx, sctx->ctx->ldb,
- SYSDB_TMPL_USER_BASE, sctx->domain);
+ SYSDB_TMPL_USER_BASE, sctx->domain->name);
if (!base_dn) {
return request_error(sctx, ENOMEM);
}
@@ -201,9 +195,8 @@ static void user_search(struct sysdb_req *sysreq, void *ptr)
int sysdb_getpwnam(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
- const char *domain,
+ struct sss_domain_info *domain,
const char *name,
- bool legacy,
sysdb_callback_t fn, void *ptr)
{
static const char *attrs[] = SYSDB_PW_ATTRS;
@@ -213,7 +206,7 @@ int sysdb_getpwnam(TALLOC_CTX *mem_ctx,
return EINVAL;
}
- sctx = init_src_ctx(mem_ctx, domain, legacy, ctx, fn, ptr);
+ sctx = init_src_ctx(mem_ctx, domain, ctx, fn, ptr);
if (!sctx) {
return ENOMEM;
}
@@ -231,9 +224,8 @@ int sysdb_getpwnam(TALLOC_CTX *mem_ctx,
int sysdb_getpwuid(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
- const char *domain,
+ struct sss_domain_info *domain,
uid_t uid,
- bool legacy,
sysdb_callback_t fn, void *ptr)
{
static const char *attrs[] = SYSDB_PW_ATTRS;
@@ -244,7 +236,7 @@ int sysdb_getpwuid(TALLOC_CTX *mem_ctx,
return EINVAL;
}
- sctx = init_src_ctx(mem_ctx, domain, legacy, ctx, fn, ptr);
+ sctx = init_src_ctx(mem_ctx, domain, ctx, fn, ptr);
if (!sctx) {
return ENOMEM;
}
@@ -262,8 +254,7 @@ int sysdb_getpwuid(TALLOC_CTX *mem_ctx,
int sysdb_enumpwent(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
- const char *domain,
- bool legacy,
+ struct sss_domain_info *domain,
const char *expression,
sysdb_callback_t fn, void *ptr)
{
@@ -274,7 +265,7 @@ int sysdb_enumpwent(TALLOC_CTX *mem_ctx,
return EINVAL;
}
- sctx = init_src_ctx(mem_ctx, domain, legacy, ctx, fn, ptr);
+ sctx = init_src_ctx(mem_ctx, domain, ctx, fn, ptr);
if (!sctx) {
return ENOMEM;
}
@@ -336,7 +327,7 @@ static void get_members(struct sysdb_search_ctx *sctx)
}
dn = ldb_dn_new_fmt(sctx, sctx->ctx->ldb,
- SYSDB_TMPL_USER_BASE, sctx->domain);
+ SYSDB_TMPL_USER_BASE, sctx->domain->name);
if (!dn) {
return request_ldberror(sctx, LDB_ERR_OPERATIONS_ERROR);
}
@@ -458,14 +449,14 @@ static void grp_search(struct sysdb_req *sysreq, void *ptr)
sctx = talloc_get_type(ptr, struct sysdb_search_ctx);
sctx->req = sysreq;
- if (sctx->legacy) {
+ if (sctx->domain->legacy) {
callback = get_gen_callback;
} else {
callback = get_grp_callback;
}
base_dn = ldb_dn_new_fmt(sctx, sctx->ctx->ldb,
- SYSDB_TMPL_GROUP_BASE, sctx->domain);
+ SYSDB_TMPL_GROUP_BASE, sctx->domain->name);
if (!base_dn) {
return request_error(sctx, ENOMEM);
}
@@ -487,9 +478,8 @@ static void grp_search(struct sysdb_req *sysreq, void *ptr)
int sysdb_getgrnam(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
- const char *domain,
+ struct sss_domain_info *domain,
const char *name,
- bool legacy,
sysdb_callback_t fn, void *ptr)
{
struct sysdb_search_ctx *sctx;
@@ -498,7 +488,7 @@ int sysdb_getgrnam(TALLOC_CTX *mem_ctx,
return EINVAL;
}
- sctx = init_src_ctx(mem_ctx, domain, legacy, ctx, fn, ptr);
+ sctx = init_src_ctx(mem_ctx, domain, ctx, fn, ptr);
if (!sctx) {
return ENOMEM;
}
@@ -514,9 +504,8 @@ int sysdb_getgrnam(TALLOC_CTX *mem_ctx,
int sysdb_getgrgid(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
- const char *domain,
+ struct sss_domain_info *domain,
gid_t gid,
- bool legacy,
sysdb_callback_t fn, void *ptr)
{
struct sysdb_search_ctx *sctx;
@@ -526,7 +515,7 @@ int sysdb_getgrgid(TALLOC_CTX *mem_ctx,
return EINVAL;
}
- sctx = init_src_ctx(mem_ctx, domain, legacy, ctx, fn, ptr);
+ sctx = init_src_ctx(mem_ctx, domain, ctx, fn, ptr);
if (!sctx) {
return ENOMEM;
}
@@ -542,8 +531,7 @@ int sysdb_getgrgid(TALLOC_CTX *mem_ctx,
int sysdb_enumgrent(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
- const char *domain,
- bool legacy,
+ struct sss_domain_info *domain,
sysdb_callback_t fn, void *ptr)
{
struct sysdb_search_ctx *sctx;
@@ -552,7 +540,7 @@ int sysdb_enumgrent(TALLOC_CTX *mem_ctx,
return EINVAL;
}
- sctx = init_src_ctx(mem_ctx, domain, legacy, ctx, fn, ptr);
+ sctx = init_src_ctx(mem_ctx, domain, ctx, fn, ptr);
if (!sctx) {
return ENOMEM;
}
@@ -591,7 +579,7 @@ static void initgr_mem_legacy(struct sysdb_search_ctx *sctx)
}
base_dn = ldb_dn_new_fmt(sctx, ctx->ldb,
- SYSDB_TMPL_GROUP_BASE, sctx->domain);
+ SYSDB_TMPL_GROUP_BASE, sctx->domain->name);
if (!base_dn) {
return request_ldberror(sctx, LDB_ERR_OPERATIONS_ERROR);
}
@@ -683,14 +671,14 @@ static void initgr_search(struct sysdb_req *sysreq, void *ptr)
sctx = talloc_get_type(ptr, struct sysdb_search_ctx);
sctx->req = sysreq;
- if (sctx->legacy) {
+ if (sctx->domain->legacy) {
sctx->gen_aux_fn = initgr_mem_legacy;
} else {
sctx->gen_aux_fn = initgr_mem_search;
}
base_dn = ldb_dn_new_fmt(sctx, sctx->ctx->ldb,
- SYSDB_TMPL_USER_BASE, sctx->domain);
+ SYSDB_TMPL_USER_BASE, sctx->domain->name);
if (!base_dn) {
return request_error(sctx, ENOMEM);
}
@@ -712,9 +700,8 @@ static void initgr_search(struct sysdb_req *sysreq, void *ptr)
int sysdb_initgroups(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
- const char *domain,
+ struct sss_domain_info *domain,
const char *name,
- bool legacy,
sysdb_callback_t fn, void *ptr)
{
struct sysdb_search_ctx *sctx;
@@ -723,7 +710,7 @@ int sysdb_initgroups(TALLOC_CTX *mem_ctx,
return EINVAL;
}
- sctx = init_src_ctx(mem_ctx, domain, legacy, ctx, fn, ptr);
+ sctx = init_src_ctx(mem_ctx, domain, ctx, fn, ptr);
if (!sctx) {
return ENOMEM;
}
@@ -739,10 +726,9 @@ int sysdb_initgroups(TALLOC_CTX *mem_ctx,
int sysdb_get_user_attr(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
- const char *domain,
+ struct sss_domain_info *domain,
const char *name,
const char **attributes,
- bool legacy,
sysdb_callback_t fn, void *ptr)
{
struct sysdb_search_ctx *sctx;
@@ -751,7 +737,7 @@ int sysdb_get_user_attr(TALLOC_CTX *mem_ctx,
return EINVAL;
}
- sctx = init_src_ctx(mem_ctx, domain, legacy, ctx, fn, ptr);
+ sctx = init_src_ctx(mem_ctx, domain, ctx, fn, ptr);
if (!sctx) {
return ENOMEM;
}
diff --git a/server/infopipe/infopipe_users.c b/server/infopipe/infopipe_users.c
index 29e87a9e..3dc03fe4 100644
--- a/server/infopipe/infopipe_users.c
+++ b/server/infopipe/infopipe_users.c
@@ -162,8 +162,7 @@ int infp_users_get_cached(DBusMessage *message, struct sbus_conn_ctx *sconn)
infp_getcached_req->min_last_login);
ret = sysdb_enumpwent(infp_getcached_req,
infp_getcached_req->infp_req->infp->sysdb,
- infp_getcached_req->infp_req->domain->name,
- infp_getcached_req->infp_req->domain->legacy,
+ infp_getcached_req->infp_req->domain,
search_expression,
infp_users_get_cached_callback, infp_getcached_req);
if(ret != EOK) {
@@ -1097,10 +1096,9 @@ static int infp_get_attr_lookup(struct infp_getattr_ctx *infp_getattr_req)
/* Call into the sysdb for the requested attributes */
ret = sysdb_get_user_attr(infp_getattr_req,
infp_getattr_req->infp_req->infp->sysdb,
- infp_getattr_req->infp_req->domain->name,
+ infp_getattr_req->infp_req->domain,
infp_getattr_req->usernames[infp_getattr_req->index],
(const char **)attributes,
- infp_getattr_req->infp_req->domain->legacy,
infp_get_attr_lookup_callback, infp_getattr_req);
return EOK;
diff --git a/server/responder/nss/nsssrv_cmd.c b/server/responder/nss/nsssrv_cmd.c
index 8b04f813..e9fbda63 100644
--- a/server/responder/nss/nsssrv_cmd.c
+++ b/server/responder/nss/nsssrv_cmd.c
@@ -395,8 +395,7 @@ static void nss_cmd_getpwnam_dp_callback(uint16_t err_maj, uint32_t err_min,
}
ret = sysdb_getpwnam(cmdctx, cctx->nctx->sysdb,
- dctx->domain->name, cmdctx->name,
- dctx->domain->legacy,
+ dctx->domain, cmdctx->name,
nss_cmd_getpwnam_callback, dctx);
if (ret != EOK) {
DEBUG(1, ("Failed to make request to our cache!\n"));
@@ -446,8 +445,7 @@ static int nss_cmd_getpwnam(struct cli_ctx *cctx)
cmdctx->name, dctx->domain->name));
ret = sysdb_getpwnam(cmdctx, cctx->nctx->sysdb,
- dctx->domain->name, cmdctx->name,
- dctx->domain->legacy,
+ dctx->domain, cmdctx->name,
nss_cmd_getpwnam_callback, dctx);
if (ret != EOK) {
@@ -622,8 +620,7 @@ static void nss_cmd_getpwuid_dp_callback(uint16_t err_maj, uint32_t err_min,
}
ret = sysdb_getpwuid(cmdctx, cctx->nctx->sysdb,
- dctx->domain->name, cmdctx->id,
- dctx->domain->legacy,
+ dctx->domain, cmdctx->id,
nss_cmd_getpwuid_callback, dctx);
if (ret != EOK) {
DEBUG(1, ("Failed to make request to our cache!\n"));
@@ -692,8 +689,7 @@ static int nss_cmd_getpwuid(struct cli_ctx *cctx)
cmdctx->id, dctx->domain->name));
ret = sysdb_getpwuid(cmdctx, cctx->nctx->sysdb,
- dctx->domain->name, cmdctx->id,
- dctx->domain->legacy,
+ dctx->domain, cmdctx->id,
nss_cmd_getpwuid_callback, dctx);
if (ret != EOK) {
DEBUG(1, ("Failed to make request to our cache!\n"));
@@ -804,7 +800,7 @@ static void nss_cmd_setpw_dp_callback(uint16_t err_maj, uint32_t err_min,
}
ret = sysdb_enumpwent(cmdctx, cctx->nctx->sysdb,
- dctx->domain->name, dctx->domain->legacy, NULL,
+ dctx->domain, NULL,
nss_cmd_setpwent_callback, dctx);
if (ret != EOK) {
DEBUG(1, ("Failed to make request to our cache!\n"));
@@ -895,8 +891,7 @@ static int nss_cmd_setpwent_ext(struct cli_ctx *cctx, bool immediate)
NULL, 0);
} else {
ret = sysdb_enumpwent(dctx, cctx->nctx->sysdb,
- dctx->domain->name,
- dctx->domain->legacy, NULL,
+ dctx->domain, NULL,
nss_cmd_setpwent_callback, dctx);
}
if (ret != EOK) {
@@ -1357,8 +1352,7 @@ static void nss_cmd_getgrnam_dp_callback(uint16_t err_maj, uint32_t err_min,
}
ret = sysdb_getgrnam(cmdctx, cctx->nctx->sysdb,
- dctx->domain->name, cmdctx->name,
- dctx->domain->legacy,
+ dctx->domain, cmdctx->name,
nss_cmd_getgrnam_callback, dctx);
if (ret != EOK) {
DEBUG(1, ("Failed to make request to our cache!\n"));
@@ -1408,8 +1402,7 @@ static int nss_cmd_getgrnam(struct cli_ctx *cctx)
cmdctx->name, dctx->domain->name));
ret = sysdb_getgrnam(cmdctx, cctx->nctx->sysdb,
- dctx->domain->name, cmdctx->name,
- dctx->domain->legacy,
+ dctx->domain, cmdctx->name,
nss_cmd_getgrnam_callback, dctx);
if (ret != EOK) {
DEBUG(1, ("Failed to make request to our cache!\n"));
@@ -1568,8 +1561,7 @@ static void nss_cmd_getgrgid_dp_callback(uint16_t err_maj, uint32_t err_min,
}
ret = sysdb_getgrgid(cmdctx, cctx->nctx->sysdb,
- dctx->domain->name, cmdctx->id,
- dctx->domain->legacy,
+ dctx->domain, cmdctx->id,
nss_cmd_getgrgid_callback, dctx);
if (ret != EOK) {
DEBUG(1, ("Failed to make request to our cache!\n"));
@@ -1635,8 +1627,7 @@ static int nss_cmd_getgrgid(struct cli_ctx *cctx)
cmdctx->id, dctx->domain->name));
ret = sysdb_getgrgid(cmdctx, cctx->nctx->sysdb,
- dctx->domain->name, cmdctx->id,
- dctx->domain->legacy,
+ dctx->domain, cmdctx->id,
nss_cmd_getgrgid_callback, dctx);
if (ret != EOK) {
DEBUG(1, ("Failed to make request to our cache!\n"));
@@ -1748,7 +1739,7 @@ static void nss_cmd_setgr_dp_callback(uint16_t err_maj, uint32_t err_min,
}
ret = sysdb_enumgrent(dctx, cctx->nctx->sysdb,
- dctx->domain->name, dctx->domain->legacy,
+ dctx->domain,
nss_cmd_setgrent_callback, dctx);
if (ret != EOK) {
DEBUG(1, ("Failed to make request to our cache!\n"));
@@ -1839,7 +1830,7 @@ static int nss_cmd_setgrent_ext(struct cli_ctx *cctx, bool immediate)
NULL, 0);
} else {
ret = sysdb_enumgrent(dctx, cctx->nctx->sysdb,
- dctx->domain->name, dctx->domain->legacy,
+ dctx->domain,
nss_cmd_setgrent_callback, dctx);
}
if (ret != EOK) {
@@ -2061,8 +2052,7 @@ static void nss_cmd_getinitgr_callback(uint16_t err_maj, uint32_t err_min,
}
ret = sysdb_initgroups(cmdctx, cctx->nctx->sysdb,
- dctx->domain->name, cmdctx->name,
- dctx->domain->legacy,
+ dctx->domain, cmdctx->name,
nss_cmd_initgr_callback, cmdctx);
if (ret != EOK) {
DEBUG(1, ("Failed to make request to our cache!\n"));
@@ -2094,8 +2084,7 @@ static void nss_cmd_getinitnam_callback(uint16_t err_maj, uint32_t err_min,
}
ret = sysdb_getpwnam(cmdctx, cctx->nctx->sysdb,
- dctx->domain->name, cmdctx->name,
- dctx->domain->legacy,
+ dctx->domain, cmdctx->name,
nss_cmd_getinit_callback, dctx);
if (ret != EOK) {
DEBUG(1, ("Failed to make request to our cache!\n"));
@@ -2254,8 +2243,7 @@ static int nss_cmd_initgroups(struct cli_ctx *cctx)
cmdctx->name, dctx->domain->name));
ret = sysdb_getpwnam(cmdctx, cctx->nctx->sysdb,
- dctx->domain->name, cmdctx->name,
- dctx->domain->legacy,
+ dctx->domain, cmdctx->name,
nss_cmd_getinit_callback, dctx);
if (ret != EOK) {
DEBUG(1, ("Failed to make request to our cache!\n"));
diff --git a/server/responder/pam/pam_LOCAL_domain.c b/server/responder/pam/pam_LOCAL_domain.c
index 90abf63e..ce74884d 100644
--- a/server/responder/pam/pam_LOCAL_domain.c
+++ b/server/responder/pam/pam_LOCAL_domain.c
@@ -418,9 +418,9 @@ int LOCAL_pam_handler(struct cli_ctx *cctx, pam_dp_callback_t callback,
lreq->dbctx = lreq->cctx->nctx->sysdb;
- ret = sysdb_get_user_attr(lreq, lreq->dbctx, lreq->domain_info->name,
- lreq->pd->user, attrs, 0, pam_handler_callback,
- lreq);
+ ret = sysdb_get_user_attr(lreq, lreq->dbctx,
+ lreq->domain_info, lreq->pd->user, attrs,
+ pam_handler_callback, lreq);
if(ret != EOK) {
DEBUG(1, ("sysdb_get_user_attr failed.\n"));
diff --git a/server/tools/sss_useradd.c b/server/tools/sss_useradd.c
index 7bad8378..ba89276f 100644
--- a/server/tools/sss_useradd.c
+++ b/server/tools/sss_useradd.c
@@ -87,8 +87,9 @@ static void get_gid_callback(void *ptr, int error, struct ldb_result *res)
* is given, returns that as integer (rationale: shadow-utils)
* On error, returns -EINVAL
*/
-static int get_gid(struct tools_ctx *ctx, const char *groupname, gid_t *_gid)
+static int get_gid(struct user_add_ctx *user_ctx, const char *groupname)
{
+ struct tools_ctx *ctx = user_ctx->ctx;
struct fetch_group *data = NULL;
char *end_ptr;
gid_t gid;
@@ -103,7 +104,7 @@ static int get_gid(struct tools_ctx *ctx, const char *groupname, gid_t *_gid)
if (!data) return ENOMEM;
ret = sysdb_getgrnam(data, ctx->sysdb,
- "LOCAL", groupname, false,
+ user_ctx->domain, groupname,
get_gid_callback, data);
if (ret != EOK) {
DEBUG(0, ("sysdb_getgrnam failed: %d\n", ret));
@@ -125,7 +126,7 @@ static int get_gid(struct tools_ctx *ctx, const char *groupname, gid_t *_gid)
if (gid == 0) {
ret = ERANGE;
} else {
- *_gid = gid;
+ user_ctx->gid = gid;
}
done:
@@ -288,7 +289,7 @@ int main(int argc, const char **argv)
/* Same as shadow-utils useradd, -g can specify gid or group name */
if (pc_group != NULL) {
- ret = get_gid(ctx, pc_group, &user_ctx->gid);
+ ret = get_gid(user_ctx, pc_group);
if (ret != EOK) {
ret = EXIT_FAILURE;
goto fini;