summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2009-04-27 10:11:14 +0200
committerSimo Sorce <ssorce@redhat.com>2009-05-26 08:55:39 -0400
commit23cb08ee2f1e3b597742281e475350039247d9d8 (patch)
tree9e4264760071223045f6e68f3c50b04ccea7f96f /server
parentd282f5c70c9706a7ee8bbc0e4cf5f165b2e3e2e8 (diff)
downloadsssd-23cb08ee2f1e3b597742281e475350039247d9d8.tar.gz
sssd-23cb08ee2f1e3b597742281e475350039247d9d8.tar.bz2
sssd-23cb08ee2f1e3b597742281e475350039247d9d8.zip
Fix manual UID assignment in sysdb
If it's an MPG domain, set them equal. If it's a non-MPG domain, get the next available GID and use that.
Diffstat (limited to 'server')
-rw-r--r--server/db/sysdb_ops.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/server/db/sysdb_ops.c b/server/db/sysdb_ops.c
index 769d5f61..d8fe83c4 100644
--- a/server/db/sysdb_ops.c
+++ b/server/db/sysdb_ops.c
@@ -864,13 +864,6 @@ int sysdb_add_user(struct sysdb_req *sysreq,
return EINVAL;
}
- if ((uid == 0 || gid == 0) && (uid != 0 || gid != 0)) {
- /* you either set both or neither, we will not guess only one */
- DEBUG(1, ("You have to either specify both uid and gid or neither"
- " (preferred) [passed in uid=%u, gid =%u]\n", uid, gid));
- return EINVAL;
- }
-
if (domain->id_max != 0 && uid != 0 &&
(uid < domain->id_min || uid > domain->id_max)) {
DEBUG(2, ("Supplied uid [%d] is not in the allowed range [%d-%d].\n",
@@ -933,7 +926,13 @@ static void user_check_callback(void *pvt, int error, struct ldb_result *res)
static int user_add_id(struct user_add_ctx *user_ctx)
{
- if (user_ctx->uid == 0 && user_ctx->gid == 0) {
+ if (user_ctx->uid != 0 && user_ctx->gid == 0) {
+ if(user_ctx->domain->mpg) {
+ user_ctx->gid = user_ctx->uid;
+ }
+ }
+
+ if (user_ctx->uid == 0 || user_ctx->gid == 0) {
/* Must generate uid/gid pair */
return sysdb_get_next_available_id(user_ctx->sysreq,
user_ctx->domain,
@@ -955,9 +954,14 @@ static void user_add_id_callback(void *pvt, int error, struct ldb_result *res)
return;
}
- /* ok id has been allocated, fill in uid and gid fields */
- user_ctx->uid = user_ctx->id.id;
- user_ctx->gid = user_ctx->id.id;
+ /* ok id has been allocated, fill in uid and gid fields if not
+ * already set */
+ if (user_ctx->uid == 0) {
+ user_ctx->uid = user_ctx->id.id;
+ }
+ if (user_ctx->gid == 0) {
+ user_ctx->gid = user_ctx->id.id;
+ }
ret = user_add_call(user_ctx);
if (ret != EOK) {