Skip to content

Commit 80f8be7

Browse files
masahir0yTetsuo Handa
authored andcommitted
tomoyo: Omit use of bin2c
bin2c was, as its name implies, introduced to convert a binary file to C code. However, I did not see any good reason ever for using this tool because using the .incbin directive is much faster, and often results in simpler code. Most of the uses of bin2c have been killed, for example: - 13610aa ("kernel/configs: use .incbin directive to embed config_data.gz") - 4c0f032 ("s390/purgatory: Omit use of bin2c") security/tomoyo/Makefile has even less reason for using bin2c because the policy files are text data. So, sed is enough for converting them to C string literals, and what is nicer, generates human-readable builtin-policy.h. This is the last user of bin2c. After this commit lands, bin2c will be removed. Signed-off-by: Masahiro Yamada <[email protected]> [penguin-kernel: Update sed script to also escape backslash and quote ] Signed-off-by: Tetsuo Handa <[email protected]>
1 parent df4840c commit 80f8be7

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

security/tomoyo/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ config SECURITY_TOMOYO
77
select SECURITY_PATH
88
select SECURITY_NETWORK
99
select SRCU
10-
select BUILD_BIN2C
1110
default n
1211
help
1312
This selects TOMOYO Linux, pathname-based access control.

security/tomoyo/Makefile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
obj-y = audit.o common.o condition.o domain.o environ.o file.o gc.o group.o load_policy.o memory.o mount.o network.o realpath.o securityfs_if.o tomoyo.o util.o
33

44
targets += builtin-policy.h
5-
define do_policy
6-
echo "static char tomoyo_builtin_$(1)[] __initdata ="; \
7-
$(objtree)/scripts/bin2c <$(firstword $(wildcard $(obj)/policy/$(1).conf $(srctree)/$(src)/policy/$(1).conf.default) /dev/null); \
8-
echo ";"
9-
endef
10-
quiet_cmd_policy = POLICY $@
11-
cmd_policy = ($(call do_policy,profile); $(call do_policy,exception_policy); $(call do_policy,domain_policy); $(call do_policy,manager); $(call do_policy,stat)) >$@
5+
6+
quiet_cmd_policy = POLICY $@
7+
cmd_policy = { \
8+
$(foreach x, profile exception_policy domain_policy manager stat, \
9+
printf 'static char tomoyo_builtin_$x[] __initdata =\n'; \
10+
sed -e 's/\\/\\\\/g' -e 's/\"/\\"/g' -e 's/\(.*\)/\t"\1\\n"/' -- $(firstword $(filter %/$x.conf %/$x.conf.default, $^) /dev/null); \
11+
printf '\t"";\n';) \
12+
} > $@
1213

1314
$(obj)/builtin-policy.h: $(wildcard $(obj)/policy/*.conf $(srctree)/$(src)/policy/*.conf.default) FORCE
1415
$(call if_changed,policy)

0 commit comments

Comments
 (0)