Fix gen-tunables.awk to work with older awk

Awk 3.1.x does not support multi-dimensional arrays, so fix up to make
sure that gen-tunables.awk works on it.

	* scripts/gen-tunables.awk: Avoid multi-dimensional arrays.
This commit is contained in:
Adhemerval Zanella 2017-06-19 14:47:21 +05:30 committed by Siddhesh Poyarekar
parent 5e5b3b8866
commit a4de0a9008
2 changed files with 38 additions and 34 deletions

View File

@ -1,3 +1,7 @@
2017-06-19 Adhemerval Zanella <adhemerval.zanella@linaro.org>
* scripts/gen-tunables.awk: Avoid multi-dimensional arrays.
2017-06-19 Stefan Liebler <stli@linux.vnet.ibm.com>
[BZ #21537]

View File

@ -39,20 +39,20 @@ $2 == "{" {
$1 == "}" {
if (tunable != "") {
# Tunables definition ended, now fill in default attributes.
if (!types[top_ns][ns][tunable]) {
types[top_ns][ns][tunable] = "STRING"
if (!types[top_ns,ns,tunable]) {
types[top_ns,ns,tunable] = "STRING"
}
if (!minvals[top_ns][ns][tunable]) {
minvals[top_ns][ns][tunable] = "0"
if (!minvals[top_ns,ns,tunable]) {
minvals[top_ns,ns,tunable] = "0"
}
if (!maxvals[top_ns][ns][tunable]) {
maxvals[top_ns][ns][tunable] = "0"
if (!maxvals[top_ns,ns,tunable]) {
maxvals[top_ns,ns,tunable] = "0"
}
if (!env_alias[top_ns][ns][tunable]) {
env_alias[top_ns][ns][tunable] = "NULL"
if (!env_alias[top_ns,ns,tunable]) {
env_alias[top_ns,ns,tunable] = "NULL"
}
if (!security_level[top_ns][ns][tunable]) {
security_level[top_ns][ns][tunable] = "SXID_ERASE"
if (!security_level[top_ns,ns,tunable]) {
security_level[top_ns,ns,tunable] = "SXID_ERASE"
}
tunable = ""
@ -81,7 +81,7 @@ $1 == "}" {
if (tunable == "") {
# We encountered a tunable without any attributes, so note it with a
# default.
types[top_ns][ns][$1] = "STRING"
types[top_ns,ns,$1] = "STRING"
next
}
@ -91,20 +91,20 @@ $1 == "}" {
val = gensub(/^[ \t]+|[ \t]+$/, "", "g", arr[2])
if (attr == "type") {
types[top_ns][ns][tunable] = val
types[top_ns,ns,tunable] = val
}
else if (attr == "minval") {
minvals[top_ns][ns][tunable] = val
minvals[top_ns,ns,tunable] = val
}
else if (attr == "maxval") {
maxvals[top_ns][ns][tunable] = val
maxvals[top_ns,ns,tunable] = val
}
else if (attr == "env_alias") {
env_alias[top_ns][ns][tunable] = sprintf("\"%s\"", val)
env_alias[top_ns,ns,tunable] = sprintf("\"%s\"", val)
}
else if (attr == "security_level") {
if (val == "SXID_ERASE" || val == "SXID_IGNORE" || val == "NONE") {
security_level[top_ns][ns][tunable] = val
security_level[top_ns,ns,tunable] = val
}
else {
printf("Line %d: Invalid value (%s) for security_level: %s, ", NR, val,
@ -114,11 +114,11 @@ $1 == "}" {
}
}
else if (attr == "default") {
if (types[top_ns][ns][tunable] == "STRING") {
default_val[top_ns][ns][tunable] = sprintf(".strval = \"%s\"", val);
if (types[top_ns,ns,tunable] == "STRING") {
default_val[top_ns,ns,tunable] = sprintf(".strval = \"%s\"", val);
}
else {
default_val[top_ns][ns][tunable] = sprintf(".numval = %s", val)
default_val[top_ns,ns,tunable] = sprintf(".numval = %s", val)
}
}
}
@ -139,27 +139,27 @@ END {
# Now, the enum names
print "\ntypedef enum"
print "{"
for (t in types) {
for (n in types[t]) {
for (m in types[t][n]) {
for (tnm in types) {
split (tnm, indices, SUBSEP);
t = indices[1];
n = indices[2];
m = indices[3];
printf (" TUNABLE_ENUM_NAME(%s, %s, %s),\n", t, n, m);
}
}
}
print "} tunable_id_t;\n"
# Finally, the tunable list.
print "\n#ifdef TUNABLES_INTERNAL"
print "static tunable_t tunable_list[] attribute_relro = {"
for (t in types) {
for (n in types[t]) {
for (m in types[t][n]) {
for (tnm in types) {
split (tnm, indices, SUBSEP);
t = indices[1];
n = indices[2];
m = indices[3];
printf (" {TUNABLE_NAME_S(%s, %s, %s)", t, n, m)
printf (", {TUNABLE_TYPE_%s, %s, %s}, {%s}, NULL, TUNABLE_SECLEVEL_%s, %s},\n",
types[t][n][m], minvals[t][n][m], maxvals[t][n][m],
default_val[t][n][m], security_level[t][n][m], env_alias[t][n][m]);
}
}
types[t,n,m], minvals[t,n,m], maxvals[t,n,m],
default_val[t,n,m], security_level[t,n,m], env_alias[t,n,m]);
}
print "};"
print "#endif"