|
Chris PeBenito |
0fbfa5 |
#!/bin/sh -
|
|
Chris PeBenito |
0fbfa5 |
#
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# FLASK
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
set -e
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
awk=$1
|
|
Chris PeBenito |
0fbfa5 |
shift 1
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# output file
|
|
Chris PeBenito |
0fbfa5 |
output_file="flask.h"
|
|
Chris PeBenito |
0fbfa5 |
debug_file="class_to_string.h"
|
|
Chris PeBenito |
0fbfa5 |
debug_file2="initial_sid_to_string.h"
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
cat $* | $awk "
|
|
Chris PeBenito |
0fbfa5 |
BEGIN {
|
|
Chris PeBenito |
0fbfa5 |
outfile = \"$output_file\"
|
|
Chris PeBenito |
0fbfa5 |
debugfile = \"$debug_file\"
|
|
Chris PeBenito |
0fbfa5 |
debugfile2 = \"$debug_file2\"
|
|
Chris PeBenito |
0fbfa5 |
"'
|
|
Chris PeBenito |
0fbfa5 |
nextstate = "CLASS";
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
printf("/* This file is automatically generated. Do not edit. */\n") > outfile;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
printf("#ifndef _SELINUX_FLASK_H_\n") > outfile;
|
|
Chris PeBenito |
0fbfa5 |
printf("#define _SELINUX_FLASK_H_\n") > outfile;
|
|
Chris PeBenito |
0fbfa5 |
printf("\n/*\n * Security object class definitions\n */\n") > outfile;
|
|
Chris PeBenito |
0fbfa5 |
printf("/* This file is automatically generated. Do not edit. */\n") > debugfile;
|
|
Chris PeBenito |
0fbfa5 |
printf("/*\n * Security object class definitions\n */\n") > debugfile;
|
|
Chris PeBenito |
0fbfa5 |
printf(" S_(\"null\")\n") > debugfile;
|
|
Chris PeBenito |
0fbfa5 |
printf("/* This file is automatically generated. Do not edit. */\n") > debugfile2;
|
|
Chris PeBenito |
0fbfa5 |
printf("static char *initial_sid_to_string[] =\n{\n") > debugfile2;
|
|
Chris PeBenito |
0fbfa5 |
printf(" \"null\",\n") > debugfile2;
|
|
Chris PeBenito |
0fbfa5 |
}
|
|
Chris PeBenito |
0fbfa5 |
/^[ \t]*#/ {
|
|
Chris PeBenito |
0fbfa5 |
next;
|
|
Chris PeBenito |
0fbfa5 |
}
|
|
Chris PeBenito |
0fbfa5 |
$1 == "class" {
|
|
Chris PeBenito |
0fbfa5 |
if (nextstate != "CLASS")
|
|
Chris PeBenito |
0fbfa5 |
{
|
|
Chris PeBenito |
0fbfa5 |
printf("Parse error: Unexpected class definition on line %d\n", NR);
|
|
Chris PeBenito |
0fbfa5 |
next;
|
|
Chris PeBenito |
0fbfa5 |
}
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
if ($2 in class_found)
|
|
Chris PeBenito |
0fbfa5 |
{
|
|
Chris PeBenito |
0fbfa5 |
printf("Duplicate class definition for %s on line %d.\n", $2, NR);
|
|
Chris PeBenito |
0fbfa5 |
next;
|
|
Chris PeBenito |
0fbfa5 |
}
|
|
Chris PeBenito |
0fbfa5 |
class_found[$2] = 1;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
class_value++;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
printf("#define SECCLASS_%s", toupper($2)) > outfile;
|
|
Chris PeBenito |
0fbfa5 |
for (i = 0; i < 40 - length($2); i++)
|
|
Chris PeBenito |
0fbfa5 |
printf(" ") > outfile;
|
|
Chris PeBenito |
0fbfa5 |
printf("%d\n", class_value) > outfile;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
printf(" S_(\"%s\")\n", $2) > debugfile;
|
|
Chris PeBenito |
0fbfa5 |
}
|
|
Chris PeBenito |
0fbfa5 |
$1 == "sid" {
|
|
Chris PeBenito |
0fbfa5 |
if (nextstate == "CLASS")
|
|
Chris PeBenito |
0fbfa5 |
{
|
|
Chris PeBenito |
0fbfa5 |
nextstate = "SID";
|
|
Chris PeBenito |
0fbfa5 |
printf("\n/*\n * Security identifier indices for initial entities\n */\n") > outfile;
|
|
Chris PeBenito |
0fbfa5 |
}
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
if ($2 in sid_found)
|
|
Chris PeBenito |
0fbfa5 |
{
|
|
Chris PeBenito |
0fbfa5 |
printf("Duplicate SID definition for %s on line %d.\n", $2, NR);
|
|
Chris PeBenito |
0fbfa5 |
next;
|
|
Chris PeBenito |
0fbfa5 |
}
|
|
Chris PeBenito |
0fbfa5 |
sid_found[$2] = 1;
|
|
Chris PeBenito |
0fbfa5 |
sid_value++;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
printf("#define SECINITSID_%s", toupper($2)) > outfile;
|
|
Chris PeBenito |
0fbfa5 |
for (i = 0; i < 37 - length($2); i++)
|
|
Chris PeBenito |
0fbfa5 |
printf(" ") > outfile;
|
|
Chris PeBenito |
0fbfa5 |
printf("%d\n", sid_value) > outfile;
|
|
Chris PeBenito |
0fbfa5 |
printf(" \"%s\",\n", $2) > debugfile2;
|
|
Chris PeBenito |
0fbfa5 |
}
|
|
Chris PeBenito |
0fbfa5 |
END {
|
|
Chris PeBenito |
0fbfa5 |
if (nextstate != "SID")
|
|
Chris PeBenito |
0fbfa5 |
printf("Parse error: Unexpected end of file\n");
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
printf("\n#define SECINITSID_NUM") > outfile;
|
|
Chris PeBenito |
0fbfa5 |
for (i = 0; i < 34; i++)
|
|
Chris PeBenito |
0fbfa5 |
printf(" ") > outfile;
|
|
Chris PeBenito |
0fbfa5 |
printf("%d\n", sid_value) > outfile;
|
|
Chris PeBenito |
0fbfa5 |
printf("\n#endif\n") > outfile;
|
|
Chris PeBenito |
0fbfa5 |
printf("};\n\n") > debugfile2;
|
|
Chris PeBenito |
0fbfa5 |
}'
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# FLASK
|