Skip to content

Commit

Permalink
sssd: adding mail as case insensitive
Browse files Browse the repository at this point in the history
Resolves: SSSD#7173

Reviewed-by: Iker Pedrosa <[email protected]>
Reviewed-by: Tomáš Halman <[email protected]>
  • Loading branch information
andreboscatto authored and alexey-tikhonov committed Feb 9, 2024
1 parent a153f13 commit 945cebc
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/db/sysdb_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,13 @@ static errno_t sysdb_domain_cache_upgrade(TALLOC_CTX *mem_ctx,
}
}

if (strcmp(version, SYSDB_VERSION_0_23) == 0) {
ret = sysdb_upgrade_23(sysdb, &version);
if (ret != EOK) {
goto done;
}
}

ret = EOK;
done:
sysdb->ldb = save_ldb;
Expand Down
5 changes: 4 additions & 1 deletion src/db/sysdb_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#ifndef __INT_SYS_DB_H__
#define __INT_SYS_DB_H__

#define SYSDB_VERSION_0_24 "0.24"
#define SYSDB_VERSION_0_23 "0.23"
#define SYSDB_VERSION_0_22 "0.22"
#define SYSDB_VERSION_0_21 "0.21"
Expand All @@ -47,7 +48,7 @@
#define SYSDB_VERSION_0_2 "0.2"
#define SYSDB_VERSION_0_1 "0.1"

#define SYSDB_VERSION SYSDB_VERSION_0_23
#define SYSDB_VERSION SYSDB_VERSION_0_24

#define SYSDB_BASE_LDIF \
"dn: @ATTRIBUTES\n" \
Expand All @@ -60,6 +61,7 @@
"objectclass: CASE_INSENSITIVE\n" \
"ipHostNumber: CASE_INSENSITIVE\n" \
"ipNetworkNumber: CASE_INSENSITIVE\n" \
"mail: CASE_INSENSITIVE\n" \
"\n" \
"dn: @INDEXLIST\n" \
"@IDXATTR: cn\n" \
Expand Down Expand Up @@ -191,6 +193,7 @@ int sysdb_upgrade_19(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_20(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_21(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_22(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_23(struct sysdb_ctx *sysdb, const char **ver);

int sysdb_ts_upgrade_01(struct sysdb_ctx *sysdb, const char **ver);

Expand Down
56 changes: 56 additions & 0 deletions src/db/sysdb_upgrade.c
Original file line number Diff line number Diff line change
Expand Up @@ -2718,6 +2718,62 @@ int sysdb_upgrade_22(struct sysdb_ctx *sysdb, const char **ver)
return ret;
}

int sysdb_upgrade_23(struct sysdb_ctx *sysdb, const char **ver)
{
TALLOC_CTX *tmp_ctx;
int ret;
struct ldb_message *msg;
struct upgrade_ctx *ctx;

tmp_ctx = talloc_new(NULL);
if (!tmp_ctx) {
return ENOMEM;
}

ret = commence_upgrade(sysdb, sysdb->ldb, SYSDB_VERSION_0_24, &ctx);
if (ret) {
return ret;
}

/* Add new indexes */
msg = ldb_msg_new(tmp_ctx);
if (!msg) {
ret = ENOMEM;
goto done;
}
msg->dn = ldb_dn_new(tmp_ctx, sysdb->ldb, "@ATTRIBUTES");
if (!msg->dn) {
ret = ENOMEM;
goto done;
}

/* Case insensitive search for mail */
ret = ldb_msg_add_empty(msg, SYSDB_USER_EMAIL, LDB_FLAG_MOD_ADD, NULL);
if (ret != LDB_SUCCESS) {
ret = ENOMEM;
goto done;
}
ret = ldb_msg_add_string(msg, SYSDB_USER_EMAIL, "CASE_INSENSITIVE");
if (ret != LDB_SUCCESS) {
ret = ENOMEM;
goto done;
}

ret = ldb_modify(sysdb->ldb, msg);
if (ret != LDB_SUCCESS) {
ret = sysdb_error_to_errno(ret);
goto done;
}

/* conversion done, update version number */
ret = update_version(ctx);

done:
ret = finish_upgrade(ret, &ctx, ver);
talloc_free(tmp_ctx);
return ret;
}

int sysdb_ts_upgrade_01(struct sysdb_ctx *sysdb, const char **ver)
{
struct upgrade_ctx *ctx;
Expand Down

0 comments on commit 945cebc

Please sign in to comment.