1 # Generate dl-tunable-list.h from dl-tunables.list
6 min_of
["INT_32"]=
"INT32_MIN"
7 max_of
["INT_32"]=
"INT32_MAX"
9 max_of
["UINT_64"]=
"UINT64_MAX"
11 max_of
["SIZE_T"]=
"SIZE_MAX"
17 # Skip over blank lines and comments.
26 # Beginning of either a top namespace, tunable namespace or a tunable, decided
27 # on the current value of TUNABLE, NS or TOP_NS.
35 else if (tunable ==
"") {
39 printf ("Unexpected occurrence of '{': %s:%d\n", FILENAME, FNR)
46 # End of either a top namespace, tunable namespace or a tunable.
49 # Tunables definition ended, now fill in default attributes.
50 if (!types
[top_ns
,ns
,tunable
]) {
51 types
[top_ns
,ns
,tunable
] =
"STRING"
53 if (!minvals
[top_ns
,ns
,tunable
]) {
54 minvals
[top_ns
,ns
,tunable
] = min_of
[types
[top_ns
,ns
,tunable
]]
56 if (!maxvals
[top_ns
,ns
,tunable
]) {
57 maxvals
[top_ns
,ns
,tunable
] = max_of
[types
[top_ns
,ns
,tunable
]]
59 if (!env_alias
[top_ns
,ns
,tunable
]) {
60 env_alias
[top_ns
,ns
,tunable
] =
"NULL"
62 if (!security_level
[top_ns
,ns
,tunable
]) {
63 security_level
[top_ns
,ns
,tunable
] =
"SXID_ERASE"
71 else if (top_ns
!= "") {
75 printf ("syntax error: extra }: %s:%d\n", FILENAME, FNR)
81 # Everything else, which could either be a tunable without any attributes or a
85 printf("Line %d: Invalid tunable outside a namespace: %s\n", NR, $
0)
90 # We encountered a tunable without any attributes, so note it with a
92 types
[top_ns
,ns
,$
1] =
"STRING"
96 # Otherwise, we have encountered a tunable attribute.
98 attr = gensub
(/^
[ \t]+|[ \t]+$
/, "", "g", arr
[1])
99 val = gensub
(/^
[ \t]+|[ \t]+$
/, "", "g", arr
[2])
101 if (attr ==
"type") {
102 types
[top_ns
,ns
,tunable
] = val
104 else if (attr ==
"minval") {
105 minvals
[top_ns
,ns
,tunable
] = val
107 else if (attr ==
"maxval") {
108 maxvals
[top_ns
,ns
,tunable
] = val
110 else if (attr ==
"env_alias") {
111 env_alias
[top_ns
,ns
,tunable
] =
sprintf("\"%s\"", val
)
113 else if (attr ==
"security_level") {
114 if (val ==
"SXID_ERASE" || val ==
"SXID_IGNORE" || val ==
"NONE") {
115 security_level
[top_ns
,ns
,tunable
] = val
118 printf("Line %d: Invalid value (%s) for security_level: %s, ", NR, val
,
120 print("Allowed values are 'SXID_ERASE', 'SXID_IGNORE', or 'NONE'")
124 else if (attr ==
"default") {
125 if (types
[top_ns
,ns
,tunable
] ==
"STRING") {
126 default_val
[top_ns
,ns
,tunable
] =
sprintf(".strval = \"%s\"", val
);
129 default_val
[top_ns
,ns
,tunable
] =
sprintf(".numval = %s", val
)
136 print "Unterminated namespace. Is a closing brace missing?"
140 print "/* AUTOGENERATED by gen-tunables.awk. */"
141 print "#ifndef _TUNABLES_H_"
142 print "# error \"Do not include this file directly.\""
143 print "# error \"Include tunables.h instead.\""
145 print "#include <dl-procinfo.h>\n"
147 # Now, the enum names
148 print "\ntypedef enum"
151 split (tnm
, indices
, SUBSEP
);
155 printf (" TUNABLE_ENUM_NAME(%s, %s, %s),\n", t
, n
, m
);
157 print "} tunable_id_t;\n"
159 # Finally, the tunable list.
160 print "\n#ifdef TUNABLES_INTERNAL"
161 print "static tunable_t tunable_list[] attribute_relro = {"
163 split (tnm
, indices
, SUBSEP
);
167 printf (" {TUNABLE_NAME_S(%s, %s, %s)", t
, n
, m
)
168 printf (", {TUNABLE_TYPE_%s, %s, %s}, {%s}, NULL, TUNABLE_SECLEVEL_%s, %s},\n",
169 types
[t
,n
,m
], minvals
[t
,n
,m
], maxvals
[t
,n
,m
],
170 default_val
[t
,n
,m
], security_level
[t
,n
,m
], env_alias
[t
,n
,m
]);