Пример #1
0
/****************************************************************************
parse the debug levels from smb.conf. Example debug level string:
  3 tdb:5 printdrivers:7
Note: the 1st param has no "name:" preceeding it.
****************************************************************************/
BOOL debug_parse_levels(char *params_str)
{
	int  i;
	char *params[DBGC_LAST];
	int  debuglevel_class[DBGC_LAST];	

	ZERO_ARRAY(params);
	ZERO_ARRAY(debuglevel_class);

	if ((params[0]=strtok(params_str," ,"))) {
		for (i=1; i<DBGC_LAST;i++) {
			if ((params[i]=strtok(NULL," ,"))==NULL)
				break;
		}
	}
	else
		return False;

	if (AllowDebugChange == False) {
		int old_debuglevel_class[DBGC_LAST];

		/* save current debug level */
		memcpy(old_debuglevel_class, DEBUGLEVEL_CLASS, sizeof(DEBUGLEVEL_CLASS));
		if (debug_parse_params(params, debuglevel_class))
			memcpy(parsed_debuglevel_class, debuglevel_class, sizeof(DEBUGLEVEL_CLASS));
		memcpy(DEBUGLEVEL_CLASS, old_debuglevel_class, sizeof(old_debuglevel_class));
		return True;
	}
	if (debug_parse_params(params, debuglevel_class)) {
		debug_message(MSG_DEBUG, getpid(), (void*)debuglevel_class, sizeof(debuglevel_class));
		return True;
	} else
		return False;
}
Пример #2
0
/*************************************************************
 Utility function to prompt for new password.
*************************************************************/
static char *prompt_for_new_password(bool stdin_get)
{
	char *p;
	fstring new_pw;

	ZERO_ARRAY(new_pw);

	p = get_pass("New SMB password:"******"Retype new SMB password:"******"Mismatch - password unchanged.\n");
		ZERO_ARRAY(new_pw);
		SAFE_FREE(p);
		return NULL;
	}

	return p;
}
Пример #3
0
void on_wat_con_ind(unsigned char span_id, uint8_t call_id, wat_con_event_t *con_event)
{
	//fprintf(stdout, "s%d: Incoming call (id:%d) Calling Number:%s  Calling Name:\"%s\" type:%d plan:%d\n", span_id, call_id, con_event->calling_num.digits, con_event->calling_name, con_event->calling_num.type, con_event->calling_num.plan);
	
	ftdm_log(FTDM_LOG_INFO, "s%d: Incoming call (id:%d) Calling Number:%s  Calling Name:\"%s\" type:%d plan:%d\n", span_id, call_id, con_event->calling_num.digits, con_event->calling_name, con_event->calling_num.type, con_event->calling_num.plan);
	
	ftdm_span_t *span = NULL;
	//ftdm_status_t ftdm_status = FTDM_FAIL;
	ftdm_gsm_span_data_t *gsm_data = NULL;

	if(!(span = GetSpanByID(span_id, &gsm_data))) {
		return;
	}	  

	gsm_data->call_id = call_id;			
	
	#define ZERO_ARRAY(arr) memset(arr, 0, sizeof(arr))
	// cid date
	{
		time_t t;
		struct tm *tmp;
		t = time(NULL);
		tmp = localtime(&t);
		if (tmp == NULL) {
			ZERO_ARRAY(gsm_data->bchan->caller_data.cid_date);
			strftime(gsm_data->bchan->caller_data.cid_date, sizeof(gsm_data->bchan->caller_data.cid_date), "%y/%m/%d", tmp);
		}

	}

	// cid name
	ZERO_ARRAY(gsm_data->bchan->caller_data.cid_name);
	strncpy(gsm_data->bchan->caller_data.cid_name, con_event->calling_name,sizeof(gsm_data->bchan->caller_data.cid_name));

	// dnis
	ZERO_ARRAY(gsm_data->bchan->caller_data.dnis.digits);
	strncpy(gsm_data->bchan->caller_data.dnis.digits, con_event->calling_num.digits, FTDM_DIGITS_LIMIT);
	
	//collected
	ZERO_ARRAY(gsm_data->bchan->caller_data.collected);
	strncpy(gsm_data->bchan->caller_data.collected, con_event->calling_num.digits, FTDM_DIGITS_LIMIT);
	
	ftdm_set_state(gsm_data->bchan, FTDM_CHANNEL_STATE_RING);

	if (ftdm_channel_open_chan(gsm_data->bchan) != FTDM_SUCCESS) {
		ftdm_log_chan(gsm_data->bchan, FTDM_LOG_ERROR, "Failed to open GSM b-channel of span %s!\n", span->name);
	}
	
}
Пример #4
0
int smbd_gpfs_set_times_path(char *path, struct smb_file_time *ft)
{
	gpfs_timestruc_t gpfs_times[4];
	int flags = 0;
	int rc;

	if (!gpfs_set_times_path_fn) {
		errno = ENOSYS;
		return -1;
	}

	ZERO_ARRAY(gpfs_times);
	timespec_to_gpfs_time(ft->atime, gpfs_times, 0, &flags);
	timespec_to_gpfs_time(ft->mtime, gpfs_times, 1, &flags);
	/* No good mapping from LastChangeTime to ctime, not storing */
	timespec_to_gpfs_time(ft->create_time, gpfs_times, 3, &flags);

	if (!flags) {
		DEBUG(10, ("nothing to do, return to avoid EINVAL\n"));
		return 0;
	}

	rc = gpfs_set_times_path_fn(path, flags, gpfs_times);

	if (rc != 0) {
		DEBUG(1,("gpfs_set_times() returned with error %s\n",
			strerror(errno)));
	}

	return rc;
}
Пример #5
0
AudioManager::AudioManager()
{
	// Initialize fields.

		Initialized = false;
		SystemInstance = nullptr;
		ZERO_ARRAY( ChannelGroups );
}
Пример #6
0
/* return the pid in a pidfile. return 0 if the process (or pidfile)
   does not exist */
