Bug 29730

Summary: su usage info shows incorrect info
Product: Base System Reporter: Joseph Mallett <jmallett>
Component: binAssignee: ru <ru>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.3-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Joseph Mallett 2001-08-15 15:20:00 UTC
Someone decided it would be easy to just insert the string used by getopt() in the usage fprintf, but this is bad, because as the c flag requires an argument, it has a colon after it, and the usage output might lead a reader to believe 'su -:' did something.

How-To-Repeat: Type su -c without any argument.
Comment 1 ru freebsd_committer freebsd_triage 2001-08-15 16:39:54 UTC
On Wed, Aug 15, 2001 at 07:10:17AM -0700, Joseph Mallett wrote:
[...]
> >Fix:
> --- su.orig     Tue Jun 19 00:26:30 2001
> +++ su.c        Wed Aug 15 14:04:29 2001
> @@ -413,7 +413,7 @@
>  static void
>  usage()
>  {
> -       (void)fprintf(stderr, "usage: su [%s] [login [args]]\n", ARGSTR);
> +       (void)fprintf(stderr, "usage: su [-flm] [-c class] [login [args]]\n");
>         exit(1);
> 
I have committed your fix to HEAD, but for RELENG_4 the correct fix is
not so obvious:

Index: su.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/su/su.c,v
retrieving revision 1.34.2.2
diff -u -p -r1.34.2.2 su.c
--- su.c	2001/06/19 00:26:30	1.34.2.2
+++ su.c	2001/08/15 15:36:56
@@ -413,7 +413,18 @@ main(argc, argv)
 static void
 usage()
 {
-	(void)fprintf(stderr, "usage: su [%s] [login [args]]\n", ARGSTR);
+	(void)fprintf(stderr, "usage: su [-] %s%s[login [args]]\n",
+#ifdef KERBEROS
+	    "[-Kflm] ",
+#else
+	    "[-flm] ",
+#endif
+#ifdef LOGIN_CAP
+	    "[-c class] "
+#else
+	    ""
+#endif
+	    );
 	exit(1);
 }
 

Cheers,
-- 
Ruslan Ermilov		Oracle Developer/DBA,
ru@sunbay.com		Sunbay Software AG,
ru@FreeBSD.org		FreeBSD committer,
+380.652.512.251	Simferopol, Ukraine

http://www.FreeBSD.org	The Power To Serve
http://www.oracle.com	Enabling The Information Age
Comment 2 dd freebsd_committer freebsd_triage 2001-08-16 03:15:39 UTC
Responsible Changed
From-To: freebsd-bugs->mikem

The fix seems reasonable, but I think Mark should deal with this, since 
he's made most of the commits to su(1) lately, including the one that 
broke this.
Comment 3 dd freebsd_committer freebsd_triage 2001-08-16 03:16:28 UTC
Responsible Changed
From-To: mikem->markm

oops: 

The fix seems reasonable, but I think Mark should deal with this, since 
he's made most of the commits to su(1) lately, including the one that 
broke this.
Comment 4 dd freebsd_committer freebsd_triage 2001-08-16 03:17:16 UTC
Responsible Changed
From-To: markm->ru

Actually, Ruslan seems to have already fixed it.  I have no idea why my 
MUA decided to show the reply to the PR a page later after the original :-/. 
Sorry for the trouble, Mark.
Comment 5 ru freebsd_committer freebsd_triage 2001-08-17 16:44:41 UTC
State Changed
From-To: open->closed

Fixed in 5.0-CURRENT and 4.4-RC, thanks!