|
|
ced1f5 |
From d75b796151973a5d94a79f5577c15cda6eecb5ee Mon Sep 17 00:00:00 2001
|
|
|
ced1f5 |
From: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
ced1f5 |
Date: Thu, 19 Oct 2017 17:18:15 +0200
|
|
|
ced1f5 |
Subject: [PATCH 08/21] SYSDB: Prevent users and groups ID collision in MPG
|
|
|
ced1f5 |
domains except for id_provider=local
|
|
|
ced1f5 |
MIME-Version: 1.0
|
|
|
ced1f5 |
Content-Type: text/plain; charset=UTF-8
|
|
|
ced1f5 |
Content-Transfer-Encoding: 8bit
|
|
|
ced1f5 |
|
|
|
ced1f5 |
This commit makes the check when adding an object in a MPG domain
|
|
|
ced1f5 |
stricter in the sense that not only same names are allowed in a MPG
|
|
|
ced1f5 |
domain, but also the same groups are not allowed either.
|
|
|
ced1f5 |
|
|
|
ced1f5 |
This commit is a backwards-incompatible change, but one that is needed,
|
|
|
ced1f5 |
otherwise requesting the duplicate group first and then requesting the
|
|
|
ced1f5 |
user entry would yield two object when searching by GID.
|
|
|
ced1f5 |
|
|
|
ced1f5 |
In order to keep backwards-compatibility, this uniqueness is NOT
|
|
|
ced1f5 |
enforced with id_provider=local. This constraint can be removed in
|
|
|
ced1f5 |
the future (or the local provider can be dropped altogether)
|
|
|
ced1f5 |
|
|
|
ced1f5 |
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
|
|
|
ced1f5 |
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
|
|
|
ced1f5 |
(cherry picked from commit ac962e2b286988d8666b3b81bf8b55b1705b9ac0)
|
|
|
ced1f5 |
---
|
|
|
ced1f5 |
src/db/sysdb_ops.c | 41 ++++++++++++++++++++++++++++++++++++++---
|
|
|
ced1f5 |
1 file changed, 38 insertions(+), 3 deletions(-)
|
|
|
ced1f5 |
|
|
|
ced1f5 |
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
|
|
|
ced1f5 |
index 0e39a629a5823ff49ed02ec4c08a21b66119f06f..2f8e36c6c9a2c2cefe4af5fb78957763304d989a 100644
|
|
|
ced1f5 |
--- a/src/db/sysdb_ops.c
|
|
|
ced1f5 |
+++ b/src/db/sysdb_ops.c
|
|
|
ced1f5 |
@@ -1960,16 +1960,34 @@ int sysdb_add_user(struct sss_domain_info *domain,
|
|
|
ced1f5 |
}
|
|
|
ced1f5 |
|
|
|
ced1f5 |
if (domain->mpg) {
|
|
|
ced1f5 |
- /* In MPG domains you can't have groups with the same name as users,
|
|
|
ced1f5 |
- * search if a group with the same name exists.
|
|
|
ced1f5 |
+ /* In MPG domains you can't have groups with the same name or GID
|
|
|
ced1f5 |
+ * as users, search if a group with the same name exists.
|
|
|
ced1f5 |
* Don't worry about users, if we try to add a user with the same
|
|
|
ced1f5 |
* name the operation will fail */
|
|
|
ced1f5 |
|
|
|
ced1f5 |
ret = sysdb_search_group_by_name(tmp_ctx, domain, name, NULL, &msg;;
|
|
|
ced1f5 |
if (ret != ENOENT) {
|
|
|
ced1f5 |
- if (ret == EOK) ret = EEXIST;
|
|
|
ced1f5 |
+ if (ret == EOK) {
|
|
|
ced1f5 |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
ced1f5 |
+ "Group named %s already exists in an MPG domain\n",
|
|
|
ced1f5 |
+ name);
|
|
|
ced1f5 |
+ ret = EEXIST;
|
|
|
ced1f5 |
+ }
|
|
|
ced1f5 |
goto done;
|
|
|
ced1f5 |
}
|
|
|
ced1f5 |
+
|
|
|
ced1f5 |
+ if (strcasecmp(domain->provider, "local") != 0) {
|
|
|
ced1f5 |
+ ret = sysdb_search_group_by_gid(tmp_ctx, domain, uid, NULL, &msg;;
|
|
|
ced1f5 |
+ if (ret != ENOENT) {
|
|
|
ced1f5 |
+ if (ret == EOK) {
|
|
|
ced1f5 |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
ced1f5 |
+ "Group with GID [%"SPRIgid"] already exists in an "
|
|
|
ced1f5 |
+ "MPG domain\n", gid);
|
|
|
ced1f5 |
+ ret = EEXIST;
|
|
|
ced1f5 |
+ }
|
|
|
ced1f5 |
+ goto done;
|
|
|
ced1f5 |
+ }
|
|
|
ced1f5 |
+ }
|
|
|
ced1f5 |
}
|
|
|
ced1f5 |
|
|
|
ced1f5 |
/* check no other user with the same uid exist */
|
|
|
ced1f5 |
@@ -2177,6 +2195,23 @@ int sysdb_add_group(struct sss_domain_info *domain,
|
|
|
ced1f5 |
}
|
|
|
ced1f5 |
goto done;
|
|
|
ced1f5 |
}
|
|
|
ced1f5 |
+
|
|
|
ced1f5 |
+ if (strcasecmp(domain->provider, "local") != 0) {
|
|
|
ced1f5 |
+ ret = sysdb_search_user_by_uid(tmp_ctx, domain, gid, NULL, &msg;;
|
|
|
ced1f5 |
+ if (ret != ENOENT) {
|
|
|
ced1f5 |
+ if (ret == EOK) {
|
|
|
ced1f5 |
+ DEBUG(SSSDBG_TRACE_LIBS,
|
|
|
ced1f5 |
+ "User with the same UID exists in MPG domain: "
|
|
|
ced1f5 |
+ "[%"SPRIgid"].\n", gid);
|
|
|
ced1f5 |
+ ret = EEXIST;
|
|
|
ced1f5 |
+ } else {
|
|
|
ced1f5 |
+ DEBUG(SSSDBG_TRACE_LIBS,
|
|
|
ced1f5 |
+ "sysdb_search_user_by_uid failed for gid: "
|
|
|
ced1f5 |
+ "[%"SPRIgid"].\n", gid);
|
|
|
ced1f5 |
+ }
|
|
|
ced1f5 |
+ goto done;
|
|
|
ced1f5 |
+ }
|
|
|
ced1f5 |
+ }
|
|
|
ced1f5 |
}
|
|
|
ced1f5 |
|
|
|
ced1f5 |
/* check no other groups with the same gid exist */
|
|
|
ced1f5 |
--
|
|
|
ced1f5 |
2.13.5
|
|
|
ced1f5 |
|