コード例 #1
0
ファイル: control.c プロジェクト: DPMI/mp
static void mp_filter(struct MPFilter* event, size_t bytes){
	if( strcmp(event->MAMPid, MPinfo->id) != 0){
		logmsg(verbose, CONTROL, "This reply was intened for a different MP (%s).\n", event->MAMPid);
		return;
	}

	if ( debug_flag ){
		logmsg(verbose, CONTROL, "Got MPFilter from MArCd.\n");
		hexdump(verbose, (char*)event, bytes);
	}

	if ( bytes < 200 ){
		logmsg(verbose, CONTROL, "Legacy MPFilter detected\n");
		event->filter.version = 0;
	}

	struct filter filter = {0,};
	filter_unpack(&event->filter, &filter);

	/* Make sure that the User doesnt request more information than we can give. */
	filter.caplen = MIN(filter.caplen, snaplen());

	logmsg(stderr, CONTROL, "Updating filter {%d}\n", filter.filter_id);

	if ( verbose_flag ){
		filter_print(&filter, stdout, 0);
	}

	mprules_add(&filter);

}
コード例 #2
0
ファイル: main.c プロジェクト: irregulator/firejail
int main(int argc, char **argv) {
#if 0
{
//system("cat /proc/self/status");
int i;
for (i = 0; i < argc; i++)
        printf("*%s* ", argv[i]);
printf("\n");
}       
#endif
	if (argc < 2) {
		usage();
		return 1;
	}
		
	if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") ==0) {
		usage();
		return 0;
	}
	else if (argc == 2 && strcmp(argv[1], "debug-syscalls") == 0)
		syscall_print();
	else if (argc == 2 && strcmp(argv[1], "debug-errnos") == 0)
		errno_print();
	else if (argc == 2 && strcmp(argv[1], "debug-protocols") == 0)
		protocol_print();
	else if (argc == 5 && strcmp(argv[1], "protocol") == 0 && strcmp(argv[2], "build") == 0)
		protocol_build_filter(argv[3], argv[4]);
	else if (argc == 4 && strcmp(argv[1], "secondary") == 0 && strcmp(argv[2], "64") == 0)
		seccomp_secondary_64(argv[3]);
	else if (argc == 4 && strcmp(argv[1], "secondary") == 0 && strcmp(argv[2], "32") == 0) 
		seccomp_secondary_32(argv[3]);
	else if (argc == 3 && strcmp(argv[1], "default") == 0)
		seccomp_default(argv[2], 0);
	else if (argc == 4 && strcmp(argv[1], "default") == 0 && strcmp(argv[3], "allow-debuggers") == 0)
		seccomp_default(argv[2], 1);
	else if (argc == 4 && strcmp(argv[1], "drop") == 0)
		seccomp_drop(argv[2], argv[3], 0);
	else if (argc == 5 && strcmp(argv[1], "drop") == 0 && strcmp(argv[4], "allow-debuggers") == 0)
		seccomp_drop(argv[2], argv[3], 1);
	else if (argc == 5 && strcmp(argv[1], "default") == 0 && strcmp(argv[2], "drop") == 0)
		seccomp_default_drop(argv[3], argv[4], 0);
	else if (argc == 6 && strcmp(argv[1], "default") == 0 && strcmp(argv[2], "drop") == 0 && strcmp(argv[5], "allow-debuggers") == 0)
		seccomp_default_drop(argv[3], argv[4], 1);
	else if (argc == 4 && strcmp(argv[1], "keep") == 0)
		seccomp_keep(argv[2], argv[3]);
	else if (argc == 3 && strcmp(argv[1], "print") == 0)
		filter_print(argv[2]);
	else {
		fprintf(stderr, "Error fseccomp: invalid arguments\n");
		return 1;
	}

	return 0;
}