summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb.c22
-rw-r--r--src/db/sysdb_ops.c18
-rw-r--r--src/db/sysdb_private.h8
-rw-r--r--src/db/sysdb_ranges.c18
-rw-r--r--src/db/sysdb_services.c9
5 files changed, 44 insertions, 31 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index 926994d3a..3c888a42c 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -2143,8 +2143,8 @@ int sysdb_delete_string(struct ldb_message *msg,
return sysdb_ldb_msg_string_helper(msg, LDB_FLAG_MOD_DELETE, attr, value);
}
-int add_ulong(struct ldb_message *msg, int flags,
- const char *attr, unsigned long value)
+static int sysdb_ldb_msg_ulong_helper(struct ldb_message *msg, int flags,
+ const char *attr, unsigned long value)
{
int ret;
@@ -2155,3 +2155,21 @@ int add_ulong(struct ldb_message *msg, int flags,
}
return ENOMEM;
}
+
+int sysdb_add_ulong(struct ldb_message *msg,
+ const char *attr, unsigned long value)
+{
+ return sysdb_ldb_msg_ulong_helper(msg, LDB_FLAG_MOD_ADD, attr, value);
+}
+
+int sysdb_replace_ulong(struct ldb_message *msg,
+ const char *attr, unsigned long value)
+{
+ return sysdb_ldb_msg_ulong_helper(msg, LDB_FLAG_MOD_REPLACE, attr, value);
+}
+
+int sysdb_delete_ulong(struct ldb_message *msg,
+ const char *attr, unsigned long value)
+{
+ return sysdb_ldb_msg_ulong_helper(msg, LDB_FLAG_MOD_DELETE, attr, value);
+}
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);
diff --git a/src/db/sysdb_private.h b/src/db/sysdb_private.h
index 75a58c6d3..4b1667ca4 100644
--- a/src/db/sysdb_private.h
+++ b/src/db/sysdb_private.h
@@ -130,8 +130,12 @@ int sysdb_replace_string(struct ldb_message *msg,
const char *attr, const char *value);
int sysdb_delete_string(struct ldb_message *msg,
const char *attr, const char *value);
-int add_ulong(struct ldb_message *msg, int flags,
- const char *attr, unsigned long value);
+int sysdb_add_ulong(struct ldb_message *msg,
+ const char *attr, unsigned long value);
+int sysdb_replace_ulong(struct ldb_message *msg,
+ const char *attr, unsigned long value);
+int sysdb_delete_ulong(struct ldb_message *msg,
+ const char *attr, unsigned long value);
/* The utility function to create a subdomain sss_domain_info object is handy
* for unit tests, so it should be available in a header, but not a public util
diff --git a/src/db/sysdb_ranges.c b/src/db/sysdb_ranges.c
index da599bf30..511e4785d 100644
--- a/src/db/sysdb_ranges.c
+++ b/src/db/sysdb_ranges.c
@@ -206,8 +206,8 @@ errno_t sysdb_range_create(struct sysdb_ctx *sysdb, struct range_info *range)
SYSDB_DOMAIN_ID_RANGE_CLASS);
if (ret) goto done;
- ret = add_ulong(msg, LDB_FLAG_MOD_ADD, SYSDB_SECONDARY_BASE_RID,
- (unsigned long) range->secondary_base_rid);
+ ret = sysdb_add_ulong(msg, SYSDB_SECONDARY_BASE_RID,
+ (unsigned long) range->secondary_base_rid);
if (ret) goto done;
} else if (range->trusted_dom_sid != NULL &&
range->secondary_base_rid == 0) {
@@ -222,20 +222,18 @@ errno_t sysdb_range_create(struct sysdb_ctx *sysdb, struct range_info *range)
ret = sysdb_add_string(msg, SYSDB_NAME, range->name);
if (ret) goto done;
- ret = add_ulong(msg, LDB_FLAG_MOD_ADD, SYSDB_BASE_ID,
- (unsigned long) range->base_id);
+ ret = sysdb_add_ulong(msg, SYSDB_BASE_ID, (unsigned long) range->base_id);
if (ret) goto done;
- ret = add_ulong(msg, LDB_FLAG_MOD_ADD, SYSDB_ID_RANGE_SIZE,
- (unsigned long) range->id_range_size);
+ ret = sysdb_add_ulong(msg, SYSDB_ID_RANGE_SIZE,
+ (unsigned long) range->id_range_size);
if (ret) goto done;
- ret = add_ulong(msg, LDB_FLAG_MOD_ADD, SYSDB_BASE_RID,
- (unsigned long) range->base_rid);
+ ret = sysdb_add_ulong(msg, SYSDB_BASE_RID,
+ (unsigned long) range->base_rid);
if (ret) goto done;
- 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 = sysdb_add_string(msg, SYSDB_ID_RANGE_TYPE, range->range_type);
diff --git a/src/db/sysdb_services.c b/src/db/sysdb_services.c
index 20c88b724..8118fef00 100644
--- a/src/db/sysdb_services.c
+++ b/src/db/sysdb_services.c
@@ -468,8 +468,7 @@ sysdb_svc_add(TALLOC_CTX *mem_ctx,
if (ret != EOK) goto done;
/* Set the port number */
- ret = add_ulong(msg, LDB_FLAG_MOD_ADD,
- SYSDB_SVC_PORT, port);
+ ret = sysdb_add_ulong(msg, SYSDB_SVC_PORT, port);
if (ret != EOK) goto done;
/* If this service has any aliases, include them */
@@ -506,8 +505,7 @@ sysdb_svc_add(TALLOC_CTX *mem_ctx,
}
/* 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;
lret = ldb_add(domain->sysdb->ldb, msg);
@@ -551,8 +549,7 @@ sysdb_svc_update(struct sysdb_ctx *sysdb,
msg->dn = dn;
/* Update the port */
- ret = add_ulong(msg, SYSDB_MOD_REP,
- SYSDB_SVC_PORT, port);
+ ret = sysdb_replace_ulong(msg, SYSDB_SVC_PORT, port);
if (ret != EOK) goto done;
if (aliases && aliases[0]) {