summaryrefslogtreecommitdiffstats
path: root/src/db/sysdb.c
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2014-09-21 16:55:21 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-10-06 14:19:37 +0200
commitd7d3ee1b8ab7a05129c83da8a185351d7c751c1c (patch)
treef2c2d9a2626791c412f661d08bed43c8eca69f99 /src/db/sysdb.c
parente4f6562e4043aa645088862d1cc657c3eff43c49 (diff)
downloadsssd-d7d3ee1b8ab7a05129c83da8a185351d7c751c1c.tar.gz
sssd-d7d3ee1b8ab7a05129c83da8a185351d7c751c1c.tar.xz
sssd-d7d3ee1b8ab7a05129c83da8a185351d7c751c1c.zip
SYSDB: move sysdb_get_real_name() from sysdb.c to sysdb_search.c
The sysdb.c should be reserved for utility and setup functions. Search functions belong to sysdb_search.c Keeping functions in specialized modules helps to maintain nice dependencies and in overall makes unit testing easier. Moreover, the function was not unit tested, which needed fixing. Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Diffstat (limited to 'src/db/sysdb.c')
-rw-r--r--src/db/sysdb.c52
1 files changed, 0 insertions, 52 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index 3bc27c84a..88cff241f 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -1882,58 +1882,6 @@ done:
return ret;
}
-errno_t sysdb_get_real_name(TALLOC_CTX *mem_ctx,
- struct sss_domain_info *domain,
- const char *name,
- const char **_cname)
-{
- errno_t ret;
- TALLOC_CTX *tmp_ctx;
- struct ldb_result *res;
- const char *cname;
- struct ldb_message *msg;
-
- tmp_ctx = talloc_new(NULL);
- if (!tmp_ctx) {
- return ENOMEM;
- }
-
- ret = sysdb_getpwnam(tmp_ctx, domain, name, &res);
- if (ret != EOK) {
- DEBUG(SSSDBG_OP_FAILURE, "Cannot canonicalize username\n");
- goto done;
- }
-
- if (res->count == 0) {
- ret = sysdb_search_user_by_upn(tmp_ctx, domain, name, NULL, &msg);
- if (ret != EOK) {
- /* User cannot be found in cache */
- DEBUG(SSSDBG_OP_FAILURE, "Cannot find user [%s] in cache\n", name);
- goto done;
- }
- } else if (res->count == 1) {
- msg = res->msgs[0];
- } else {
- DEBUG(SSSDBG_CRIT_FAILURE,
- "sysdb_getpwnam returned count: [%d]\n", res->count);
- ret = EIO;
- goto done;
- }
-
- cname = ldb_msg_find_attr_as_string(msg, SYSDB_NAME, NULL);
- if (!cname) {
- DEBUG(SSSDBG_CRIT_FAILURE, "A user with no name?\n");
- ret = ENOENT;
- goto done;
- }
-
- ret = EOK;
- *_cname = talloc_steal(mem_ctx, cname);
-done:
- talloc_free(tmp_ctx);
- return ret;
-}
-
errno_t sysdb_msg2attrs(TALLOC_CTX *mem_ctx, size_t count,
struct ldb_message **msgs,
struct sysdb_attrs ***attrs)