summaryrefslogtreecommitdiff
path: root/source3/winbindd
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2013-08-30 17:31:16 +0200
committerMichael Adam <obnox@samba.org>2013-10-02 00:06:19 +0200
commit2d8cc3ed9e14d5de98794b131ecf4f4675d1f9d7 (patch)
tree72879a45ab9796595e181d5cfdc8597d44c4e8ef /source3/winbindd
parentf8767cd9d838b726b40271668f18199ee11a3791 (diff)
downloadsamba-2d8cc3ed9e14d5de98794b131ecf4f4675d1f9d7.tar.gz
samba-2d8cc3ed9e14d5de98794b131ecf4f4675d1f9d7.tar.bz2
samba-2d8cc3ed9e14d5de98794b131ecf4f4675d1f9d7.zip
idmap_autorid: factor building of the keystr into a function
to avoid code duplication. Pair-Programmed-with: Atul Kulkarni <atul.kulkarni@in.ibm.com> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Atul Kulkarni <atul.kulkarni@in.ibm.com> Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'source3/winbindd')
-rw-r--r--source3/winbindd/idmap_autorid_tdb.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/source3/winbindd/idmap_autorid_tdb.c b/source3/winbindd/idmap_autorid_tdb.c
index bb5f497842..0523fd5918 100644
--- a/source3/winbindd/idmap_autorid_tdb.c
+++ b/source3/winbindd/idmap_autorid_tdb.c
@@ -25,6 +25,22 @@
#include "idmap_autorid_tdb.h"
+/**
+ * Build the database keystring for getting a range
+ * belonging to a domain sid and a range index.
+ */
+static void idmap_autorid_build_keystr(const char *domsid,
+ uint32_t domain_range_index,
+ fstring keystr)
+{
+ if (domain_range_index > 0) {
+ snprintf(keystr, FSTRING_LEN, "%s#%"PRIu32,
+ domsid, domain_range_index);
+ } else {
+ fstrcpy(keystr, domsid);
+ }
+}
+
static NTSTATUS idmap_autorid_get_domainrange_action(struct db_context *db,
void *private_data)
{
@@ -37,12 +53,8 @@ static NTSTATUS idmap_autorid_get_domainrange_action(struct db_context *db,
range = (struct autorid_range_config *)private_data;
- if (range->domain_range_index > 0) {
- snprintf(keystr, FSTRING_LEN, "%s#%"PRIu32,
- range->domsid, range->domain_range_index);
- } else {
- fstrcpy(keystr, range->domsid);
- }
+ idmap_autorid_build_keystr(range->domsid, range->domain_range_index,
+ keystr);
ret = dbwrap_fetch_uint32_bystring(db, keystr,
&(range->rangenum));
@@ -136,12 +148,8 @@ NTSTATUS idmap_autorid_get_domainrange(struct db_context *db,
* if it is not found create a mapping in a transaction unless
* read-only mode has been set
*/
- if (range->domain_range_index > 0) {
- snprintf(keystr, FSTRING_LEN, "%s#%"PRIu32,
- range->domsid, range->domain_range_index);
- } else {
- fstrcpy(keystr, range->domsid);
- }
+ idmap_autorid_build_keystr(range->domsid, range->domain_range_index,
+ keystr);
ret = dbwrap_fetch_uint32_bystring(db, keystr,
&(range->rangenum));