summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/utils/net_idmap.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c
index 0ee180e13e..8109bef522 100644
--- a/source3/utils/net_idmap.c
+++ b/source3/utils/net_idmap.c
@@ -84,18 +84,21 @@ static int net_idmap_find_max_id(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA data,
void *handle)
{
struct hwms *hwms = (struct hwms *)handle;
- int *idptr = NULL;
+ void *idptr = NULL;
+ BOOL isgid = False;
int id;
if (strncmp(key.dptr, "S-", 2) != 0)
return 0;
if (sscanf(data.dptr, "GID %d", &id) == 1) {
- idptr = &hwms->group_hwm;
+ idptr = (void *)&hwms->group_hwm;
+ isgid = True;
}
if (sscanf(data.dptr, "UID %d", &id) == 1) {
- idptr = &hwms->user_hwm;
+ idptr = (void *)&hwms->user_hwm;
+ isgid = False;
}
if (idptr == NULL) {
@@ -105,8 +108,15 @@ static int net_idmap_find_max_id(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA data,
return -1;
}
- if (*idptr <= id)
- *idptr = id+1;
+ if (isgid) {
+ if (hwms->group_hwm <= (gid_t)id) {
+ hwms->group_hwm = (gid_t)(id+1);
+ }
+ } else {
+ if (hwms->user_hwm <= (uid_t)id) {
+ hwms->user_hwm = (uid_t)(id+1);
+ }
+ }
return 0;
}