summaryrefslogtreecommitdiff
path: root/source3/passdb/passdb.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2002-11-05 07:20:27 +0000
committerAndrew Bartlett <abartlet@samba.org>2002-11-05 07:20:27 +0000
commitb81b71a8d121fdf937dc32aa007a5ce01676c54c (patch)
treeb4e0ca7e3188823d8942f47bcecf0db18e940004 /source3/passdb/passdb.c
parentea6d5bc48bd14f8eaca665576d7094cce53be81a (diff)
downloadsamba-b81b71a8d121fdf937dc32aa007a5ce01676c54c.tar.gz
samba-b81b71a8d121fdf937dc32aa007a5ce01676c54c.tar.bz2
samba-b81b71a8d121fdf937dc32aa007a5ce01676c54c.zip
Merge vl's 'algorithmic rid base' patch, and my changes to pdb_smbpasswd's NUA
support from HEAD -> 3.0 Andrew Bartlett (This used to be commit 89d8ebd520e2a441e6d5b6b8adb6c483b0131adc)
Diffstat (limited to 'source3/passdb/passdb.c')
-rw-r--r--source3/passdb/passdb.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index 04786b59e5..4ce5b93abd 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -500,9 +500,32 @@ BOOL pdb_gethexpwd(const char *p, unsigned char *pwd)
Converts NT user RID to a UNIX uid.
********************************************************************/
+static int algorithmic_rid_base(void)
+{
+ static int rid_offset = 0;
+
+ if (rid_offset != 0)
+ return rid_offset;
+
+ rid_offset = lp_algorithmic_rid_base();
+
+ if (rid_offset < BASE_RID) {
+ /* Try to prevent admin foot-shooting, we can't put algorithmic
+ rids below 1000, that's the 'well known RIDs' on NT */
+ DEBUG(0, ("'algorithmic rid base' must be equal to or above %ld\n", BASE_RID));
+ rid_offset = BASE_RID;
+ }
+ if (rid_offset & 1) {
+ DEBUG(0, ("algorithmic rid base must be even\n"));
+ rid_offset += 1;
+ }
+ return rid_offset;
+}
+
+
uid_t fallback_pdb_user_rid_to_uid(uint32 user_rid)
{
- int rid_offset = lp_algorithmic_rid_base();
+ int rid_offset = algorithmic_rid_base();
return (uid_t)(((user_rid & (~USER_RID_TYPE))- rid_offset)/RID_MULTIPLIER);
}
@@ -513,7 +536,7 @@ uid_t fallback_pdb_user_rid_to_uid(uint32 user_rid)
uint32 fallback_pdb_uid_to_user_rid(uid_t uid)
{
- int rid_offset = lp_algorithmic_rid_base();
+ int rid_offset = algorithmic_rid_base();
return (((((uint32)uid)*RID_MULTIPLIER) + rid_offset) | USER_RID_TYPE);
}
@@ -523,7 +546,7 @@ uint32 fallback_pdb_uid_to_user_rid(uid_t uid)
gid_t pdb_group_rid_to_gid(uint32 group_rid)
{
- int rid_offset = lp_algorithmic_rid_base();
+ int rid_offset = algorithmic_rid_base();
return (gid_t)(((group_rid & (~GROUP_RID_TYPE))- rid_offset)/RID_MULTIPLIER);
}
@@ -537,7 +560,7 @@ gid_t pdb_group_rid_to_gid(uint32 group_rid)
uint32 pdb_gid_to_group_rid(gid_t gid)
{
- int rid_offset = lp_algorithmic_rid_base();
+ int rid_offset = algorithmic_rid_base();
return (((((uint32)gid)*RID_MULTIPLIER) + rid_offset) | GROUP_RID_TYPE);
}