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>
Sat, 14 Aug 2010 00:10:42 +0000 (02:10 +0200)
source3/include/proto.h
source3/winbindd/idmap_util.c

index f7d5e8f8f58feb357cfe764e22b3045c617efc56..bc55eaff072d76e6cb812401e0e90fca7e4c2176 100644 (file)
@@ -6051,6 +6051,7 @@ NTSTATUS idmap_uid_to_sid(const char *domname, struct dom_sid *sid, uid_t uid);
 NTSTATUS idmap_gid_to_sid(const char *domname, struct dom_sid *sid, gid_t gid);
 NTSTATUS idmap_sid_to_uid(const char *dom_name, struct dom_sid *sid, uid_t *uid);
 NTSTATUS idmap_sid_to_gid(const char *domname, struct 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 70c109a7a559e598e66b8e27723b2f27beb8a09b..3afe9f8607bdc2c7ba152b1b15ef4fdee6831732 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;
+}