From 92bb11b3570c0ce1de84824d9697fa45422feb0b Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 9 Mar 2009 20:34:44 -0400 Subject: Move MPG checks within sysdb. This allows to perform checks and modifications in one transaction. Uses configuration stored in confdb to determins if a domain uses MPGs. --- server/tools/tools_util.c | 98 ----------------------------------------------- 1 file changed, 98 deletions(-) (limited to 'server/tools/tools_util.c') diff --git a/server/tools/tools_util.c b/server/tools/tools_util.c index daf9b41f..a3669001 100644 --- a/server/tools/tools_util.c +++ b/server/tools/tools_util.c @@ -28,104 +28,6 @@ #include "db/sysdb.h" #include "tools/tools_util.h" -/* Even in LOCAL database, we must enforce MPG. That means enforcing the following rules: - * - * 1. Users and groups must share the same name space. There can never be - * a real group that has the same name of a real user. - * 2. Users and Groups must share the same ID space a group can never have - * a gidNumber that is numerically equal to a uidNumber Otherwise the - * user MPG will conflict with said group. - */ - -struct ucheck { - bool done; - bool dup; - int error; -}; - -void check_unique_callback(void *ptr, int error, struct ldb_result *res) -{ - struct ucheck *data = talloc_get_type(ptr, struct ucheck); - - data->done = true; - - if (error) { - data->error = error; - } - - if (res->count != 0) { - data->dup = true; - } -} - -int check_user_name_unique(struct tools_ctx *ctx, const char *name) -{ - struct ucheck *data; - int ret = EOK; - - data = talloc_zero(NULL, struct ucheck); - if (!data) return ENOMEM; - - ret = sysdb_getgrnam(data, ctx->sysdb, - "LOCAL", name, false, - check_unique_callback, data); - if (ret != EOK) { - DEBUG(1, ("sysdb_getgrnam failed: %d\n", ret)); - goto done; - } - - while (!data->done) { - tevent_loop_once(ctx->ev); - } - - if (data->error) { - ret = data->error; - goto done; - } - - if (data->dup) { - ret = EEXIST; - } - -done: - talloc_free(data); - return ret; -} - -int check_group_name_unique(struct tools_ctx *ctx, const char *name) -{ - struct ucheck *data; - int ret; - - data = talloc_zero(NULL, struct ucheck); - if (!data) return ENOMEM; - - ret = sysdb_getpwnam(data, ctx->sysdb, - "LOCAL", name, false, - check_unique_callback, data); - if (ret != EOK) { - DEBUG(1, ("sysdb_getgrnam failed: %d\n", ret)); - goto done; - } - - while (!data->done) { - tevent_loop_once(ctx->ev); - } - - if (data->error) { - ret = data->error; - goto done; - } - - if (data->dup) { - ret = EEXIST; - } - -done: - talloc_free(data); - return ret; -} - int setup_db(struct tools_ctx **tools_ctx) { TALLOC_CTX *tmp_ctx; -- cgit