diff options
-rw-r--r-- | source3/client/clientutil.c | 3 | ||||
-rw-r--r-- | source3/include/proto.h | 1 | ||||
-rw-r--r-- | source3/include/rpc_misc.h | 13 | ||||
-rw-r--r-- | source3/passdb/passdb.c | 30 | ||||
-rw-r--r-- | source3/passdb/smbpass.c | 4 |
5 files changed, 43 insertions, 8 deletions
diff --git a/source3/client/clientutil.c b/source3/client/clientutil.c index a09832a68b..2da0fbb215 100644 --- a/source3/client/clientutil.c +++ b/source3/client/clientutil.c @@ -583,6 +583,9 @@ BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup, else pass = (char *)getpass("Password: "); + if(!pass) + pass = ""; + pstrcpy(smb_login_passwd, pass); /* use a blank username for the 2nd try with a blank password */ diff --git a/source3/include/proto.h b/source3/include/proto.h index 3086c6cd24..ff44a5841f 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1611,6 +1611,7 @@ uid_t pdb_user_rid_to_uid(uint32 u_rid); gid_t pdb_group_rid_to_gid(uint32 g_rid); uint32 pdb_uid_to_user_rid(uid_t uid); uint32 pdb_gid_to_group_rid(gid_t gid); +BOOL pdb_rid_is_well_known(uint32 rid); BOOL pdb_rid_is_user(uint32 rid); /*The following definitions come from password.c */ diff --git a/source3/include/rpc_misc.h b/source3/include/rpc_misc.h index 7406916cce..e8ffcd4a16 100644 --- a/source3/include/rpc_misc.h +++ b/source3/include/rpc_misc.h @@ -62,6 +62,19 @@ #define DOMAIN_ALIAS_RID_REPLICATOR (0x00000228L) +/* + * Masks for mappings between unix uid and gid types and + * NT RIDS. + */ + +/* Take the 3 bottom bits. */ +#define RID_TYPE_MASK 7 +#define RID_MULTIPLIER 8 + +/* The two common types for now. */ +#define USER_RID_TYPE 0 +#define GROUP_RID_TYPE 1 + /* ENUM_HND */ typedef struct enum_hnd_info { 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; } diff --git a/source3/passdb/smbpass.c b/source3/passdb/smbpass.c index abb037b95d..003a1742e7 100644 --- a/source3/passdb/smbpass.c +++ b/source3/passdb/smbpass.c @@ -433,9 +433,9 @@ static BOOL add_smbfilepwd_entry(struct smb_passwd *newpwd) int fd; int new_entry_length; - unsigned char *new_entry; + char *new_entry; long offpos; - unsigned char *p; + char *p; /* Open the smbpassword file - for update. */ fp = startsmbfilepwent(True); |