summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/db/sysdb_ops.c9
-rw-r--r--src/tests/sysdb-tests.c5
2 files changed, 13 insertions, 1 deletions
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 094c27b7f..eb88cd256 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -2539,6 +2539,7 @@ int sysdb_delete_user(struct sysdb_ctx *sysdb,
struct ldb_message *msg;
int ret;
int i;
+ char *sanitized_name;
tmp_ctx = talloc_new(NULL);
if (!tmp_ctx) {
@@ -2578,7 +2579,13 @@ int sysdb_delete_user(struct sysdb_ctx *sysdb,
}
} else if (ret == ENOENT && name != NULL) {
/* Perhaps a ghost user? */
- filter = talloc_asprintf(tmp_ctx, "(%s=%s)", SYSDB_GHOST, name);
+ ret = sss_filter_sanitize(tmp_ctx, name, &sanitized_name);
+ if (ret != EOK) {
+ goto fail;
+ }
+
+ filter = talloc_asprintf(tmp_ctx, "(%s=%s)",
+ SYSDB_GHOST, sanitized_name);
if (filter == NULL) {
ret = ENOMEM;
goto fail;
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index 1c28526e0..bf964fd76 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -3998,6 +3998,11 @@ START_TEST(test_odd_characters)
fail_unless(ret == EOK, "sysdb_delete_user error [%d][%s]",
ret, strerror(ret));
+ /* Delete non existing User */
+ ret = sysdb_delete_user(test_ctx->sysdb, test_ctx->domain,
+ odd_username, 10000);
+ fail_unless(ret == ENOENT, "sysdb_delete_user error [%d][%s]",
+ ret, strerror(ret));
/* Delete Group */
ret = sysdb_delete_group(test_ctx->sysdb, test_ctx->domain,