10 const char *
perms[
sizeof(unsigned) * 8 + 1];
16 #define max(x, y) (((int)(x) > (int)(y)) ? x : y)
20 static void usage(
void)
26 static char *stoupperx(
const char *
s)
32 fprintf(stderr,
"%s: out of memory\n", progname);
46 const char *needle =
"SOCKET";
54 fout = fopen(argv[1],
"w");
56 fprintf(stderr,
"Could not open %s for writing: %s\n",
64 for (j = 0; map->
perms[
j]; j++)
68 isids_len =
sizeof(initial_sid_to_string) /
sizeof (
char *);
69 for (i = 1; i < isids_len; i++)
70 initial_sid_to_string[i] = stoupperx(initial_sid_to_string[i]);
72 fprintf(fout,
"/* This file is automatically generated. Do not edit. */\n");
73 fprintf(fout,
"#ifndef _SELINUX_FLASK_H_\n#define _SELINUX_FLASK_H_\n\n");
85 for (i = 1; i < isids_len; i++) {
86 const char *s = initial_sid_to_string[
i];
87 fprintf(fout,
"#define SECINITSID_%s", s);
88 for (j = 0; j <
max(1, 40 -
strlen(s)); j++)
92 fprintf(fout,
"\n#define SECINITSID_NUM %d\n", i-1);
93 fprintf(fout,
"\nstatic inline bool security_is_socket_class(u16 kern_tclass)\n");
95 fprintf(fout,
"\tbool sock = false;\n\n");
96 fprintf(fout,
"\tswitch (kern_tclass) {\n");
100 if (substr &&
strcmp(substr, needle) == 0)
103 fprintf(fout,
"\t\tsock = true;\n");
108 fprintf(fout,
"\treturn sock;\n");
114 fout = fopen(argv[2],
"w");
116 fprintf(stderr,
"Could not open %s for writing: %s\n",
121 fprintf(fout,
"/* This file is automatically generated. Do not edit. */\n");
122 fprintf(fout,
"#ifndef _SELINUX_AV_PERMISSIONS_H_\n#define _SELINUX_AV_PERMISSIONS_H_\n\n");
126 for (j = 0; map->
perms[
j]; j++) {
131 fprintf(fout,
"0x%08xUL\n", (1<<j));