Fix bad option processing.

PR:		bin/7986
Submitted by:	Dan Nelson <dnelson@emsphone.com>
This commit is contained in:
Ollivier Robert 1998-09-21 07:47:53 +00:00
parent 5b036e2b3c
commit d6bc2e88c1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=39538

View File

@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)su.c 8.3 (Berkeley) 4/2/94";
#endif
static const char rcsid[] =
"$Id: su.c,v 1.26 1998/05/25 03:34:52 steve Exp $";
"$Id: su.c,v 1.27 1998/05/26 06:39:08 danny Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -134,8 +134,7 @@ main(argc, argv)
#endif /* WHEELSU */
asme = asthem = fastlogin = 0;
user = "root";
while(optind < argc)
if((ch = getopt(argc, argv, ARGSTR)) != -1)
while((ch = getopt(argc, argv, ARGSTR)) != -1)
switch((char)ch) {
#ifdef KERBEROS
case 'K':
@ -163,11 +162,9 @@ main(argc, argv)
default:
usage();
}
else
{
if (optind < argc)
user = argv[optind++];
break;
}
if (strlen(user) > MAXLOGNAME - 1) {
(void)fprintf(stderr, "su: username too long.\n");