From patchwork Tue Jan 30 22:53:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 226 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director3.mail.ord1d.rsapps.net ([172.30.191.6]) by backend31.mail.ord1d.rsapps.net (Dovecot) with LMTP id 2L6FBDeScVoUNgAAgoeIoA for ; Wed, 31 Jan 2018 04:53:59 -0500 Received: from proxy16.mail.ord1d.rsapps.net ([172.30.191.6]) by director3.mail.ord1d.rsapps.net (Dovecot) with LMTP id E4JdBDeScVq4SQAAkXNnRw ; Wed, 31 Jan 2018 04:53:59 -0500 Received: from smtp25.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy16.mail.ord1d.rsapps.net (Dovecot) with LMTP id i8FNGDeScVqhfAAAetu3IA ; Wed, 31 Jan 2018 04:53:59 -0500 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.34.181.88] Authentication-Results: smtp25.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.34.181.88"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=rfc2549.org X-Classification-ID: a8c15f3e-066c-11e8-8e38-52540081550e-1-1 Received: from [216.34.181.88] ([216.34.181.88:47396] helo=lists.sourceforge.net) by smtp25.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 81/94-29004-732917A5; Wed, 31 Jan 2018 04:53:59 -0500 Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.89) (envelope-from ) id 1egp4p-0003NH-71; Wed, 31 Jan 2018 09:53:11 +0000 Received: from sfi-mx-4.v28.ch3.sourceforge.com ([172.29.28.194] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1egp4o-0003NB-Q9 for openvpn-devel@lists.sourceforge.net; Wed, 31 Jan 2018 09:53:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:To: From:Sender:Reply-To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=RyOK5ayCRRqhPqktKW5FJ7M86K+Crh/Ck9JLKpDePcE=; b=RI5sJA+SxyI124MOv1ftjobZcS DmqojrbN2T1Y88reCp8d2MmBhRLje17BAH/rsPrUEkSNLt57EzV7n9u7FTRDYPeVoSjExl9XSP7Gq PIE2Di736/DIKrCrr4QxE6nRq5sCCyUg2jzc8mVpekK1N/XqOdFkXXQI+alc83obH3NA=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc :MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=RyOK5ayCRRqhPqktKW5FJ7M86K+Crh/Ck9JLKpDePcE=; b=k2jmtwXOYtzFdaSIfzJCvTvbOT kib0Qb9td4iQr3gwudY1FqHkQxknjr6XVYBzJ+ag+gHzs6P/13lnDX/ujXbfIPROAwDbJFNYjA80U tm7+dz43KosPjr0w2PYRTmJRFbT92H3OG740elAeR3HAK1SWl0jqSVt3E7ACVVWzPOLk=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-4.v28.ch3.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) id 1egp4k-0004S2-W0 for openvpn-devel@lists.sourceforge.net; Wed, 31 Jan 2018 09:53:10 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1egp4e-00066W-EE for openvpn-devel@lists.sourceforge.net; Wed, 31 Jan 2018 10:53:00 +0100 Received: (nullmailer pid 21638 invoked by uid 10006); Wed, 31 Jan 2018 09:53:00 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Wed, 31 Jan 2018 10:53:00 +0100 Message-Id: <1517392380-21597-1-git-send-email-arne@rfc2549.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1egp4k-0004S2-W0 Subject: [Openvpn-devel] [PATCH v3] show the right string for key-direction X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox V2: print also a nice string if direction is not set V3: really include V2 changes Acked-by: Steffan Karger Tested-by: Steffan Karger --- src/openvpn/crypto.c | 11 +++++++++-- src/openvpn/crypto.h | 2 +- src/openvpn/options.c | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c index 3096f3b0..b3021d4f 100644 --- a/src/openvpn/crypto.c +++ b/src/openvpn/crypto.c @@ -1545,11 +1545,18 @@ ascii2keydirection(int msglevel, const char *str) } const char * -keydirection2ascii(int kd, bool remote) +keydirection2ascii(int kd, bool remote, bool humanreadable) { if (kd == KEY_DIRECTION_BIDIRECTIONAL) { - return NULL; + if (humanreadable) + { + return "not set"; + } + else + { + return NULL; + } } else if (kd == KEY_DIRECTION_NORMAL) { diff --git a/src/openvpn/crypto.h b/src/openvpn/crypto.h index 8e8ee8f5..e1e318eb 100644 --- a/src/openvpn/crypto.h +++ b/src/openvpn/crypto.h @@ -470,7 +470,7 @@ void must_have_n_keys(const char *filename, const char *option, const struct key int ascii2keydirection(int msglevel, const char *str); -const char *keydirection2ascii(int kd, bool remote); +const char *keydirection2ascii(int kd, bool remote, bool humanreadable); /* print keys */ void key2_print(const struct key2 *k, diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 66e1f9d1..9f5cd6ed 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -1706,7 +1706,7 @@ show_settings(const struct options *o) #endif SHOW_STR(shared_secret_file); - SHOW_INT(key_direction); + SHOW_PARM(key_direction, keydirection2ascii(o->key_direction, false, true), "%s"); SHOW_STR(ciphername); SHOW_BOOL(ncp_enabled); SHOW_STR(ncp_ciphers); @@ -3583,7 +3583,7 @@ options_string(const struct options *o, * Key direction */ { - const char *kd = keydirection2ascii(o->key_direction, remote); + const char *kd = keydirection2ascii(o->key_direction, remote, false); if (kd) { buf_printf(&out, ",keydir %s", kd);