pid_t pidfile_pid(const char *name)
{
	int fd;
	char pidstr[20];
	pid_t pid;
	unsigned int ret;
	char * pidFile;

	if (asprintf(&pidFile, "%s/%s.pid", lp_piddir(), name) == -1) {
		return 0;
	}

	fd = sys_open(pidFile, O_NONBLOCK | O_RDONLY, 0644);
	if (fd == -1) {
		SAFE_FREE(pidFile);
		return 0;
	}

	ZERO_ARRAY(pidstr);

	if (read(fd, pidstr, sizeof(pidstr)-1) <= 0) {
		goto noproc;
	}

	ret = atoi(pidstr);

	if (ret == 0) {
		/* Obviously we had some garbage in the pidfile... */
		DEBUG(1, ("Could not parse contents of pidfile %s\n",
			  pidFile));
		goto noproc;
	}
	
	pid = (pid_t)ret;
	if (!process_exists_by_pid(pid)) {
		goto noproc;
	}

	if (fcntl_lock(fd,SMB_F_SETLK,0,1,F_RDLCK)) {
		/* we could get the lock - it can't be a Samba process */
		goto noproc;
	}

	SAFE_FREE(pidFile);
	close(fd);
	return (pid_t)ret;

 noproc:
	close(fd);
	unlink(pidFile);
	SAFE_FREE(pidFile);
	return 0;
}
Пример #7
0
static void send_message(void)
{
	int total_len = 0;
	int grp_id;

	if (!cli_message_start(cli, desthost, username, &grp_id)) {
		d_printf("message start: %s\n", cli_errstr(cli));
		return;
	}


	d_printf("Connected. Type your message, ending it with a Control-D\n");

	while (!feof(stdin) && total_len < 1600) {
		int maxlen = MIN(1600 - total_len,127);
		pstring msg;
		int l=0;
		int c;

		ZERO_ARRAY(msg);

		for (l=0;l<maxlen && (c=fgetc(stdin))!=EOF;l++) {
			if (c == '\n')
				msg[l++] = '\r';
			msg[l] = c;   
		}

		if (!cli_message_text(cli, msg, l, grp_id)) {
			d_printf("SMBsendtxt failed (%s)\n",cli_errstr(cli));
			return;
		}      
		
		total_len += l;
	}

	if (total_len >= 1600)
		d_printf("the message was truncated to 1600 bytes\n");
	else
		d_printf("sent %d bytes\n",total_len);

	if (!cli_message_end(cli, grp_id)) {
		d_printf("SMBsendend failed (%s)\n",cli_errstr(cli));
		return;
	}      
}
Пример #8
0
/*************************************************************
 Utility function to prompt for passwords from stdin. Each
 password entered must end with a newline.
*************************************************************/
char *stdin_new_passwd( void)
{
	static fstring new_pw;
	size_t len;

	ZERO_ARRAY(new_pw);

	/*
	 * if no error is reported from fgets() and string at least contains
	 * the newline that ends the password, then replace the newline with
	 * a null terminator.
	 */
	if ( fgets(new_pw, sizeof(new_pw), stdin) == NULL) {
		return NULL;
	}
	if ((len = strlen(new_pw)) > 0) {
		if(new_pw[len-1] == '\n')
			new_pw[len - 1] = 0;
	}
	return(new_pw);
}
Пример #9
0
/*
   basic testing of SMB2 shadow copy calls
*/
static bool test_ioctl_get_shadow_copy(struct torture_context *torture,
				       struct smb2_tree *tree)
{
	struct smb2_handle h;
	uint8_t buf[100];
	NTSTATUS status;
	union smb_ioctl ioctl;
	TALLOC_CTX *tmp_ctx = talloc_new(tree);

	smb2_util_unlink(tree, FNAME);

	status = torture_smb2_testfile(tree, FNAME, &h);
	if (!NT_STATUS_IS_OK(status)) {
		printf("create write\n");
		return false;
	}

	ZERO_ARRAY(buf);
	status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));
	if (!NT_STATUS_IS_OK(status)) {
		printf("failed write\n");
		return false;
	}

	ZERO_STRUCT(ioctl);
	ioctl.smb2.level = RAW_IOCTL_SMB2;
	ioctl.smb2.in.file.handle = h;
	ioctl.smb2.in.function = SMB2_FSCTL_SRV_ENUM_SNAPS;
	ioctl.smb2.in.max_response_size = 16;
	ioctl.smb2.in.flags = SMB2_IOCTL_FLAG_IS_FSCTL;

	status = smb2_ioctl(tree, tmp_ctx, &ioctl.smb2);
	if (!NT_STATUS_IS_OK(status)) {
		printf("SMB2_FSCTL_SRV_ENUM_SNAPS failed\n");
		return false;
	}

	return true;
}
Пример #10
0
//--------------------------------------------------------------------------------
GFSDK::SSAO::RandomTexture::RandomTexture()
    : m_pTexture(NULL)
{
    ZERO_ARRAY(m_pSRVs);

    UINT RandomNumberIndex = 0;
    for (UINT i = 0; i < ARRAYSIZE(m_JittersFP32x4); ++i)
    {
        float Rand1 = GetRandomNumber(RandomNumberIndex++);
        float Rand2 = GetRandomNumber(RandomNumberIndex++);
        float Rand3 = GetRandomNumber(RandomNumberIndex++);

        // Use random rotation angles in [0,2PI/NUM_DIRECTIONS)
        float Angle = 2.f * D3DX_PI * Rand1 / NUM_DIRECTIONS;
        m_JittersFP32x4[i].x = cosf(Angle);
        m_JittersFP32x4[i].y = sinf(Angle);
        m_JittersFP32x4[i].z = Rand2;
        m_JittersFP32x4[i].w = Rand3;

        // Convert from R32G32B32A32_FLOAT to R16G16B16A16_SNORM
        m_JittersINT16x4[i] = int16x4(m_JittersFP32x4[i]);
    }
}
Пример #11
0
 void IndividualHumanMalaria::ResetClinicalSymptoms()
 {
     ZERO_ARRAY(m_clinical_symptoms);
 }
