Ejemplo n.º 1
0
static const char *print_arch(const char *val, int machine)
{
        const char *ptr;
	char *out;

        if (machine < 0) {
                asprintf(&out, "unknown elf type(%s)", val);
                return out;
        }
        ptr = audit_machine_to_name(machine);
	if (ptr)
	        return strdup(ptr);
	else {
                asprintf(&out, "unknown machine type(%d)", machine);
                return out;
	}
}
Ejemplo n.º 2
0
static void print_arch(const char *val)
{
	unsigned int ival;
	const char *ptr;

	errno = 0;
	ival = strtoul(val, NULL, 16);
	if (errno) {
		printf("conversion error(%s) ", val);
		return;
	}
	machine = audit_elf_to_machine(ival);
	if (machine < 0) {
		printf("unknown elf type(%s) ", val);
		return;
	}
	ptr = audit_machine_to_name(machine);
	printf("%s ", ptr);
}
Ejemplo n.º 3
0
static int print_arch(unsigned int value, int op)
{
	int machine;
	_audit_elf = value;
	machine = audit_elf_to_machine(_audit_elf);
	if (machine < 0)
		printf(" -F arch%s0x%X", audit_operator_to_symbol(op),
				(unsigned)value);
	else {
		if (interpret == 0) {
			if (__AUDIT_ARCH_64BIT & _audit_elf)
				printf(" -F arch%sb64",
						audit_operator_to_symbol(op));
			else
				printf(" -F arch%sb32",
						audit_operator_to_symbol(op));
		} else {	
			const char *ptr = audit_machine_to_name(machine);
			printf(" -F arch%s%s", audit_operator_to_symbol(op),
						ptr);
		}
	}
	return machine;
}
Ejemplo n.º 4
0
int main(int argc, char *argv[])
{
	int i, rc;
	int machine=-1, syscall_num=-1, dump=0, exact=0;
	const char *name = NULL;

	if (argc > 4) {
		fputs("Too many arguments\n", stderr);
		usage();
	} else if (argc < 2)
		usage();
 
	for (i=1; i<argc; i++) {
		if (isdigit(argv[i][0])) {
			if (syscall_num != -1) {
				fputs("Two syscall numbers not allowed\n",
					stderr);
				usage();
			}
			syscall_num = strtol(argv[i], 0, 10);
		} else if ((rc = audit_name_to_machine(argv[i])) != -1) {
			if (machine != -1) {
				fputs("Two machine types not allowed\n",stderr);
				usage();
			}
			machine = rc;
		} else if (strcmp("--dump", argv[i]) == 0) {
			dump=1;
		} else if (strcmp("--exact", argv[i]) == 0) {
			exact=1;
#ifndef WITH_ALPHA
		} else if (strcmp("alpha", argv[i]) == 0) {
			fputs("Alpha processor support is not enabled\n",
					stderr);
			exit(1);
#endif
#ifndef WITH_ARMEB
		} else if (strcmp("armeb", argv[i]) == 0) {
			fputs("Arm eabi processor support is not enabled\n",
					stderr);
			exit(1);
#endif
		} else {
			if (name != NULL) {
				fputs("Two syscall names not allowed\n",stderr);
				usage();
			}
			name = argv[i];
		}
	}
	if (machine == -1)
		machine = audit_detect_machine();
	if (machine == -1) {
		fprintf(stderr, "Unable to detect machine type\n");
		return 1;
	}

	if (dump) {
		printf("Using %s syscall table:\n",
			audit_machine_to_name(machine));
		for (i=0; i<8192; i++) {
			name = audit_syscall_to_name(i, machine);
			if (name) 
				printf("%d\t%s\n", i, name);
		}
		return 0;
	}

	if (name) {
		if (exact) {
			rc = audit_name_to_syscall(name, machine);
			if (rc < 0) {
				fprintf(stderr,
					"Unknown syscall %s using %s lookup table\n",
					name, audit_machine_to_name(machine));
				return 1;
			} else
				printf("%d\n", rc);
		} else {
			int found = 0;
			for (i=0; i< LAST_SYSCALL; i++) {
				const char *n = audit_syscall_to_name(i, machine);
				if (n && strcasestr(n, name)) {
					found = 1;
					printf("%-18s %d\n", n, i);
				}
			}
			if (!found) {
				fprintf(stderr,
					"Unknown syscall %s using %s lookup table\n",
					name, audit_machine_to_name(machine));
				return 1;
			}
		}
	} else if (syscall_num != -1) {
		name = audit_syscall_to_name(syscall_num, machine);
		if (name == NULL) {
			fprintf(stderr,
				"Unknown syscall %d using %s lookup table\n",
				syscall_num, audit_machine_to_name(machine));
			return 1;
		} else
			printf("%s\n", name);
	} else {
		fputs("Error - either a syscall name or number must "
			"be given with an optional arch\n", stderr);
		return 1;
	}

	return 0;
}