Patch for parse_samr.c:make_sam_info_1

Sean Mathews mathewss at nutech.com
Sun Jan 10 06:47:34 GMT 1999


 This fixes problems with the SAMR_QUERY_DISPINFO command
from a client where it is attempting to enum the users
if your smbpasswd file is not in perfect order say you have users
and MACHINE$ accounts mixed it gets to be a real mess and since
its not documented that it is necessarey to have this and i myself
and too stupid to read any doc's in detail enough to find this out
before doing samba work might be a good idea to make the code
more umm idiot proof.

-------------------------------
/*******************************************************************
makes a SAM_INFO_1 structure.
********************************************************************/
void make_sam_info_1(SAM_INFO_1 *sam, uint32 acb_mask,
		uint32 start_idx, uint32 num_sam_entries,
		SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES])
{
	int i,x;
	int entries_added;

	if (sam == NULL) return;

	DEBUG(5,("make_sam_info_1\n"));

	if (num_sam_entries >= MAX_SAM_ENTRIES)
	{
		num_sam_entries = MAX_SAM_ENTRIES;
		DEBUG(5,("limiting number of entries to %d\n", 
			 num_sam_entries));
	}
    
	/* Actual start_idx needs to be based upon the acb_mask 
	   so we will sync i to the needed starting point in pass[] */
	for (i = 0, x = 0; i < num_sam_entries; i++)
	{
		if (IS_BITS_SET_ALL(pass[i].acb_info, acb_mask))
		{			
			if(x == start_idx)
				break;
			x++;
		}
	}

	for (entries_added = 0; i < num_sam_entries; i++)
	{
		if (IS_BITS_SET_ALL(pass[i].acb_info, acb_mask))
		{
			make_sam_entry1(&(sam->sam[entries_added]),
						start_idx + entries_added
+ 1,

pass[i].uni_user_name.uni_str_len,

pass[i].uni_full_name.uni_str_len, 

pass[i].uni_acct_desc.uni_str_len,
						pass[i].user_rid,
						pass[i].acb_info);


copy_unistr2(&(sam->str[entries_added].uni_acct_name),
&(pass[i].uni_user_name));

copy_unistr2(&(sam->str[entries_added].uni_full_name),
&(pass[i].uni_full_name));

copy_unistr2(&(sam->str[entries_added].uni_acct_desc),
&(pass[i].uni_acct_desc));
			entries_added++;
		}
	}

	sam->num_entries   = entries_added;
	sam->ptr_entries   = 1;
	sam->num_entries2  = entries_added;
}
 
------------------------------- 


 Regards 
  Sean Mathews Nu Tech CTO

struct SoftwareProfessional { 
  double salary;
  long   lunches;
  float  jobs;
  char   unstable;
  void   work;
  short  tempers; 
};



More information about the samba-ntdom mailing list