Пример #12
0
int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute, 
		 void (*fn)(const char *, file_info *, const char *, void *), void *state)
{
	char *p;
	int received = 0;
	BOOL first = True;
	char status[21];
	int num_asked = (cli->max_xmit - 100)/DIR_STRUCT_SIZE;
	int num_received = 0;
	int i;
	char *dirlist = NULL;
	pstring mask;
	
	ZERO_ARRAY(status);

	pstrcpy(mask,Mask);
  
	while (1) {
		memset(cli->outbuf,'\0',smb_size);
		memset(cli->inbuf,'\0',smb_size);

		set_message(cli->outbuf,2,0,True);

		SCVAL(cli->outbuf,smb_com,SMBsearch);

		SSVAL(cli->outbuf,smb_tid,cli->cnum);
		cli_setup_packet(cli);

		SSVAL(cli->outbuf,smb_vwv0,num_asked);
		SSVAL(cli->outbuf,smb_vwv1,attribute);
  
		p = smb_buf(cli->outbuf);
		*p++ = 4;
      
		p += clistr_push(cli, p, first?mask:"", -1, STR_TERMINATE);
		*p++ = 5;
		if (first) {
			SSVAL(p,0,0);
			p += 2;
		} else {
			SSVAL(p,0,21);
			p += 2;
			memcpy(p,status,21);
			p += 21;
		}

		cli_setup_bcc(cli, p);
		cli_send_smb(cli);
		if (!cli_receive_smb(cli)) break;

		received = SVAL(cli->inbuf,smb_vwv0);
		if (received <= 0) break;

		first = False;

		dirlist = (char *)SMB_REALLOC(
			dirlist,(num_received + received)*DIR_STRUCT_SIZE);
		if (!dirlist) {
			DEBUG(0,("cli_list_old: failed to expand dirlist"));
			return 0;
		}

		p = smb_buf(cli->inbuf) + 3;

		memcpy(dirlist+num_received*DIR_STRUCT_SIZE,
		       p,received*DIR_STRUCT_SIZE);
		
		memcpy(status,p + ((received-1)*DIR_STRUCT_SIZE),21);
		
		num_received += received;
		
		if (cli_is_error(cli)) break;
	}

	if (!first) {
		memset(cli->outbuf,'\0',smb_size);
		memset(cli->inbuf,'\0',smb_size);

		set_message(cli->outbuf,2,0,True);
		SCVAL(cli->outbuf,smb_com,SMBfclose);
		SSVAL(cli->outbuf,smb_tid,cli->cnum);
		cli_setup_packet(cli);

		SSVAL(cli->outbuf, smb_vwv0, 0); /* find count? */
		SSVAL(cli->outbuf, smb_vwv1, attribute);

		p = smb_buf(cli->outbuf);
		*p++ = 4;
		fstrcpy(p, "");
		p += strlen(p) + 1;
		*p++ = 5;
		SSVAL(p, 0, 21);
		p += 2;
		memcpy(p,status,21);
		p += 21;
		
		cli_setup_bcc(cli, p);
		cli_send_smb(cli);
		if (!cli_receive_smb(cli)) {
			DEBUG(0,("Error closing search: %s\n",cli_errstr(cli)));
		}
	}

	for (p=dirlist,i=0;i<num_received;i++) {
		file_info finfo;
		p += interpret_short_filename(cli, p,&finfo);
		fn("\\", &finfo, Mask, state);
	}

	SAFE_FREE(dirlist);
	return(num_received);
}
Пример #13
0
/****************************************************************************
do command
****************************************************************************/
static BOOL do_command(char *dest, char *msg_name, int iparams, char **params)
{
	int i, n, v;
	int mtype;
	BOOL retval=False;
	int debuglevel_class[DBGC_LAST];

	mtype = parse_type(msg_name);
	if (mtype == -1) {
		fprintf(stderr,"Couldn't resolve message type: %s\n", msg_name);
		return(False);
	}

	switch (mtype) {
	case MSG_DEBUG:
		if (!params || !params[0]) {
			fprintf(stderr,"MSG_DEBUG needs a parameter\n");
			return(False);
		}

		ZERO_ARRAY(debuglevel_class);
		if (!debug_parse_params(params, debuglevel_class)) {
			fprintf(stderr, "MSG_DEBUG error. Expected <class name>:level\n");
			return(False);
		} else
			send_message(dest, MSG_DEBUG, debuglevel_class, sizeof(debuglevel_class), False);
		break;

	case MSG_PROFILE:
		if (!params || !params[0]) {
			fprintf(stderr,"MSG_PROFILE needs a parameter\n");
			return(False);
		}
		if (strequal(params[0], "off")) {
			v = 0;
		} else if (strequal(params[0], "count")) {
			v = 1;
		} else if (strequal(params[0], "on")) {
			v = 2;
		} else if (strequal(params[0], "flush")) {
			v = 3;
		} else {
		    fprintf(stderr,
			"MSG_PROFILE parameter must be off, count, on, or flush\n");
		    return(False);
		}
		send_message(dest, MSG_PROFILE, &v, sizeof(int), False);
		break;

	case MSG_FORCE_ELECTION:
		if (!strequal(dest, "nmbd")) {
			fprintf(stderr,"force-election can only be sent to nmbd\n");
			return(False);
		}
		send_message(dest, MSG_FORCE_ELECTION, NULL, 0, False);
		break;

	case MSG_REQ_PROFILELEVEL:
		if (!profilelevel_registered) {
		    message_register(MSG_PROFILELEVEL, profilelevel_function);
		    profilelevel_registered = True;
		}
		got_level = False;
		retval = send_message(dest, MSG_REQ_PROFILELEVEL, NULL, 0, True);
		if (retval) {
			timeout_start = time(NULL);
			while (!got_level) {
				message_dispatch();
				if ((time(NULL) - timeout_start) > MAX_WAIT) {
					fprintf(stderr,"profilelevel timeout\n");
					break;
				}
			}
		}
		break;

	case MSG_REQ_DEBUGLEVEL:
		if (!debuglevel_registered) {
		    message_register(MSG_DEBUGLEVEL, debuglevel_function);
		    debuglevel_registered = True;
		}
		got_level = False;
		retval = send_message(dest, MSG_REQ_DEBUGLEVEL, NULL, 0, True);
		if (retval) {
			timeout_start = time(NULL);
			while (!got_level) {
				message_dispatch();
				if ((time(NULL) - timeout_start) > MAX_WAIT) {
					fprintf(stderr,"debuglevel timeout\n");
					break;
				}
			}
		}
		break;

	case MSG_PRINTER_NOTIFY:
		if (!strequal(dest, "smbd")) {
			fprintf(stderr,"printer-notify can only be sent to smbd\n");
			return(False);
		}
		if (!params || !params[0]) {
			fprintf(stderr, "printer-notify needs a printer name\n");
			return (False);
		}
		{
			char msg[8 + sizeof(fstring)+4];
			SIVAL(msg,0,PRINTER_CHANGE_ALL);
			SIVAL(msg,4,0);
			fstrcpy(&msg[8], params[0]);
			SIVAL(msg,8+strlen(params[0])+1, PRINTER_MESSAGE_DRIVER);

			retval = send_message(dest, MSG_PRINTER_NOTIFY, msg, 8 + strlen(params[0]) + 1 + 4, False);
		}
		break;

	case MSG_SMB_FORCE_TDIS:
		if (!strequal(dest, "smbd")) {
			fprintf(stderr,"close-share can only be sent to smbd\n");
			return(False);
		}
		if (!params || !params[0]) {
			fprintf(stderr, "close-share needs a share name or '*'\n");
			return (False);
		}
		retval = send_message(dest, MSG_SMB_FORCE_TDIS, params[0],
				      strlen(params[0]) + 1, False);
		break;

	case MSG_PING:
		if (!pong_registered) {
		    message_register(MSG_PONG, pong_function);
		    pong_registered = True;
		}
		if (!params || !params[0]) {
			fprintf(stderr,"MSG_PING needs a parameter\n");
			return(False);
		}
		n = atoi(params[0]);
		pong_count = 0;
		for (i=0;i<n;i++) {
			if (iparams > 1)
				retval = send_message(dest, MSG_PING, params[1], strlen(params[1]) + 1, True);
			else
				retval = send_message(dest, MSG_PING, NULL, 0, True);
			if (retval == False) break;
		}
		if (retval) {
			timeout_start = time(NULL);
			while (pong_count < n) {
				message_dispatch();
				if ((time(NULL) - timeout_start) > MAX_WAIT) {
					fprintf(stderr,"PING timeout\n");
					break;
				}
			}
		}
		break;

	}
	
	return (True);
}
Пример #14
0
/* return the pid in a pidfile. return 0 if the process (or pidfile)
   does not exist */
