Skip to content

Commit 9adeb5b

Browse files
arndbgregkh
authored andcommittedFeb 25, 2018
modsign: hide openssl output in silent builds
commit 5d06ee2 upstream. When a user calls 'make -s', we can assume they don't want to see any output except for warnings and errors, but instead they see this for a warning free build: ### ### Now generating an X.509 key pair to be used for signing modules. ### ### If this takes a long time, you might wish to run rngd in the ### background to keep the supply of entropy topped up. It ### needs to be run as root, and uses a hardware random ### number generator if one is available. ### Generating a 4096 bit RSA private key .................................................................................................................................................................................................................................++ ..............................................................................................................................++ writing new private key to 'certs/signing_key.pem' ----- ### ### Key pair generated. ### The output can confuse simple build testing scripts that just check for an empty build log. This patch silences all the output: - "echo" is changed to "@$(kecho)", which is dropped when "-s" gets passed - the openssl command itself is only printed with V=1, using the $(Q) macro - The output of openssl gets redirected to /dev/null on "-s" builds. Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: David Howells <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 12ec052 commit 9adeb5b

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed
 

‎certs/Makefile

+19-14
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,34 @@ ifndef CONFIG_MODULE_SIG_HASH
3636
$(error Could not determine digest type to use from kernel config)
3737
endif
3838

39+
redirect_openssl = 2>&1
40+
quiet_redirect_openssl = 2>&1
41+
silent_redirect_openssl = 2>/dev/null
42+
3943
# We do it this way rather than having a boolean option for enabling an
4044
# external private key, because 'make randconfig' might enable such a
4145
# boolean option and we unfortunately can't make it depend on !RANDCONFIG.
4246
ifeq ($(CONFIG_MODULE_SIG_KEY),"certs/signing_key.pem")
4347
$(obj)/signing_key.pem: $(obj)/x509.genkey
44-
@echo "###"
45-
@echo "### Now generating an X.509 key pair to be used for signing modules."
46-
@echo "###"
47-
@echo "### If this takes a long time, you might wish to run rngd in the"
48-
@echo "### background to keep the supply of entropy topped up. It"
49-
@echo "### needs to be run as root, and uses a hardware random"
50-
@echo "### number generator if one is available."
51-
@echo "###"
52-
openssl req -new -nodes -utf8 -$(CONFIG_MODULE_SIG_HASH) -days 36500 \
48+
@$(kecho) "###"
49+
@$(kecho) "### Now generating an X.509 key pair to be used for signing modules."
50+
@$(kecho) "###"
51+
@$(kecho) "### If this takes a long time, you might wish to run rngd in the"
52+
@$(kecho) "### background to keep the supply of entropy topped up. It"
53+
@$(kecho) "### needs to be run as root, and uses a hardware random"
54+
@$(kecho) "### number generator if one is available."
55+
@$(kecho) "###"
56+
$(Q)openssl req -new -nodes -utf8 -$(CONFIG_MODULE_SIG_HASH) -days 36500 \
5357
-batch -x509 -config $(obj)/x509.genkey \
5458
-outform PEM -out $(obj)/signing_key.pem \
55-
-keyout $(obj)/signing_key.pem 2>&1
56-
@echo "###"
57-
@echo "### Key pair generated."
58-
@echo "###"
59+
-keyout $(obj)/signing_key.pem \
60+
$($(quiet)redirect_openssl)
61+
@$(kecho) "###"
62+
@$(kecho) "### Key pair generated."
63+
@$(kecho) "###"
5964

6065
$(obj)/x509.genkey:
61-
@echo Generating X.509 key generation config
66+
@$(kecho) Generating X.509 key generation config
6267
@echo >$@ "[ req ]"
6368
@echo >>$@ "default_bits = 4096"
6469
@echo >>$@ "distinguished_name = req_distinguished_name"

0 commit comments

Comments
 (0)