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