pid_t pidfile_pid(const char *program_name)
{
	int fd;
	char pidstr[20];
	pid_t pid;
	unsigned int ret;
	char *name;
	const char *short_configfile;
	char * pidFile;

	/* Add a suffix to the program name if this is a process with a
	 * none default configuration file name. */
	if (strcmp( CONFIGFILE, get_dyn_CONFIGFILE()) == 0) {
		name = SMB_STRDUP(program_name);
	} else {
		short_configfile = strrchr( get_dyn_CONFIGFILE(), '/');
		if (short_configfile == NULL) {
			/* conf file in current directory */
			short_configfile = get_dyn_CONFIGFILE();
		} else {
			/* full/relative path provided */
			short_configfile++;
		}
		if (asprintf(&name, "%s-%s", program_name,
				short_configfile) == -1) {
			smb_panic("asprintf failed");
		}
	}

	if (asprintf(&pidFile, "%s/%s.pid", lp_piddir(), name) == -1) {
		SAFE_FREE(name);
		return 0;
	}

	SAFE_FREE(name);

	fd = open(pidFile, O_NONBLOCK | O_RDONLY, 0644);
	if (fd == -1) {
		SAFE_FREE(pidFile);
		return 0;
	}

	ZERO_ARRAY(pidstr);

	if (read(fd, pidstr, sizeof(pidstr)-1) <= 0) {
		goto noproc;
	}

	ret = atoi(pidstr);

	if (ret == 0) {
		/* Obviously we had some garbage in the pidfile... */
		DEBUG(1, ("Could not parse contents of pidfile %s\n",
			  pidFile));
		goto noproc;
	}
	
	pid = (pid_t)ret;
	if (!process_exists_by_pid(pid)) {
		goto noproc;
	}

	if (fcntl_lock(fd,F_SETLK,0,1,F_RDLCK)) {
		/* we could get the lock - it can't be a Samba process */
		goto noproc;
	}

	SAFE_FREE(pidFile);
	close(fd);
	return (pid_t)ret;

 noproc:
	close(fd);
	unlink(pidFile);
	SAFE_FREE(pidFile);
	return 0;
}
Пример #15
0
static BOOL ads_keytab_verify_ticket(krb5_context context,
					krb5_auth_context auth_context,
					const DATA_BLOB *ticket,
					krb5_ticket **pp_tkt,
					krb5_keyblock **keyblock,
					krb5_error_code *perr)
{
	krb5_error_code ret = 0;
	BOOL auth_ok = False;
	krb5_keytab keytab = NULL;
	krb5_kt_cursor kt_cursor;
	krb5_keytab_entry kt_entry;
	char *valid_princ_formats[9];
	fstring my_name, my_fqdn;
	int i;

	const char * lkdc_realm = lp_parm_talloc_string(GLOBAL_SECTION_SNUM,
					"com.apple", "lkdc realm", NULL);

	ZERO_ARRAY(valid_princ_formats);

	*pp_tkt = NULL;
	*keyblock = NULL;
	*perr = 0;

	/* Generate the list of principal names which we expect
	 * clients might want to use for authenticating to the file
	 * service.  We allow name$,{host,cifs}/{name,fqdn,name.REALM}. */

	fstrcpy(my_name, global_myname());

	my_fqdn[0] = '\0';
	get_mydnsfullname(my_fqdn);

	asprintf(&valid_princ_formats[0], "%s$@%s", my_name, lp_realm());
	asprintf(&valid_princ_formats[1], "host/%s@%s", my_name, lp_realm());
	asprintf(&valid_princ_formats[2], "host/%s@%s", my_fqdn, lp_realm());
	asprintf(&valid_princ_formats[3], "host/%s.%s@%s", my_name, lp_realm(), lp_realm());
	asprintf(&valid_princ_formats[4], "cifs/%s@%s", my_name, lp_realm());
	asprintf(&valid_princ_formats[5], "cifs/%s@%s", my_fqdn, lp_realm());
	asprintf(&valid_princ_formats[6], "cifs/%s.%s@%s", my_name, lp_realm(), lp_realm());

	if (lkdc_realm) {
		asprintf(&valid_princ_formats[7],
			"host/%s@%s", lkdc_realm, lkdc_realm);
		asprintf(&valid_princ_formats[8],
			"cifs/%s@%s", lkdc_realm, lkdc_realm);
	}

	for (i = 0; i < ARRAY_SIZE(valid_princ_formats); i++) {

		ZERO_STRUCT(kt_entry);
		ZERO_STRUCT(kt_cursor);

		ret = krb5_kt_default(context, &keytab);
		if (ret) {
			DEBUG(1, ("ads_keytab_verify_ticket: krb5_kt_default failed (%s)\n", error_message(ret)));
			goto out;
		}

		/* Iterate through the keytab.  For each key, if the principal
		 * name case-insensitively matches one of the allowed formats,
		 * try verifying the ticket using that principal.
		 */

		ret = krb5_kt_start_seq_get(context, keytab, &kt_cursor);
		if (ret) {
			DEBUG(1, ("ads_keytab_verify_ticket: krb5_kt_start_seq_get failed (%s)\n", error_message(ret)));
			goto out;
		}

		while (!auth_ok && (krb5_kt_next_entry(context, keytab, &kt_entry, &kt_cursor) == 0)) {

			/* In MIT Kerberos, it is not legal to interleave krb5_rd_req()
			 * with krb5_kt_start_seq_get() and krb5_kt_end_seq_get() on the
			 * same krb5_keytab object. We have to keep a separate
			 * krb5_keytab object around for the krb5_rd_req().
			 */
			ret = ads_keytab_verify_for_principal(context,
				auth_context, &kt_entry, ticket,
				valid_princ_formats[i], pp_tkt, keyblock);

			if (ret == 0) {
				auth_ok = True;
			}

			/* Free the entry we just read. */
			smb_krb5_kt_free_entry(context, &kt_entry);
			ZERO_STRUCT(kt_entry);

			if (auth_ok) {
				/* success, let's go. */
				break;
			}

			/* workaround for MIT:
			* as krb5_ktfile_get_entry will explicitly
			* close the krb5_keytab as soon as krb5_rd_req
			* has sucessfully decrypted the ticket but the
			* ticket is not valid yet (due to clockskew)
			* there is no point in querying more keytab
			* entries - Guenther */
			if (ret == KRB5KRB_AP_ERR_TKT_NYV ||
			    ret == KRB5KRB_AP_ERR_TKT_EXPIRED ||
			    ret == KRB5KRB_AP_ERR_SKEW ||
			    ret == KRB5KRB_AP_ERR_REPEAT) {
			    break;
			}

		}

		krb5_kt_end_seq_get(context, keytab, &kt_cursor);
		krb5_kt_close(context, keytab);
		keytab = NULL;
	}

	ZERO_STRUCT(kt_cursor);

out:

	TALLOC_FREE(lkdc_realm);

	for (i = 0; i < ARRAY_SIZE(valid_princ_formats); i++) {
		SAFE_FREE(valid_princ_formats[i]);
	}

	{
		krb5_keytab_entry zero_kt_entry;
		ZERO_STRUCT(zero_kt_entry);
		if (memcmp(&zero_kt_entry, &kt_entry, sizeof(krb5_keytab_entry))) {
			smb_krb5_kt_free_entry(context, &kt_entry);
		}
	}

	{
		krb5_kt_cursor zero_csr;
		ZERO_STRUCT(zero_csr);
		if ((memcmp(&kt_cursor, &zero_csr, sizeof(krb5_kt_cursor)) != 0) && keytab) {
			krb5_kt_end_seq_get(context, keytab, &kt_cursor);
		}
	}

	if (keytab) {
		krb5_kt_close(context, keytab);
	}
	*perr = ret;
	return auth_ok;
}
Пример #16
0
int vscan_send_warning_message(const char *filename, const char *virname, const char *ipaddr) {
    struct in_addr ip;
    struct sockaddr_storage ss;

        struct nmb_name called, calling;
	pstring myname;
	pstring message;
	pstring shortfilename;
	char* lastslash;

	static pstring lastfile;
	static pstring lastip;

	#if SAMBA_VERSION_MAJOR==3
	fstrcpy(remote_machine, get_remote_machine_name());
	DEBUG(5, ("remote machine is: %s\n", remote_machine));
	#endif

	/* Only notify once for a given virus/ip combo - otherwise the
	 * scanner will go crazy reaccessing the file and sending
	 * messages once the user hits the "okay" button */
	if (strncmp(lastfile,filename,sizeof(pstring)) == 0) {
		if (strncmp(lastip,ipaddr,sizeof(pstring)) == 0) {
			DEBUG(5,("Both IP and Filename are the same, not notifying\n"));
			return 0;
		}
	}

	ZERO_ARRAY(lastfile);
	ZERO_ARRAY(lastip);
	pstrcpy(lastfile,filename);
	pstrcpy(lastip,ipaddr);

	ZERO_ARRAY(myname);
	pstrcpy(myname,myhostname());

	ZERO_ARRAY(username);
	/* could make this configurable */
	snprintf(username,sizeof(pstring)-1,"%s VIRUS SCANNER",myname);

	/* We need to get the real ip structure from the ip string
	 * is this info already available somewhere else in samba? */
       	zero_ip_v4(&ip);
	if (inet_aton(ipaddr,&ip) == 0) {
               	DEBUG(5,("Cannot resolve ip address %s\n", ipaddr));
               	return 1;
	}
    in_addr_to_sockaddr_storage(&ss, ip);


       	make_nmb_name(&calling, myname, 0x0);
       	make_nmb_name(&called , remote_machine, name_type);

	 if (!(cli=cli_initialise())) {
               	DEBUG(5,("Connection to %s failed\n", remote_machine));
               	return 1;
       	}
        cli_set_port(cli, port);
     if (!NT_STATUS_IS_OK(cli_connect(cli, remote_machine, &ss))) {
               	DEBUG(5,("Connection to %s failed\n", remote_machine));
               	return 1;
    }

       	if (!cli_session_request(cli, &calling, &called)) {
               	DEBUG(5,("session request failed\n"));
               	cli_shutdown(cli);
               	return 1;
       	}

	ZERO_ARRAY(shortfilename);
	/* we don't want the entire filename, otherwise the message service may choke
	 * so we chop off the path up to the very last forward-slash
	 * assumption: unix-style pathnames in filename (don't know if there's a
	 * portable file-separator variable... */
	lastslash = strrchr(filename,'/');
	if (lastslash != NULL && lastslash != filename) {
		pstrcpy(shortfilename,lastslash+1);
	} else {
		pstrcpy(shortfilename,filename);
	}

	ZERO_ARRAY(message);
	/* could make the message configurable and language specific? */
	snprintf(message,sizeof(pstring)-1,
		"%s IS INFECTED WITH VIRUS  %s.\r\n\r\nAccess will be denied.\r\nPlease contact your system administrator",
		shortfilename, virname);

	/* actually send the message... */
       	send_message(message);

       	cli_shutdown(cli);
	
        return 0;
}
Пример #17
0
/**
 * Write backtrace to debug log
 */
