From owner-dev-commits-src-all@freebsd.org Mon Jun 21 16:12:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0899B64B6C9; Mon, 21 Jun 2021 16:12:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G7vh26TXyz3v58; Mon, 21 Jun 2021 16:12:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BBF9820160; Mon, 21 Jun 2021 16:12:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15LGCohC005852; Mon, 21 Jun 2021 16:12:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15LGCoZ1005850; Mon, 21 Jun 2021 16:12:50 GMT (envelope-from git) Date: Mon, 21 Jun 2021 16:12:50 GMT Message-Id: <202106211612.15LGCoZ1005850@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: 224c772ca59a - main - telnet(1): add quiet mode ("telnet -Q") MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 224c772ca59a1234b48658358a8f043e4cd09f7c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jun 2021 16:12:51 -0000 The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=224c772ca59a1234b48658358a8f043e4cd09f7c commit 224c772ca59a1234b48658358a8f043e4cd09f7c Author: Edward Tomasz Napierala AuthorDate: 2021-06-21 16:07:39 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-06-21 16:11:57 +0000 telnet(1): add quiet mode ("telnet -Q") Reviewed By: imp, phk Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. X-NetApp-PR: #54 Differential Revision: https://reviews.freebsd.org/D30819 --- contrib/telnet/telnet/commands.c | 18 +++++++++++++----- contrib/telnet/telnet/main.c | 6 +++++- contrib/telnet/telnet/telnet.1 | 9 +++++++-- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/contrib/telnet/telnet/commands.c b/contrib/telnet/telnet/commands.c index 21e973209d9b..c52af2a81a67 100644 --- a/contrib/telnet/telnet/commands.c +++ b/contrib/telnet/telnet/commands.c @@ -122,6 +122,7 @@ static char line[256]; static char saveline[256]; static int margc; static char *margv[20]; +int quiet_mode; #ifdef OPIE #include @@ -2042,7 +2043,8 @@ static int status(int argc, char *argv[]) { if (connected) { - printf("Connected to %s.\n", hostname); + if (!quiet_mode) + printf("Connected to %s.\n", hostname); if ((argc < 2) || strcmp(argv[1], "notmuch")) { int mode = getconnmode(); @@ -2071,7 +2073,8 @@ status(int argc, char *argv[]) } else { printf("No connection.\n"); } - printf("Escape character is '%s'.\n", control(escape)); + if (!quiet_mode) + printf("Escape character is '%s'.\n", control(escape)); (void) fflush(stdout); return 1; } @@ -2264,7 +2267,8 @@ tn(int argc, char *argv[]) memset(&su, 0, sizeof su); su.sun_family = AF_UNIX; strncpy(su.sun_path, hostp, sizeof su.sun_path); - printf("Trying %s...\n", hostp); + if (!quiet_mode) + printf("Trying %s...\n", hostp); net = socket(PF_UNIX, SOCK_STREAM, 0); if ( net < 0) { perror("socket"); @@ -2373,7 +2377,8 @@ tn(int argc, char *argv[]) } } do { - printf("Trying %s...\n", sockaddr_ntop(res->ai_addr)); + if (!quiet_mode) + printf("Trying %s...\n", sockaddr_ntop(res->ai_addr)); net = socket(res->ai_family, res->ai_socktype, res->ai_protocol); setuid(getuid()); if (net < 0) { @@ -2491,7 +2496,10 @@ tn(int argc, char *argv[]) (void) call(status, "status", "notmuch", 0); telnet(user); (void) NetClose(net); - ExitString("Connection closed by foreign host.\n",1); + if (quiet_mode) + ExitString("",1); + else + ExitString("Connection closed by foreign host.\n",1); /*NOTREACHED*/ fail: if (res0 != NULL) diff --git a/contrib/telnet/telnet/main.c b/contrib/telnet/telnet/main.c index befb3eecee66..8ebcc0a86259 100644 --- a/contrib/telnet/telnet/main.c +++ b/contrib/telnet/telnet/main.c @@ -63,6 +63,7 @@ char *ipsec_policy_out = NULL; #endif extern int tos; +extern int quiet_mode; int family = AF_UNSPEC; @@ -152,7 +153,7 @@ main(int argc, char *argv[]) #define IPSECOPT #endif while ((ch = getopt(argc, argv, - "468B:EKLNS:X:acde:fFk:l:n:rs:uxy" IPSECOPT)) != -1) + "468B:EKLNQS:X:acde:fFk:l:n:rs:uxy" IPSECOPT)) != -1) #undef IPSECOPT { switch(ch) { @@ -184,6 +185,9 @@ main(int argc, char *argv[]) case 'N': doaddrlookup = 0; break; + case 'Q': + quiet_mode = 1; + break; case 'S': #ifdef HAS_GETTOS diff --git a/contrib/telnet/telnet/telnet.1 b/contrib/telnet/telnet/telnet.1 index b7004ee94a5d..015401030f23 100644 --- a/contrib/telnet/telnet/telnet.1 +++ b/contrib/telnet/telnet/telnet.1 @@ -28,7 +28,7 @@ .\" @(#)telnet.1 8.6 (Berkeley) 6/1/94 .\" $FreeBSD$ .\" -.Dd August 7, 2020 +.Dd June 21, 2021 .Dt TELNET 1 .Os .Sh NAME @@ -38,7 +38,7 @@ protocol .Sh SYNOPSIS .Nm -.Op Fl 468EFKLNacdfruxy +.Op Fl 468EFKLNQacdfruxy .Op Fl B Ar baudrate .Op Fl S Ar tos .Op Fl X Ar authtype @@ -108,6 +108,11 @@ option to be negotiated on output. .It Fl N Prevents IP address to name lookup when destination host is given as an IP address. +.It Fl Q +Quiet mode. +This suppresses the messages +.Nm +would normally output upon connecting or disconnecting. .It Fl S Ar tos Sets the IP type-of-service (TOS) option for the telnet connection to the value