summaryrefslogtreecommitdiff
path: root/source3/passdb/passdb.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-06-01 18:50:27 +0000
committerJeremy Allison <jra@samba.org>1998-06-01 18:50:27 +0000
commitffe91d6443f2a3e19977ed97167dd100a42a3e9a (patch)
treea9db7c7d7258a5a2dfbbc8debbc514d117aad467 /source3/passdb/passdb.c
parent3c116d2aa70d68bb4d2c536f03b83d6faf86f53b (diff)
downloadsamba-ffe91d6443f2a3e19977ed97167dd100a42a3e9a.tar.gz
samba-ffe91d6443f2a3e19977ed97167dd100a42a3e9a.tar.bz2
samba-ffe91d6443f2a3e19977ed97167dd100a42a3e9a.zip
clientutil.c: Don't core dump if no controlling terminal available for password.
passdb.c: lib/rpc/include/rpc_misc.h: First cut at automatic uid/gid to rid mapping. We can change this at a later date to make more bits available if neccessary. Jeremy. (This used to be commit 34f40474aba97118e1e80fe6259c686e46dc16b4)
Diffstat (limited to 'source3/passdb/passdb.c')
-rw-r--r--source3/passdb/passdb.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index 5bb20fce98..2ba856e19b 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -1058,7 +1058,7 @@ Error was %s\n", sid_file, strerror(errno) ));
uid_t pdb_user_rid_to_uid(uint32 u_rid)
{
- return (uid_t)(u_rid - 1000);
+ return (uid_t)((u_rid / RID_MULTIPLIER) - 1000);
}
/*******************************************************************
@@ -1067,7 +1067,7 @@ uid_t pdb_user_rid_to_uid(uint32 u_rid)
gid_t pdb_group_rid_to_gid(uint32 g_rid)
{
- return (gid_t)(g_rid - 1000);
+ return (gid_t)((g_rid / RID_MULTIPLIER) - 1000);
}
/*******************************************************************
@@ -1076,7 +1076,7 @@ gid_t pdb_group_rid_to_gid(uint32 g_rid)
uint32 pdb_uid_to_user_rid(uid_t uid)
{
- return (uint32)(uid + 1000);
+ return (((((uint32)uid)*RID_MULTIPLIER) + 1000) | USER_RID_TYPE);
}
/*******************************************************************
@@ -1085,7 +1085,16 @@ uint32 pdb_uid_to_user_rid(uid_t uid)
uint32 pdb_gid_to_group_rid(gid_t gid)
{
- return (uint32)(gid + 1000);
+ return (((((uint32)gid)*RID_MULTIPLIER) + 1000) | GROUP_RID_TYPE);
+}
+
+/*******************************************************************
+ Decides if a RID is a well known RID.
+ ********************************************************************/
+
+BOOL pdb_rid_is_well_known(uint32 rid)
+{
+ return (rid < 1000);
}
/*******************************************************************
@@ -1094,10 +1103,19 @@ uint32 pdb_gid_to_group_rid(gid_t gid)
BOOL pdb_rid_is_user(uint32 rid)
{
- /* Punt for now - we need to look at the encoding here. JRA. */
/* lkcl i understand that NT attaches an enumeration to a RID
* such that it can be identified as either a user, group etc
* type. there are 5 such categories, and they are documented.
*/
- return True;
+ if(pdb_rid_is_well_known(rid)) {
+ /*
+ * The only well known user RIDs are DOMAIN_USER_RID_ADMIN
+ * and DOMAIN_USER_RID_GUEST.
+ */
+ if(rid == DOMAIN_USER_RID_ADMIN || rid == DOMAIN_USER_RID_GUEST)
+ return True;
+ } else if((rid & RID_TYPE_MASK) == USER_RID_TYPE) {
+ return True;
+ }
+ return False;
}