Bug#142070: [Pkg-shadow-devel] Bug#142070: Patch applied in sarge branch

Christian Perrier Christian Perrier <bubulle@debian.org>, 142070@bugs.debian.org
Wed, 6 Apr 2005 09:15:07 +0200


--6c2NcOVqGQ03X4Wi
Content-Type: text/plain; charset=iso-8859-15
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by onera.onera.fr id j367F8k9006800

Quoting Christian Perrier (bubulle@debian.org):
> Attached is the patch we applied to sarge regarding this bug.
>=20
> We have to check if it applies cleanly in woody.


The attached patch applies cleanly.

I'm currently building a new version of the shadow package on a woody
system to check if this fixes the DES/MD5 problem.

PS=A0: the build system of shadow in woody in incredibly better. All
Debian specific patches were in debian/patches and there was a clean
line between Debian specific patches and upstream sources, not the
mess we currently have....:-(. This is exactly what I want to get back
with the 4.0.3-32 release and the use of dpatch.







--6c2NcOVqGQ03X4Wi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="patch.142070"

--- chpasswd.c.ori	Wed Apr  6 09:07:01 2005
+++ chpasswd.c	Wed Apr  6 08:59:47 2005
@@ -50,6 +50,7 @@
 #include "defines.h"
 #include <pwd.h>
 #include <fcntl.h>
+#include <getopt.h>
 #include "pwio.h"
 #ifdef	SHADOWPWD
 #include "shadowio.h"
@@ -57,6 +58,7 @@
 
 static char *Prog;
 static int eflg = 0;
+static int md5flg = 0;
 #ifdef SHADOWPWD
 static int is_shadow_pwd;
 #endif
@@ -73,7 +75,7 @@
 static void
 usage(void)
 {
-	fprintf(stderr, _("usage: %s [-e]\n"), Prog);
+ 	fprintf (stderr, _("usage: %s [--encrypted] [--md5]\n"), Prog);
 	exit(1);
 }
 
@@ -104,11 +106,32 @@
 	bindtextdomain(PACKAGE, LOCALEDIR);
 	textdomain(PACKAGE);
 
-	/* XXX - use getopt() */
-	if (!(argc == 1 || (argc == 2 && !strcmp(argv[1], "-e"))))
-		usage();
-	if (argc == 2)
-		eflg = 1;
+	{
+		int option_index = 0;
+		int c;
+		static struct option long_options[] = {
+			{ "encrypted",	no_argument,	&eflg,	1 },
+			{ "md5",	no_argument,	&md5flg,	1 },
+			{ 0 }
+		};
+
+		while ((c = getopt_long(argc,argv,"em",long_options,&option_index)) != -1) {
+			switch (c) {
+				case 'e':
+					eflg = 1;
+					break;
+				case 'm':
+					md5flg = 1;
+					break;
+				case 0:
+					/* long option */
+					break;
+				default:
+					usage();
+					break;
+			}
+		}
+	}
 
 	/*
 	 * Lock the password file and open it for reading.  This will
@@ -182,8 +205,14 @@
 			continue;
 		}
 		newpwd = cp;
-		if (!eflg)
-			cp = pw_encrypt(newpwd, crypt_make_salt());
+		if (!eflg) {
+			if (md5flg) {
+				char salt[12] = "$1$";
+				strcat(salt,crypt_make_salt());
+				cp = pw_encrypt (newpwd, salt);
+			} else
+				cp = pw_encrypt (newpwd, crypt_make_salt());
+		}
 
 		/*
 		 * Get the password file entry for this user.  The user

--6c2NcOVqGQ03X4Wi--