diff options
author | Sumit Bose <sbose@redhat.com> | 2015-09-21 12:32:48 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2017-03-23 17:18:51 +0100 |
commit | 3994e8779d16db3e9fb30f03e5ecf5e811095ac2 (patch) | |
tree | 69465c66e6d1100568aa9c5cbf63116a8db7a9f3 /src/db | |
parent | 31a6661ff2a640fbcf97460df2415fd1bab309b5 (diff) | |
download | sssd-3994e8779d16db3e9fb30f03e5ecf5e811095ac2.tar.gz sssd-3994e8779d16db3e9fb30f03e5ecf5e811095ac2.tar.xz sssd-3994e8779d16db3e9fb30f03e5ecf5e811095ac2.zip |
sysdb: add sysdb_attrs_copy()
Related to https://pagure.io/SSSD/sssd/issue/3050
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/sysdb.c | 24 | ||||
-rw-r--r-- | src/db/sysdb.h | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c index 5160e3df3..98b7afbfa 100644 --- a/src/db/sysdb.c +++ b/src/db/sysdb.c @@ -752,6 +752,30 @@ done: return ret; } +errno_t sysdb_attrs_copy(struct sysdb_attrs *src, struct sysdb_attrs *dst) +{ + int ret; + size_t c; + size_t d; + + if (src == NULL || dst == NULL) { + return EINVAL; + } + + for (c = 0; c < src->num; c++) { + for (d = 0; d < src->a[c].num_values; d++) { + ret = sysdb_attrs_add_val_safe(dst, src->a[c].name, + &src->a[c].values[d]); + if (ret != EOK) { + DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_add_val failed.\n"); + return ret; + } + } + } + + return EOK; +} + int sysdb_attrs_users_from_str_list(struct sysdb_attrs *attrs, const char *attr_name, const char *domain, diff --git a/src/db/sysdb.h b/src/db/sysdb.h index 83d0d794c..c677957bb 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -352,6 +352,7 @@ int sysdb_attrs_add_lc_name_alias_safe(struct sysdb_attrs *attrs, int sysdb_attrs_copy_values(struct sysdb_attrs *src, struct sysdb_attrs *dst, const char *name); +errno_t sysdb_attrs_copy(struct sysdb_attrs *src, struct sysdb_attrs *dst); int sysdb_attrs_get_el(struct sysdb_attrs *attrs, const char *name, struct ldb_message_element **el); int sysdb_attrs_get_el_ext(struct sysdb_attrs *attrs, const char *name, |