Exemple #1
0
int main(int argc,char ** argv)
{
	int i;
	char *cmdline;
	prg_cache_load();
	for(i=1;i<PORT_MAX;i++)
	{
		cmdline = prg_cache_get(i);
		if(*cmdline != '-')
			printf("port:[%d], cmdline:[%s]\n", i, cmdline);
	}
	printf("over======PORT_MAX:%d=\n", PORT_MAX);
	prg_cache_clear();
	return 0;
}
Exemple #2
0
/**
 * Send connections to nuauth: between 1 and #CONN_MAX connections
 * in a big packet of format:
 *   [ nu_header + nu_authfield_ipv6 * N ]
 */
int send_user_pckt(nuauth_session_t * session, conn_t * carray[CONN_MAX])
{
	char data[PACKET_SIZE];
	char *pointer;
	unsigned int item;
	struct nu_header *header;
	struct nu_authreq *authreq;
	struct nu_authfield_ipv6 *authfield;
	struct nu_authfield_app *appfield;
	unsigned len;
	const char *appname;
	char *app_ptr;

	session->timestamp_last_sent = time(NULL);
	memset(data, 0, sizeof data);

	header = (struct nu_header *) data;
	header->proto = PROTO_VERSION;
	header->msg_type = USER_REQUEST;
	header->option = 0;
	header->length = sizeof(struct nu_header);
	pointer = (char *) (header + 1);

	for (item = 0; ((item < CONN_MAX) && carray[item] != NULL); item++) {
#if DEBUG
		printf("adding one authreq\n");
#endif
#ifdef LINUX
		/* get application name from inode */
		appname = prg_cache_get(carray[item]->inode);
#else
		appname = "UNKNOWN";
#endif
		header->length +=
		    sizeof(struct nu_authreq) +
		    sizeof(struct nu_authfield_ipv6);

		authreq = (struct nu_authreq *) pointer;
		authreq->packet_seq = session->packet_seq++;
		authreq->packet_length =
		    sizeof(struct nu_authreq) +
		    sizeof(struct nu_authfield_ipv6);

		authfield = (struct nu_authfield_ipv6 *) (authreq + 1);
		authfield->type = IPV6_FIELD;
		authfield->option = 0;
		authfield->src = carray[item]->ip_src;
		authfield->dst = carray[item]->ip_dst;
		authfield->proto = carray[item]->protocol;
		authfield->flags = 0;
		authfield->FUSE = 0;
#ifdef _I386__ENDIAN_H_
#ifdef __DARWIN_LITTLE_ENDIAN
		authfield->sport = carray[item]->port_src;
		authfield->dport = carray[item]->port_dst;
#else
		authfield->sport = htons(carray[item]->port_src);
		authfield->dport = htons(carray[item]->port_dst);
#endif				/* DARWIN LITTLE ENDIAN */
#else
		authfield->sport = htons(carray[item]->port_src);
		authfield->dport = htons(carray[item]->port_dst);
#endif				/* I386 ENDIAN */

		/* application field  */
		appfield = (struct nu_authfield_app *) (authfield + 1);
		appfield->type = APP_FIELD;
		appfield->option = APP_TYPE_NAME;
		app_ptr = (char *) (appfield + 1);
		sasl_encode64(appname, strlen(appname), app_ptr,
			      PROGNAME_BASE64_WIDTH, &len);
		appfield->length = sizeof(struct nu_authfield_app) + len;
		authreq->packet_length += appfield->length;

		/* glue piece together on data if packet is not too long */
		header->length += appfield->length;

		if (session->hash) {
			struct nu_authfield_app *sigfield;
			const char *appsig;
			appsig = prg_cache_getsig(session->hash, carray[item]->inode);
			sigfield = (struct nu_authfield_app *) ((char*)appfield + appfield->length);
			sigfield->type = HASH_FIELD;
			sigfield->option = 0;
			app_ptr = (char *) (sigfield + 1);
			memcpy(app_ptr, appsig, strlen(appsig));
			sigfield->length = sizeof(struct nu_authfield_app) + strlen(appsig);

			authreq->packet_length += sigfield->length;

			/* glue piece together on data if packet is not too long */
			header->length += sigfield->length;
			sigfield->length = htons(sigfield->length);
		}

		assert(header->length < PACKET_SIZE);

		pointer += authreq->packet_length;

		appfield->length = htons(appfield->length);

		authreq->packet_length = htons(authreq->packet_length);
		authfield->length =
		    htons(sizeof(struct nu_authfield_ipv6));
	}
	header->length = htons(header->length);
	if (session->debug_mode) {
		log_printf(DEBUG_LEVEL_INFO, "[+] Send %u new connection(s) to nuauth\n", item);
	}

	/* and send it */
#if XXX
	if (session->tls) {
		if (gnutls_record_send
		    (session->tls, data, pointer - data) <= 0) {
			log_printf(DEBUG_LEVEL_CRITICAL, "write failed\n");
			return 0;
		}
	}
#else
	if (ufwissl_write(session->ufwissl, (char*)data, pointer - data) < 0)
	{
		log_printf(DEBUG_LEVEL_CRITICAL, "write failed\n");
		return 0;
	}
#endif
	return 1;
}