1 # Generate dl-tunable-list.h from dl-tunables.list
9 # Skip over blank lines and comments.
18 # Beginning of either a top namespace, tunable namespace or a tunable, decided
19 # on the current value of TUNABLE, NS or TOP_NS.
27 else if (tunable ==
"") {
31 printf ("Unexpected occurrence of '{': %s:%d\n", FILENAME, FNR)
38 # End of either a top namespace, tunable namespace or a tunable.
41 # Tunables definition ended, now fill in default attributes.
42 if (!types
[top_ns
,ns
,tunable
]) {
43 types
[top_ns
,ns
,tunable
] =
"STRING"
45 if (!minvals
[top_ns
,ns
,tunable
]) {
46 minvals
[top_ns
,ns
,tunable
] =
"0"
48 if (!maxvals
[top_ns
,ns
,tunable
]) {
49 maxvals
[top_ns
,ns
,tunable
] =
"0"
51 if (!env_alias
[top_ns
,ns
,tunable
]) {
52 env_alias
[top_ns
,ns
,tunable
] =
"NULL"
54 if (!security_level
[top_ns
,ns
,tunable
]) {
55 security_level
[top_ns
,ns
,tunable
] =
"SXID_ERASE"
63 else if (top_ns
!= "") {
67 printf ("syntax error: extra }: %s:%d\n", FILENAME, FNR)
73 # Everything else, which could either be a tunable without any attributes or a
77 printf("Line %d: Invalid tunable outside a namespace: %s\n", NR, $
0)
82 # We encountered a tunable without any attributes, so note it with a
84 types
[top_ns
,ns
,$
1] =
"STRING"
88 # Otherwise, we have encountered a tunable attribute.
90 attr = gensub
(/^
[ \t]+|[ \t]+$
/, "", "g", arr
[1])
91 val = gensub
(/^
[ \t]+|[ \t]+$
/, "", "g", arr
[2])
94 types
[top_ns
,ns
,tunable
] = val
96 else if (attr ==
"minval") {
97 minvals
[top_ns
,ns
,tunable
] = val
99 else if (attr ==
"maxval") {
100 maxvals
[top_ns
,ns
,tunable
] = val
102 else if (attr ==
"env_alias") {
103 env_alias
[top_ns
,ns
,tunable
] =
sprintf("\"%s\"", val
)
105 else if (attr ==
"security_level") {
106 if (val ==
"SXID_ERASE" || val ==
"SXID_IGNORE" || val ==
"NONE") {
107 security_level
[top_ns
,ns
,tunable
] = val
110 printf("Line %d: Invalid value (%s) for security_level: %s, ", NR, val
,
112 print("Allowed values are 'SXID_ERASE', 'SXID_IGNORE', or 'NONE'")
116 else if (attr ==
"default") {
117 if (types
[top_ns
,ns
,tunable
] ==
"STRING") {
118 default_val
[top_ns
,ns
,tunable
] =
sprintf(".strval = \"%s\"", val
);
121 default_val
[top_ns
,ns
,tunable
] =
sprintf(".numval = %s", val
)
128 print "Unterminated namespace. Is a closing brace missing?"
132 print "/* AUTOGENERATED by gen-tunables.awk. */"
133 print "#ifndef _TUNABLES_H_"
134 print "# error \"Do not include this file directly.\""
135 print "# error \"Include tunables.h instead.\""
137 print "#include <dl-procinfo.h>\n"
139 # Now, the enum names
140 print "\ntypedef enum"
143 split (tnm
, indices
, SUBSEP
);
147 printf (" TUNABLE_ENUM_NAME(%s, %s, %s),\n", t
, n
, m
);
149 print "} tunable_id_t;\n"
151 # Finally, the tunable list.
152 print "\n#ifdef TUNABLES_INTERNAL"
153 print "static tunable_t tunable_list[] attribute_relro = {"
155 split (tnm
, indices
, SUBSEP
);
159 printf (" {TUNABLE_NAME_S(%s, %s, %s)", t
, n
, m
)
160 printf (", {TUNABLE_TYPE_%s, %s, %s}, {%s}, NULL, TUNABLE_SECLEVEL_%s, %s},\n",
161 types
[t
,n
,m
], minvals
[t
,n
,m
], maxvals
[t
,n
,m
],
162 default_val
[t
,n
,m
], security_level
[t
,n
,m
], env_alias
[t
,n
,m
]);