some fixes for 2.1.0-prealpha

Sean Mathews mathewss at mail.nutech.com
Fri Jan 8 21:37:52 GMT 1999


 After extensive debugging i found out why
the current cvs tree src causes run away
smbd service. At least on my OS NetBSD 1.3
a call to getgrent() will properly enum
the group database but any calls to getgrgid()
will reset the static file pointer used by
getgrent() to the position asked for by getgrgid()

 Thus we end up with infinite loops inside of
functions like aliasunix.c:getalsunixpwent() in
the while ((unix_grp = getgrent()) !=NULL)
loop.

this type of situation exists in
aliasunix.c,builtinunix.c,groupunix.c
to fix this i have done something like the following.
it gets the list of unix id's first into an array
ya ya i know its a fixed array not very safe but
im not looking for perfect just to solve the bug 
so dont flame me on that. Then it goes through
the array of gid's and does its work from there.
 This solved the run away problems under usermanager
when pulling up info on groups etc etc, but now
my current 2 problems are as follows.

Administrator login to the domain failes smbd log shows this
[1999/01/08 14:45:24, 0] passdb/sampassdb.c:pwdb_sam_map_names(517)
  UNIX User root Primary Group is in the wrong domain! S-1-5-32-544

second problem is if i log in localy out of the domain
i can pull up user manager but when i go into the group
say "Administrators" to see its members and push "Add"
i end up with an error on the "Add Users And Groups"
window unable to browse the selected domain because
the following error occured: The tag is invalid.

 Well back to the grind.. I havnt been able
to get my original beta1 back working again
seems what ever magic wand i waved over it when i 
had it working i cant reproduct so looks like im
without a pdc for now.
 
 Regards
  Sean Mathews


static LOCAL_GRP *getbltunixpwent(void *vp, LOCAL_GRP_MEMBER **mem, int *num_mem)
{
	/* Static buffers we will return. */
	static LOCAL_GRP gp_buf;
	struct group *unix_grp;
	gid_t gidlist[100];    
	int gidcount=-1;
	int currentgid=0;
	
	memset(gidlist,0,sizeof(gidlist));

	if (lp_server_role() == ROLE_DOMAIN_NONE)
	{
		/*
		 * no domain role, no domain builtin aliases (or domain groups,
		 * but that's dealt with by groupdb...).
		 */

		return NULL;
	}

	bidb_init_blt(&gp_buf);

    while ((unix_grp = getgrent()) !=NULL)
	{
		gidcount++;
		gidlist[gidcount]=unix_grp->gr_gid;
		DEBUG(10,("getgrpunixpwent: enum unix group entry %s %d\n",
		           unix_grp->gr_name,gidcount));
	}


	/* cycle through unix groups */
	while (currentgid<=gidcount)
	{
		DOM_NAME_MAP gmep;
		fstring sid_str;
			
		if (!lookupsmbgrpgid(gidlist[currentgid], &gmep))
		{
			currentgid++;
			continue;
		}

		sid_to_string(sid_str, &gmep.sid);
		DEBUG(10,("group %s found, sid %s type %d\n",
			gmep.nt_name, sid_str, gmep.type));

		if (gmep.type != SID_NAME_ALIAS)
		{
			currentgid++;
			continue;
		}

		sid_split_rid(&gmep.sid, &gp_buf.rid);
		if (!sid_equal(&global_sid_S_1_5_20, &gmep.sid))
		{
			currentgid++;
			continue;
		}

		fstrcpy(gp_buf.name, gmep.nt_name);
		break;
	}

	if (currentgid>gidcount)
	{
		return NULL;
	}
	
	unix_grp = getgrgid(gidlist[currentgid]);
	/* get the user's domain builtin aliases.  there are a maximum of 32 */

	if (mem != NULL && num_mem != NULL)
	{
		(*mem) = NULL;
		(*num_mem) = 0;

		get_unixbuiltin_members(unix_grp, num_mem, mem);
	}

	{
		pstring linebuf;
		make_builtin_line(linebuf, sizeof(linebuf), &gp_buf, mem, num_mem);
		DEBUG(10,("line: '%s'\n", linebuf));
	}

	return &gp_buf;
}




More information about the samba-ntdom mailing list