summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Ambach <ambi@samba.org>2011-10-20 18:39:30 +0200
committerKarolin Seeger <kseeger@samba.org>2011-11-10 20:50:55 +0100
commit31593bcd74f4063217190012a83e1003e29fdba7 (patch)
tree5bd03e2e59822cee2a21aa08b529ec58ceb06478
parent188a12e1df2a5a3ae39cb2e25c87ae2093a62853 (diff)
downloadsamba-31593bcd74f4063217190012a83e1003e29fdba7.tar.gz
samba-31593bcd74f4063217190012a83e1003e29fdba7.tar.xz
samba-31593bcd74f4063217190012a83e1003e29fdba7.zip
s3:idmap_autorid: move HWM initialization into a function
we will need some more HWM soon, so move out initialization and optimize the logic using the new interface of dbwrap_fetch_uint32
-rw-r--r--source3/winbindd/idmap_autorid.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c
index 0fcfc9604ec..eb8abf3a584 100644
--- a/source3/winbindd/idmap_autorid.c
+++ b/source3/winbindd/idmap_autorid.c
@@ -326,12 +326,32 @@ static NTSTATUS idmap_autorid_sids_to_unixids(struct idmap_domain *dom,
}
+/* initialize the given HWM to 0 if it does not exist yet */
+static NTSTATUS idmap_autorid_init_hwm(const char *hwm) {
+
+ NTSTATUS status;
+ int32_t hwmval;
+
+ hwmval = dbwrap_fetch_int32(autorid_db, hwm);
+ if ((hwmval < 0)) {
+ status = dbwrap_trans_store_int32(autorid_db, hwm, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,
+ ("Unable to initialise HWM (%s) in autorid "
+ "database: %s\n", hwm, nt_errstr(status)));
+ return NT_STATUS_INTERNAL_DB_ERROR;
+ }
+ }
+
+ return NT_STATUS_OK;
+}
+
/*
* open and initialize the database which stores the ranges for the domains
*/
static NTSTATUS idmap_autorid_db_init(void)
{
- int32_t hwm;
+ NTSTATUS status;
if (autorid_db) {
/* its already open */
@@ -349,16 +369,9 @@ static NTSTATUS idmap_autorid_db_init(void)
}
/* Initialize high water mark for the currently used range to 0 */
- hwm = dbwrap_fetch_int32(autorid_db, HWM);
- if ((hwm < 0)) {
- if (!NT_STATUS_IS_OK
- (dbwrap_trans_store_int32(autorid_db, HWM, 0))) {
- DEBUG(0,
- ("Unable to initialise HWM in autorid "
- "database\n"));
- return NT_STATUS_INTERNAL_DB_ERROR;
- }
- }
+
+ status = idmap_autorid_init_hwm(HWM);
+ NT_STATUS_NOT_OK_RETURN(status);
return NT_STATUS_OK;
}