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