summaryrefslogtreecommitdiffstats
path: root/server/tools
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2009-03-09 20:34:44 -0400
committerSimo Sorce <ssorce@redhat.com>2009-03-09 20:34:44 -0400
commit92bb11b3570c0ce1de84824d9697fa45422feb0b (patch)
tree3834cc0b59f463ce92ebc963c419e6352b7991fc /server/tools
parent5ea221d5325a2b60ec872a3864953178c8b593a0 (diff)
downloadsssd-92bb11b3570c0ce1de84824d9697fa45422feb0b.tar.gz
sssd-92bb11b3570c0ce1de84824d9697fa45422feb0b.tar.xz
sssd-92bb11b3570c0ce1de84824d9697fa45422feb0b.zip
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.
Diffstat (limited to 'server/tools')
-rw-r--r--server/tools/sss_groupadd.c8
-rw-r--r--server/tools/sss_useradd.c8
-rw-r--r--server/tools/tools_util.c98
-rw-r--r--server/tools/tools_util.h2
4 files changed, 0 insertions, 116 deletions
diff --git a/server/tools/sss_groupadd.c b/server/tools/sss_groupadd.c
index e36e220fe..5363dbbaf 100644
--- a/server/tools/sss_groupadd.c
+++ b/server/tools/sss_groupadd.c
@@ -135,14 +135,6 @@ int main(int argc, const char **argv)
goto fini;
}
- /* Check MPG constraints */
- ret = check_group_name_unique(ctx, group_ctx->groupname);
- if(ret != EOK) {
- DEBUG(1, ("Could not add group - name not unique\n"));
- ret = EXIT_FAILURE;
- goto fini;
- }
-
/* add_group */
ret = sysdb_transaction(ctx, ctx->sysdb, add_group, group_ctx);
if(ret != EOK) {
diff --git a/server/tools/sss_useradd.c b/server/tools/sss_useradd.c
index 710ed207f..7bad83786 100644
--- a/server/tools/sss_useradd.c
+++ b/server/tools/sss_useradd.c
@@ -338,14 +338,6 @@ int main(int argc, const char **argv)
goto fini;
}
- /* Check MPG constraints */
- ret = check_user_name_unique(ctx, user_ctx->username);
- if (ret != EOK) {
- DEBUG(0, ("Could not add user - name not unique\n"));
- ret = EXIT_FAILURE;
- goto fini;
- }
-
/* useradd */
ret = sysdb_transaction(ctx, ctx->sysdb, add_user, user_ctx);
if (ret != EOK) {
diff --git a/server/tools/tools_util.c b/server/tools/tools_util.c
index daf9b41f4..a3669001f 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;
diff --git a/server/tools/tools_util.h b/server/tools/tools_util.h
index d8edd4930..4a32e9c73 100644
--- a/server/tools/tools_util.h
+++ b/server/tools/tools_util.h
@@ -12,8 +12,6 @@ struct tools_ctx {
struct btreemap *domains;
};
-int check_user_name_unique(struct tools_ctx *ctx, const char *name);
-int check_group_name_unique(struct tools_ctx *ctx, const char *name);
int setup_db(struct tools_ctx **ctx);
void usage(poptContext pc, const char *error);