From: Benedict Wong Date: Fri, 18 Jan 2019 19:12:17 +0000 (-0800) Subject: xfrm: add option to hide keys in state output X-Git-Tag: v5.4.0~161 X-Git-Url: https://git.proxmox.com/?p=mirror_iproute2.git;a=commitdiff_plain;h=a6af9f2e6195dc67d5355d6cb94fc8512c6fba1c xfrm: add option to hide keys in state output ip xfrm state show currently dumps keys unconditionally. This limits its use in logging, as security information can be leaked. This patch adds a nokeys option to ip xfrm ( state show | monitor ), which prevents the printing of keys. This allows ip xfrm state show to be used in logging without exposing keys. Signed-off-by: Benedict Wong Signed-off-by: David Ahern --- diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c index 2dea4e37..b153b863 100644 --- a/ip/ipxfrm.c +++ b/ip/ipxfrm.c @@ -497,7 +497,8 @@ void xfrm_selector_print(struct xfrm_selector *sel, __u16 family, } static void __xfrm_algo_print(struct xfrm_algo *algo, int type, int len, - FILE *fp, const char *prefix, int newline) + FILE *fp, const char *prefix, int newline, + bool nokeys) { int keylen; int i; @@ -521,7 +522,9 @@ static void __xfrm_algo_print(struct xfrm_algo *algo, int type, int len, goto fin; } - if (keylen > 0) { + if (nokeys) + fprintf(fp, "<