diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2010-10-29 10:11:05 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-11-15 09:52:35 -0500 |
commit | aef2ac961abfe73c799354f5cfa0331ab44ac765 (patch) | |
tree | d04a1d371fb10d511a4743743a5f009184ca064a /src/db | |
parent | ca92350db6ad6ac344181f7b8ec695eda29da675 (diff) | |
download | sssd-aef2ac961abfe73c799354f5cfa0331ab44ac765.tar.gz sssd-aef2ac961abfe73c799354f5cfa0331ab44ac765.tar.xz sssd-aef2ac961abfe73c799354f5cfa0331ab44ac765.zip |
Add sysdb utility function for sanitizing DN
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/sysdb.c | 24 | ||||
-rw-r--r-- | src/db/sysdb.h | 3 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c index bc6f8fc97..b2691526a 100644 --- a/src/db/sysdb.c +++ b/src/db/sysdb.c @@ -25,6 +25,30 @@ #include "confdb/confdb.h" #include <time.h> +errno_t sysdb_dn_sanitize(void *mem_ctx, const char *input, + char **sanitized) +{ + struct ldb_val val; + errno_t ret = EOK; + + val.data = (uint8_t *)talloc_strdup(mem_ctx, input); + if (!val.data) { + return ENOMEM; + } + + /* We can't include the trailing NULL because it would + * be escaped and result in an unterminated string + */ + val.length = strlen(input); + + *sanitized = ldb_dn_escape_value(mem_ctx, val); + if (!*sanitized) { + ret = ENOMEM; + } + + talloc_free(val.data); + return ret; +} struct ldb_dn *sysdb_custom_subtree_dn(struct sysdb_ctx *ctx, void *memctx, const char *domain, diff --git a/src/db/sysdb.h b/src/db/sysdb.h index 0d8b29c96..fde27b93e 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -697,4 +697,7 @@ errno_t sysdb_netgr_to_entries(TALLOC_CTX *mem_ctx, struct ldb_result *res, struct sysdb_netgroup_ctx ***entries); +errno_t sysdb_dn_sanitize(void *mem_ctx, const char *input, + char **sanitized); + #endif /* __SYS_DB_H__ */ |