summaryrefslogtreecommitdiffstats
path: root/src/db/sysdb.c
diff options
context:
space:
mode:
authorFabiano FidĂȘncio <fidencio@redhat.com>2016-05-25 21:12:18 +0200
committerJakub Hrozek <jhrozek@redhat.com>2016-05-31 13:06:50 +0200
commita928f7a6bd7681db6e26cba3eb7da22d14288737 (patch)
tree7996403758dea9a8c5c43157a17bd29801a7709d /src/db/sysdb.c
parent5b1e73bc40a55f2095660423a2a4623a93de1ef8 (diff)
downloadsssd-a928f7a6bd7681db6e26cba3eb7da22d14288737.tar.gz
sssd-a928f7a6bd7681db6e26cba3eb7da22d14288737.tar.xz
sssd-a928f7a6bd7681db6e26cba3eb7da22d14288737.zip
sysdb: add sysdb_{add,replace,delete}_string()
As the add_string() convenience can add, replace or delete a string according to the operation received as its argument, some confusion can easily happen due to its misleading name. In order to improve the explicitness of our code, let's introduce sysdb_add_string(), sysdb_replace_string() and sysdb_delete_string(). These new functions are basically wrappers of add_string() (now sysdb_ldb_msg_string_helper()), calling it using the proper flag according to each function. Any code previously using add_string() is now adapted to use these brand new functions. Resolves: https://fedorahosted.org/sssd/ticket/1656 Signed-off-by: Fabiano FidĂȘncio <fabiano@fidencio.org> Reviewed-by: Petr Cech <pcech@redhat.com>
Diffstat (limited to 'src/db/sysdb.c')
-rw-r--r--src/db/sysdb.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index f83d236c8..81223ad74 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -2112,8 +2112,8 @@ done:
return EOK;
}
-int add_string(struct ldb_message *msg, int flags,
- const char *attr, const char *value)
+static int sysdb_ldb_msg_string_helper(struct ldb_message *msg, int flags,
+ const char *attr, const char *value)
{
int ret;
@@ -2124,3 +2124,21 @@ int add_string(struct ldb_message *msg, int flags,
}
return ENOMEM;
}
+
+int sysdb_add_string(struct ldb_message *msg,
+ const char *attr, const char *value)
+{
+ return sysdb_ldb_msg_string_helper(msg, LDB_FLAG_MOD_ADD, attr, value);
+}
+
+int sysdb_replace_string(struct ldb_message *msg,
+ const char *attr, const char *value)
+{
+ return sysdb_ldb_msg_string_helper(msg, LDB_FLAG_MOD_REPLACE, attr, value);
+}
+
+int sysdb_delete_string(struct ldb_message *msg,
+ const char *attr, const char *value)
+{
+ return sysdb_ldb_msg_string_helper(msg, LDB_FLAG_MOD_DELETE, attr, value);
+}