[Pkg-shadow-devel] patch for login - 3

Nicolas François nicolas.francois@centraliens.net
Wed, 1 Jun 2005 22:33:12 +0200


--ew6BAiZeqk4r7MaW
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Jun 01, 2005 at 08:42:41AM +0200, Tomasz K=C5=82oczko wrote:
> I'll little busy to end of week .. do you check is it two patches can b=
e =20
> cleanly aplayed to current CVS tree ?

Eh eh, good question.

There was no problem, but here are patches that apply without warning.

--=20
Nekral

--ew6BAiZeqk4r7MaW
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=008_login_opt-f_with_username_after--

Goal: Made login's -f option also able to use the username after -- if none
      was passed as it's optarg
Fixes: #53702

Status wrt upstream: I'm not sure, but it is probably not in upstream.
                     It could certainly be submitted to upstream.

--- login.c.orig	2005-06-01 21:37:17.000000000 +0200
+++ login.c	2005-06-01 21:46:32.000000000 +0200
@@ -369,7 +369,7 @@
 
 	check_flags (argc, argv);
 
-	while ((flag = getopt (argc, argv, "d:f:h:pr:")) != EOF) {
+	while ((flag = getopt (argc, argv, "d:f::h:pr:")) != EOF) {
 		switch (flag) {
 		case 'p':
 			pflg++;
@@ -378,11 +378,16 @@
 			/*
 			 * username must be a separate token
 			 * (-f root, *not* -froot).  --marekm
+			 *
+			 * if -f has an arg, use that, else use the
+			 * normal user name passed after all options
+			 * --benc
 			 */
-			if (optarg != argv[optind - 1])
+			if (optarg != NULL && optarg != argv[optind - 1])
 				usage ();
 			fflg++;
-			STRFCPY (username, optarg);
+			if (optarg)
+			  STRFCPY (username, optarg);
 			break;
 #ifdef	RLOGIN
 		case 'r':
@@ -535,7 +540,7 @@
 		init_env ();
 
 		if (optind < argc) {	/* get the user name */
-			if (rflg || fflg)
+			if (rflg || (fflg && username[0]))
 				usage ();
 
 			STRFCPY (username, argv[optind]);

--ew6BAiZeqk4r7MaW
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=008_login_stop_checking_args_after--

Goal: terminate argument validation in login when it hits a '--'.
Fixes: #66368

Status wrt upstream: It could certainly be submitted to upstream.

--- login.c.orig	2005-06-01 21:37:17.000000000 +0200
+++ login.c	2005-06-01 21:49:53.000000000 +0200
@@ -258,6 +258,8 @@
 	for (arg = 1; arg < argc; arg++) {
 		if (argv[arg][0] == '-' && strlen (argv[arg]) > 2)
 			usage ();
+		if (!strcmp(argv[arg], "--"))
+			break; /* stop checking on a "--" */
 	}
 }
 

--ew6BAiZeqk4r7MaW--