File: selinux_check_securetty_context.c

package info (click to toggle)
libselinux 2.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, experimental, sid
  • size: 2,080 kB
  • sloc: ansic: 16,057; makefile: 379; sh: 23
file content (35 lines) | stat: -rw-r--r-- 660 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <selinux/selinux.h>

static __attribute__ ((__noreturn__)) void usage(const char *progname)
{
	fprintf(stderr, "usage:  %s tty_context...\n", progname);
	exit(1);
}

int main(int argc, char **argv)
{
	int i;
	if (argc < 2)
		usage(argv[0]);

	for (i = 1; i < argc; i++) {
		switch (selinux_check_securetty_context(argv[i])) {
		case 0:
			printf("%s securetty.\n", argv[i]);
			break;
		default:
			printf("%s not securetty.\n", argv[i]);
			break;
		}
	}
	return 0;
}