s3:idmap: add idmap_unix_id_is_in_range() for checking an id against an idmap range
authorMichael Adam <obnox@samba.org>
Wed, 16 Jun 2010 14:59:26 +0000 (16:59 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 23 Jun 2010 09:10:36 +0000 (11:10 +0200)
source3/include/proto.h
source3/winbindd/idmap_util.c

index ae78914ee13e2cbeb61cf9926cd21fb095254e45..9726e833e1c2d807ada3b28c8b855778f6867501 100644 (file)
@@ -7241,6 +7241,7 @@ NTSTATUS idmap_uid_to_sid(const char *domname, DOM_SID *sid, uid_t uid);
 NTSTATUS idmap_gid_to_sid(const char *domname, DOM_SID *sid, gid_t gid);
 NTSTATUS idmap_sid_to_uid(const char *dom_name, DOM_SID *sid, uid_t *uid);
 NTSTATUS idmap_sid_to_gid(const char *domname, DOM_SID *sid, gid_t *gid);
+bool idmap_unix_id_is_in_range(uint32_t id, struct idmap_domain *dom);
 
 /* The following definitions come from winbindd/nss_info.c  */
 
index 6e88730130668e7253e953fdff841e72e0268d54..950233eeb66971bc9a7a16527be96298cb28cd52 100644 (file)
@@ -287,3 +287,22 @@ backend:
        }
        return NT_STATUS_OK;
 }
+
+/**
+ * check whether a given unix id is inside the filter range of an idmap domain
+ */
+bool idmap_unix_id_is_in_range(uint32_t id, struct idmap_domain *dom)
+{
+       if (id == 0) {
+               /* 0 is not an allowed unix id for id mapping */
+               return false;
+       }
+
+       if ((dom->low_id && (id < dom->low_id)) ||
+           (dom->high_id && (id > dom->high_id)))
+       {
+               return false;
+       }
+
+       return true;
+}