From owner-freebsd-bugs Wed Apr 18 18:20:11 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 154BB37B42C for ; Wed, 18 Apr 2001 18:20:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f3J1K1R82396; Wed, 18 Apr 2001 18:20:01 -0700 (PDT) (envelope-from gnats) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 4D36537B423 for ; Wed, 18 Apr 2001 18:17:56 -0700 (PDT) (envelope-from nobody@FreeBSD.org) Received: (from nobody@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f3J1Hu182226; Wed, 18 Apr 2001 18:17:56 -0700 (PDT) (envelope-from nobody) Message-Id: <200104190117.f3J1Hu182226@freefall.freebsd.org> Date: Wed, 18 Apr 2001 18:17:56 -0700 (PDT) From: reel@sympatico.ca To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: bin/26689: logname returns error when passing opts args. Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 26689 >Category: bin >Synopsis: logname returns error when passing opts args. >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Apr 18 18:20:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Félix-Antoine Paradis >Release: FreeBSD 4.3-RC i386 >Organization: Idemnia Networks >Environment: FreeBSD idemnia.ath.cx 4.3-RC FreeBSD 4.3-RC #2: Thu Apr 12 11:25:41 EDT 2001 reel@idemnia.ath.cx:/usr/src/sys/compile/ZEUS i386 >Description: logname is a utility that prints the username on the standard output. when doing: 'logname meuh', it returns my login name, when doing 'logname reel', it returns my login name, when I do 'logname -e', it returns an error. As logname will always return the login whatever the argument passed is, it still wants to know if we passed some options to it. It doesn't have any options. Which means that it should not normally call getopt() to see if there is options, as the next switch only brings it to usage(). >How-To-Repeat: Type: logname -e (or any other options...) Note: logname --e will not give any errors. >Fix: Here is a patch: --- /usr/src/usr.bin/logname/logname.c Fri Mar 28 23:30:48 1997 +++ logname.c Wed Apr 18 21:04:10 2001 @@ -55,15 +55,9 @@ int argc; char *argv[]; { - int ch; char *p; - - while ((ch = getopt(argc, argv, "")) != -1) - switch (ch) { - case '?': - default: - usage(); - } + if (argc != 1) + usage(); argc -= optind; argv += optind; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message