summaryrefslogtreecommitdiffstats
path: root/src/db/sysdb_ops.c
diff options
context:
space:
mode:
authorFabiano FidĂȘncio <fidencio@redhat.com>2016-05-25 23:00:59 +0200
committerJakub Hrozek <jhrozek@redhat.com>2016-05-31 13:07:02 +0200
commit49d84c926b00ba1368372cdec255bceb58d66f43 (patch)
treec8bfeb778ebf55009204da5fabf49f11f12eb117 /src/db/sysdb_ops.c
parent7b9a4a89cb92a0281d73a2c2e79f5eeb317e1149 (diff)
downloadsssd-49d84c926b00ba1368372cdec255bceb58d66f43.tar.gz
sssd-49d84c926b00ba1368372cdec255bceb58d66f43.tar.xz
sssd-49d84c926b00ba1368372cdec255bceb58d66f43.zip
sysdb: add sysdb_{add,replace,delete}_ulong()
As the add_ulong() convenience can add, replace or remove a unsigned long 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_ulong(), sysdb_replace_ulong() and sysdb_delete_ulong(). These new functions are basically wrappers of add_ulong() (now sysdb_ldb_msg_ulong_helper()), calling it using the proper flag according to each function. Any code previously using add_ulong() is now adapted to use these brand new functions. Related: 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_ops.c')
-rw-r--r--src/db/sysdb_ops.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 39489a465..3c9a85395 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -963,8 +963,7 @@ int sysdb_get_new_id(struct sss_domain_info *domain,
}
msg->dn = base_dn;
- ret = add_ulong(msg, LDB_FLAG_MOD_REPLACE,
- SYSDB_NEXTID, new_id + 1);
+ ret = sysdb_replace_ulong(msg, SYSDB_NEXTID, new_id + 1);
if (ret) {
goto done;
}
@@ -1030,10 +1029,10 @@ int sysdb_add_basic_user(struct sss_domain_info *domain,
ret = sysdb_add_string(msg, SYSDB_NAME, name);
if (ret) goto done;
- ret = add_ulong(msg, LDB_FLAG_MOD_ADD, SYSDB_UIDNUM, (unsigned long)uid);
+ ret = sysdb_add_ulong(msg, SYSDB_UIDNUM, (unsigned long)uid);
if (ret) goto done;
- ret = add_ulong(msg, LDB_FLAG_MOD_ADD, SYSDB_GIDNUM, (unsigned long)gid);
+ ret = sysdb_add_ulong(msg, SYSDB_GIDNUM, (unsigned long)gid);
if (ret) goto done;
/* We set gecos to be the same as fullname on user creation,
@@ -1058,8 +1057,7 @@ int sysdb_add_basic_user(struct sss_domain_info *domain,
}
/* creation time */
- ret = add_ulong(msg, LDB_FLAG_MOD_ADD, SYSDB_CREATE_TIME,
- (unsigned long)time(NULL));
+ ret = sysdb_add_ulong(msg, SYSDB_CREATE_TIME, (unsigned long)time(NULL));
if (ret) goto done;
ret = ldb_add(domain->sysdb->ldb, msg);
@@ -1445,12 +1443,11 @@ int sysdb_add_basic_group(struct sss_domain_info *domain,
ret = sysdb_add_string(msg, SYSDB_NAME, name);
if (ret) goto done;
- ret = add_ulong(msg, LDB_FLAG_MOD_ADD, SYSDB_GIDNUM, (unsigned long)gid);
+ ret = sysdb_add_ulong(msg, SYSDB_GIDNUM, (unsigned long)gid);
if (ret) goto done;
/* creation time */
- ret = add_ulong(msg, LDB_FLAG_MOD_ADD, SYSDB_CREATE_TIME,
- (unsigned long)time(NULL));
+ ret = sysdb_add_ulong(msg, SYSDB_CREATE_TIME, (unsigned long)time(NULL));
if (ret) goto done;
ret = ldb_add(domain->sysdb->ldb, msg);
@@ -1764,8 +1761,7 @@ int sysdb_add_basic_netgroup(struct sss_domain_info *domain,
}
/* creation time */
- ret = add_ulong(msg, LDB_FLAG_MOD_ADD, SYSDB_CREATE_TIME,
- (unsigned long) time(NULL));
+ ret = sysdb_add_ulong(msg, SYSDB_CREATE_TIME, (unsigned long) time(NULL));
if (ret) goto done;
ret = ldb_add(domain->sysdb->ldb, msg);