_PUBLIC_ void call_backtrace(void)
{
#ifdef HAVE_BACKTRACE
#ifndef BACKTRACE_STACK_SIZE
#define BACKTRACE_STACK_SIZE 64
#endif
	void *backtrace_stack[BACKTRACE_STACK_SIZE];
	size_t backtrace_size;
	char **backtrace_strings;

	/* get the backtrace (stack frames) */
	backtrace_size = backtrace(backtrace_stack,BACKTRACE_STACK_SIZE);
	backtrace_strings = backtrace_symbols(backtrace_stack, backtrace_size);

	DEBUG(0, ("BACKTRACE: %lu stack frames:\n", 
		  (unsigned long)backtrace_size));
	
	if (backtrace_strings) {
		int i;

		for (i = 0; i < backtrace_size; i++)
			DEBUGADD(0, (" #%u %s\n", i, backtrace_strings[i]));

		/* Leak the backtrace_strings, rather than risk what free() might do */
	}

#elif HAVE_LIBEXC

#define NAMESIZE 32 /* Arbitrary */
#ifndef BACKTRACE_STACK_SIZE
#define BACKTRACE_STACK_SIZE 64
#endif

	/* The IRIX libexc library provides an API for unwinding the stack. See
	 * libexc(3) for details. Apparantly trace_back_stack leaks memory, but
	 * since we are about to abort anyway, it hardly matters.
	 *
	 * Note that if we paniced due to a SIGSEGV or SIGBUS (or similar) this
	 * will fail with a nasty message upon failing to open the /proc entry.
	 */
	{
		uint64_t	addrs[BACKTRACE_STACK_SIZE];
		char *      	names[BACKTRACE_STACK_SIZE];
		char		namebuf[BACKTRACE_STACK_SIZE * NAMESIZE];

		int		i;
		int		levels;

		ZERO_ARRAY(addrs);
		ZERO_ARRAY(names);
		ZERO_ARRAY(namebuf);

		for (i = 0; i < BACKTRACE_STACK_SIZE; i++) {
			names[i] = namebuf + (i * NAMESIZE);
		}

		levels = trace_back_stack(0, addrs, names,
				BACKTRACE_STACK_SIZE, NAMESIZE);

		DEBUG(0, ("BACKTRACE: %d stack frames:\n", levels));
		for (i = 0; i < levels; i++) {
			DEBUGADD(0, (" #%d 0x%llx %s\n", i, addrs[i], names[i]));
		}
     }
#undef NAMESIZE
#else
	DEBUG(0, ("call_backstrace: not implemented\n"));
#error bla
#endif
}
Пример #18
0
int
main(void)
{
    /* Zero an array. */
    {
        double d[2];
        d[0] = 1.0;
        d[1] = 2.0;
        ZERO_ARRAY(d); /* Pass pointer to array. */
        printf("d[0]    = %f\n", d[0]);
        printf("d[1]    = %f\n", d[1]);
        printf("\n");
    }

    /* Zero a struct. */
    {
        struct stuff st;
        st.d[0]   = 1.0;
        st.d[1]   = 2.0;
        st.str[0] = 'O';
        st.str[1] = 'K';
        st.str[2] = '\n';
        st.str[3] = '\0';
        st.x      = -5;
        ZERO_STRUCT(&st); /* Pass pointer to struct. */
        printf("st.d[0] = %f\n",     st.d[0]);
        printf("st.d[1] = %f\n",     st.d[1]);
        printf("st.str  = \"%s\"\n", st.str);
        printf("st.x    = %d\n",     st.x);
        printf("\n");
    }

    /* Count array length. */
    {
        double d[3];
        printf("length  = %d\n", COUNT_ARRAY(d));
        printf("\n");
    }

    /* Test maximum. */
    {
        int a = 4;
        int b = 5;
        printf("max     = %d\n", MAX(a, b));
        printf("max     = %d\n", MAX(b, a));
        printf("\n");
    }

    /* Test strcmp. */
    {
        char a[] = "ab";
        char b[] = "abd";
        printf("strcmp  = %d\n", strcmp(a, b));
        printf("\n");
    }

    /* Test strlen. */
    {
        char a[] = "ab\n";
        char b[] = "";
        printf("strlen  = %d\n", strlen(a)); /* = 3 */
        printf("strlen  = %d\n", strlen(b)); /* = 0 */
        printf("\n");
    }

    /* Test strcpy. */
    {
        char dst[20] = "";
        char src[20] = "baba";
        printf("strcpy  = %s\n", strcpy(dst, src));
        printf("\n");
    }

    /* Test memset. */
    {
        char dst[20] = "";
        printf("memset  = %s\n", (char *)memset(dst, 97, sizeof(dst)-1));
        printf("\n");
    }

    /* Test FILL_ARRAY. */
    {
        int arr[2];
        size_t i = 0;
        uint8_t *byte = (uint8_t *)arr;
        FILL_ARRAY(arr, 0xba);
        printf("arr[0]  = %d\n", arr[0]);
        printf("arr[1]  = %d\n", arr[1]);
        for (i = 0; i < sizeof(arr); ++i)
        {
            printf("arr as byte[%d]  = 0x%x\n", i, *byte++);
        }
        printf("\n");
    }

    /* Test atoi. */
    {
        char str[] = "0123456789";
        char str1[] = "-489";
        char str2[] = "  9 white space";
        char str3[] = "--5";
        char str4[] = "";
        printf("%s = %d\n", str, atoi(str));
        printf("%s = %d\n", str1, atoi(str1));
        printf("%s = %d\n", str2, atoi(str2));
        printf("%s = %d\n", str3, atoi(str3));
        printf("%s = %d\n", str4, atoi(str4));
        printf("\n");
    }

    /* Test strchar. */
    {
        char str[] = "0123456789";
        printf("%s\n", strchr(str,'5'));
        printf("%s\n", strchr(str,'1'));
        printf("\n");
    }

    /* Test rand. */
    {
        size_t i = 0;
        for (i = 0; i < 5; ++i)
        {
            printf("rand() = %d\n", rand());
        }
        for (i = 0; i < 10; ++i)
        {
            printf("rand_between(1, 3) = %d\n", rand_between(1, 3));
        }
        while (rand() != 0)
        {
        }
        while (rand() != RAND_MAX)
        {
        }
        printf("\n");
    }

    return 0;
}
Пример #19
0
int ProAccumulateMis(char *Oper)
{
    int                i, nTotalNum = 0;
	uint               nRetLen;
    struct FileRecStru TmpFileRec;
    char               szBuffer[130];
    uchar              ucFd;
	char  szReadBuff[sizeof(struct FileRecStru)+1024];
	char               szAmount[20];
	int				   nCnt;

	BUFCLR(szBuffer);
    ZERO_ARRAY(gbStruSettleData);
	memset(gbInstalment,0x00,sizeof(gbInstalment));
	for(i=0;i<SETTLE_ITEM_NUM;i++)
		sprintf(gbStruSettleData[i].szAmount, "%012d", 0);

    if (PubFileOpen(WATERFILE, &ucFd) != NORMAL)
        ASSERT_NORMAL(EXCEPTION);

    for (i = 1;; i++)
    {
        ZERO_STRUCT(TmpFileRec);
        if (PubFileOper(ucFd, REC_READ, i, 1, szReadBuff, &nRetLen) != NORMAL)
            break;
		memcpy(&TmpFileRec, szReadBuff, sizeof(struct FileRecStru));

		if (TmpFileRec.cAdjustFlag == '*')  // 被调整和追加小费的交易不参与计算 linq
			continue; 

		//MIS新加的柜员号判断
// 		PubDisplay(2,"%02x %02x %02x %02x %02x %02x",TmpFileRec.szNEWOperNO[0]&0xff,TmpFileRec.szNEWOperNO[1]&0xff,TmpFileRec.szNEWOperNO[2]&0xff,TmpFileRec.szNEWOperNO[3]&0xff,TmpFileRec.szNEWOperNO[4]&0xff);
// 		PubDisplay(3,"%02x %02x %02x %02x %02x %02x",Oper[0]&0xff,Oper[1]&0xff,Oper[2]&0xff,Oper[3]&0xff,Oper[4]&0xff);
// 		PubuiInkey(0);
		if (memcmp(TmpFileRec.szNEWOperNO,Oper,strlen(TmpFileRec.szNEWOperNO)))
			continue;
	
		// 20110310 系统返回Z7后的统计,不包含脱机交易
		if (gbcHostRetZ7 == 1 && IsUploadTrans(&TmpFileRec) == YES) // 20110310 系统返回Z7后的统计,不包含脱机交易
			continue;

		// 根据测试组反馈,IC卡脱机成功未上送前就被撤消的交易,无需统计 -- 错误,应当统计,原因如下:
		/*
		 *  2009-07-23 中行最新规范4.48.2节有如下描述,表明IC卡脱机成功未上送前就被撤消的交易需要统计,但不上送。
		 *  未上送IST的脱机交易(例如还未上送的基于EMV标准的IC卡离线消费交易)
		 *  在POS端撤消后则原始交易和撤消交易都不需要再上送IST,
		 *  但需在POS端累计中体现出来(此时POS与IST对帐将不平)。
		 */
		/*******
		if (((TmpFileRec.cTransType == PURCHASE) && (TmpFileRec.cOfflineFlag == '*') && (TmpFileRec.cUploadFlag != '*') && (TmpFileRec.cCancelFlag == '*'))
			|| ((TmpFileRec.cTransType == POS_VOID) && (TmpFileRec.cOfflineFlag == '*') && (TmpFileRec.cUploadFlag != '*')))
		{
            continue;
		}
		********/
		BUFCLR(szAmount);
		strcpy(szAmount, TmpFileRec.szAmount);
		nCnt = 1;

		// 积分类交易,积分部分不区分卡种统计
		if (TmpFileRec.cTransType == POINT_PUR || TmpFileRec.cTransType == POINT_VOID || TmpFileRec.cTransType == POINT_REFUND )
		{
			strcpy(szAmount, TmpFileRec.szPointAmt);
			if (TmpFileRec.cTransType == POINT_PUR)
			{
				// 积分消费统计到积分借记20
				gbStruSettleData[20].num += nCnt;
				sprintf(szBuffer, "%12.12s", szAmount);
				PubStrAdd(gbStruSettleData[20].szAmount, szBuffer, gbStruSettleData[20].szAmount);
			}
			else
			{
				// 积分消费撤消/退货统计到积分贷记21
				gbStruSettleData[21].num += nCnt;
				sprintf(szBuffer, "%12.12s", szAmount);
				PubStrAdd(gbStruSettleData[21].szAmount, szBuffer, gbStruSettleData[21].szAmount);
			}
			nTotalNum += nCnt;
			
			// 纯积分交易无需统计现金部分
			if (TmpFileRec.cPointType == 0)				
				continue;

			// 如果是积分+现金,现金部分金额使用正常分卡种统计
			strcpy(szAmount, TmpFileRec.szPointAuth);
		}

		BUFCLR(szBuffer);		
        nTotalNum += nCnt;
        switch (TmpFileRec.cTransType)
        {
        case PRE_AUTH:
            gbStruSettleData[19].num += nCnt;
            sprintf(szBuffer, "%12.12s", szAmount);
			PubStrAdd(gbStruSettleData[19].szAmount, szBuffer, gbStruSettleData[19].szAmount);
            break;

			// 电子现金圈存类交易
		case EC_LOAD:			   // 指定账户圈存
		case EC_LOAD_U:			   // 非指定账户圈存
		case EC_LOAD_CASH:		   // 补登圈存
            gbStruSettleData[18].num += nCnt;
            sprintf(szBuffer, "%12.12s", szAmount);
			PubStrAdd(gbStruSettleData[18].szAmount, szBuffer, gbStruSettleData[18].szAmount);
			break;

        case INSTALMENT:
        case CASHBACK:
        case WITHDRAWAL:
		case AGENTIN:
		case AGENTOUT_VOID:        
        case PURCHASE:
        case MOTO:
        case CONFIRM:
		case CONFIRM_NOTICE:
        case OFFLINE_PUR:
        case POINT_PUR:
        case FEE:
        case ADJUST:
		case MOTO_INSTALMENT:
  
            gbStruSettleData[0].num += nCnt;
            sprintf(szBuffer, "%12.12s", szAmount);
			PubStrAdd(gbStruSettleData[0].szAmount, szBuffer, gbStruSettleData[0].szAmount);
#ifdef BJZYMIS
			if(TmpFileRec.cTransType == INSTALMENT)//分期付款消费
			{
				
				if(atoi(TmpFileRec.szCardId)/10 <= CARD_CUP_DEBIT/10)
				{
					gbInstalment[0][3].num += nCnt;
					PubStrAdd(gbInstalment[0][3].szAmount, szBuffer, gbInstalment[0][3].szAmount);
				}
				else
				{
					gbInstalment[1][3].num += nCnt;
					PubStrAdd(gbInstalment[1][3].szAmount, szBuffer, gbInstalment[1][3].szAmount);
					
				}
			}
			else
			{									   //普通消费
				if(atoi(TmpFileRec.szCardId)/10 <= CARD_CUP_DEBIT/10)
				{
					gbInstalment[0][0].num += nCnt;
					PubStrAdd(gbInstalment[0][0].szAmount, szBuffer, gbInstalment[0][0].szAmount);
				}
				else
				{
					gbInstalment[1][0].num += nCnt;
					PubStrAdd(gbInstalment[1][0].szAmount, szBuffer, gbInstalment[1][0].szAmount);
				}
			}
#endif
            switch (atoi(TmpFileRec.szCardId)/10)
            {
            case CARD_BOC_DEBIT/10:
				if (atoi(TmpFileRec.szCardId) == CARD_BOC_CREDIT || atoi(TmpFileRec.szCardId) == CARD_BOC_CREDIT_2)
				{
	                gbStruSettleData[3].num += nCnt;
		            sprintf(szBuffer, "%12.12s", szAmount);
					PubStrAdd(gbStruSettleData[3].szAmount, szBuffer, gbStruSettleData[3].szAmount);
                }
				else
				{
					gbStruSettleData[2].num += nCnt;
					sprintf(szBuffer, "%12.12s", szAmount);
					PubStrAdd(gbStruSettleData[2].szAmount, szBuffer, gbStruSettleData[2].szAmount);
                }
				break;
            case CARD_CUP_DEBIT/10:			
                gbStruSettleData[4].num += nCnt;
                sprintf(szBuffer, "%12.12s", szAmount);
                PubStrAdd(gbStruSettleData[4].szAmount, szBuffer, gbStruSettleData[4].szAmount);
				break;
            case CARD_VISA_DEBIT/10:
                gbStruSettleData[5].num += nCnt;
                sprintf(szBuffer, "%12.12s", szAmount);
                PubStrAdd(gbStruSettleData[5].szAmount, szBuffer, gbStruSettleData[5].szAmount);
				break;
            case CARD_MC_DEBIT/10:
                gbStruSettleData[6].num += nCnt;
                sprintf(szBuffer, "%12.12s", szAmount);
                PubStrAdd(gbStruSettleData[6].szAmount, szBuffer, gbStruSettleData[6].szAmount);
				break;
            case CARD_AE/10:
                gbStruSettleData[7].num += nCnt;
                sprintf(szBuffer, "%12.12s", szAmount);
                PubStrAdd(gbStruSettleData[7].szAmount, szBuffer, gbStruSettleData[7].szAmount);
				break;
            case CARD_DINERS/10:
                gbStruSettleData[8].num += nCnt;
                sprintf(szBuffer, "%12.12s", szAmount);
                PubStrAdd(gbStruSettleData[8].szAmount, szBuffer, gbStruSettleData[8].szAmount);
				break;
            case CARD_JCB/10:
                gbStruSettleData[9].num += nCnt;
                sprintf(szBuffer, "%12.12s", szAmount);
                PubStrAdd(gbStruSettleData[9].szAmount, szBuffer, gbStruSettleData[9].szAmount);
				break;
            default:
				// linq add 未正确取得卡类型的卡,统一记入银联卡,防止漏统计
				gbStruSettleData[4].num += nCnt;
                sprintf(szBuffer, "%12.12s", szAmount);
                PubStrAdd(gbStruSettleData[4].szAmount, szBuffer, gbStruSettleData[4].szAmount);
				break;
            }
            break;
        case REFUND:
        case MOTO_REFUND:
        case INSTALMENT_REFUND:
        case INSTALMENT_VOID:
        case CASHBACK_VOID:
        case CASHBACK_REFUND:
        case WITHDRAWAL_VOID:
		case AGENTOUT:  
		case AGENTIN_VOID:        
        case POS_VOID:
        case MOTO_VOID:
        case CONFIRM_VOID:
        case POINT_VOID:
        case POINT_REFUND:
        case OFFLINE_VOID:
		case OFFLINE_REFUND:
		case MOTO_INSTALMENT_VOID:
		case MOTO_INSTALMENT_REFUND:

            gbStruSettleData[1].num += nCnt;
            sprintf(szBuffer, "%12.12s", szAmount);
			PubStrAdd(gbStruSettleData[1].szAmount, szBuffer, gbStruSettleData[1].szAmount);
#ifdef BJZYMIS
			if(TmpFileRec.cTransType == INSTALMENT_VOID||TmpFileRec.cTransType ==INSTALMENT_REFUND)//分期付款贷记金额
			{
				if(TmpFileRec.cTransType == INSTALMENT_VOID)//分期付款撤销
				{
					if(atoi(TmpFileRec.szCardId)/10 <= CARD_CUP_DEBIT/10)
					{
						gbInstalment[0][4].num += nCnt;
						PubStrAdd(gbInstalment[0][4].szAmount, szBuffer, gbInstalment[0][4].szAmount);
					}
					else
					{
						gbInstalment[1][4].num += nCnt;
						PubStrAdd(gbInstalment[1][4].szAmount, szBuffer, gbInstalment[1][4].szAmount);
					}
				}
				else	// 分期付款退货
				{
					if(atoi(TmpFileRec.szCardId)/10 <= CARD_CUP_DEBIT/10)
					{
						gbInstalment[0][5].num += nCnt;
						PubStrAdd(gbInstalment[0][5].szAmount, szBuffer, gbInstalment[0][5].szAmount);
					}
					else
					{
						gbInstalment[1][5].num += nCnt;
						PubStrAdd(gbInstalment[1][5].szAmount, szBuffer, gbInstalment[1][5].szAmount);
					}
					
				}
			}
			else if(TmpFileRec.cTransType == POS_VOID||TmpFileRec.cTransType == REFUND)
			{	
				if(TmpFileRec.cTransType == POS_VOID)
				{
					if(atoi(TmpFileRec.szCardId)/10 <= CARD_CUP_DEBIT/10)
					{
						gbInstalment[0][1].num += nCnt;
						PubStrAdd(gbInstalment[0][1].szAmount, szBuffer, gbInstalment[0][1].szAmount);
					}
					else
					{
						gbInstalment[1][1].num += nCnt;
						PubStrAdd(gbInstalment[1][1].szAmount, szBuffer, gbInstalment[1][1].szAmount);
						
					}
				}
				else
				{
					if(atoi(TmpFileRec.szCardId)/10 <= CARD_CUP_DEBIT/10)
					{
						gbInstalment[0][2].num += nCnt;
						PubStrAdd(gbInstalment[0][2].szAmount, szBuffer, gbInstalment[0][2].szAmount);
					}
					else
					{
						gbInstalment[1][2].num += nCnt;
						PubStrAdd(gbInstalment[1][2].szAmount, szBuffer, gbInstalment[1][2].szAmount);
					}
				}
			}
#endif
            switch (atoi(TmpFileRec.szCardId)/10)
            {
            case CARD_BOC_DEBIT/10:
				if (atoi(TmpFileRec.szCardId) == CARD_BOC_CREDIT || atoi(TmpFileRec.szCardId) == CARD_BOC_CREDIT_2)
				{
					gbStruSettleData[11].num += nCnt;
					sprintf(szBuffer, "%12.12s", szAmount);
					PubStrAdd(gbStruSettleData[11].szAmount, szBuffer, gbStruSettleData[11].szAmount);
				}
				else
				{
					gbStruSettleData[10].num += nCnt;
					sprintf(szBuffer, "%12.12s", szAmount);
	                PubStrAdd(gbStruSettleData[10].szAmount, szBuffer, gbStruSettleData[10].szAmount);
				}
				break;

            case CARD_CUP_DEBIT/10:
                gbStruSettleData[12].num += nCnt;
                sprintf(szBuffer, "%12.12s", szAmount);
                PubStrAdd(gbStruSettleData[12].szAmount, szBuffer, gbStruSettleData[12].szAmount);
				break;

            case CARD_VISA_DEBIT/10:
                gbStruSettleData[13].num += nCnt;
                sprintf(szBuffer, "%12.12s", szAmount);
                PubStrAdd(gbStruSettleData[13].szAmount, szBuffer, gbStruSettleData[13].szAmount);
				break;

            case CARD_MC_DEBIT/10:
                gbStruSettleData[14].num += nCnt;
                sprintf(szBuffer, "%12.12s", szAmount);
                PubStrAdd(gbStruSettleData[14].szAmount, szBuffer, gbStruSettleData[14].szAmount);
				break;
            case CARD_AE/10:
                gbStruSettleData[15].num += nCnt;
                sprintf(szBuffer, "%12.12s", szAmount);
                PubStrAdd(gbStruSettleData[15].szAmount, szBuffer, gbStruSettleData[15].szAmount);
				break;
            case CARD_DINERS/10:
                gbStruSettleData[16].num += nCnt;
                sprintf(szBuffer, "%12.12s", szAmount);
                PubStrAdd(gbStruSettleData[16].szAmount, szBuffer, gbStruSettleData[16].szAmount);
				break;
            case CARD_JCB/10:
                gbStruSettleData[17].num += nCnt;
                sprintf(szBuffer, "%12.12s", szAmount);
                PubStrAdd(gbStruSettleData[17].szAmount, szBuffer, gbStruSettleData[17].szAmount);
				break;
            default:
				// linq add 未正确取得卡类型的卡,统一记入银联卡,防止漏统计
				gbStruSettleData[12].num += nCnt;
                sprintf(szBuffer, "%12.12s", szAmount);
                PubStrAdd(gbStruSettleData[12].szAmount, szBuffer, gbStruSettleData[12].szAmount);
				break;
            }
            break;
        default:
            break;
        }
    }
    EA_ucPFClose(ucFd);

    return NORMAL;
}