[Pkg-shadow-commits] r1455 - in upstream/trunk: . src

nekral-guest at alioth.debian.org nekral-guest at alioth.debian.org
Sat Nov 24 00:26:31 UTC 2007


Author: nekral-guest
Date: 2007-11-24 00:26:31 +0000 (Sat, 24 Nov 2007)
New Revision: 1455

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/src/newusers.c
Log:
* Provide the crypt method to all the
  crypt_make_salt invocations.
* Tag the ENCRYPTMETHOD_SELECT dependent code
  accordingly.


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2007-11-24 00:16:41 UTC (rev 1454)
+++ upstream/trunk/ChangeLog	2007-11-24 00:26:31 UTC (rev 1455)
@@ -1,5 +1,12 @@
 2007-11-24  Nicolas François  <nicolas.francois at centraliens.net>
 
+	* src/newusers.c: Provide the crypt method to all the
+	crypt_make_salt invocations.
+	* src/newusers.c: Tag the ENCRYPTMETHOD_SELECT dependent code
+	accordingly.
+
+2007-11-24  Nicolas François  <nicolas.francois at centraliens.net>
+
 	* libmisc/salt.c: Make sure method is not NULL, defaulting to DES.
 	Thanks to Dan Kopecek <dkopecek at redhat.com>.
 	* src/chpasswd.c, src/chgpasswd.c: Do not use DES by default, but

Modified: upstream/trunk/src/newusers.c
===================================================================
--- upstream/trunk/src/newusers.c	2007-11-24 00:16:41 UTC (rev 1454)
+++ upstream/trunk/src/newusers.c	2007-11-24 00:26:31 UTC (rev 1455)
@@ -234,10 +234,10 @@
 
 static void update_passwd (struct passwd *pwd, const char *passwd)
 {
-	void *arg = NULL;
+	void *crypt_arg = NULL;
 	if (crypt_method != NULL) {
 		if (sflg)
-			arg = &sha_rounds;
+			crypt_arg = &sha_rounds;
 	}
 
 	if (crypt_method != NULL && 0 == strcmp(crypt_method, "NONE")) {
@@ -245,7 +245,7 @@
 	} else {
 		pwd->pw_passwd = pw_encrypt (passwd,
 		                             crypt_make_salt (crypt_method,
-		                                              arg));
+		                                              crypt_arg));
 	}
 }
 
@@ -256,6 +256,11 @@
 {
 	const struct spwd *sp;
 	struct spwd spent;
+	void *crypt_arg = NULL;
+	if (crypt_method != NULL) {
+		if (sflg)
+			crypt_arg = &sha_rounds;
+	}
 
 	/*
 	 * In the case of regular password files, this is real easy - pwd
@@ -274,7 +279,8 @@
 	if ((sp = spw_locate (pwd->pw_name))) {
 		spent = *sp;
 		spent.sp_pwdp = pw_encrypt (passwd,
-		                            crypt_make_salt (NULL, NULL));
+		                            crypt_make_salt (crypt_method,
+		                                             crypt_arg));
 		return !spw_update (&spent);
 	}
 
@@ -294,7 +300,8 @@
 	 * shadow password file entry.
 	 */
 	spent.sp_namp = pwd->pw_name;
-	spent.sp_pwdp = pw_encrypt (passwd, crypt_make_salt (NULL, NULL));
+	spent.sp_pwdp = pw_encrypt (passwd,
+	                            crypt_make_salt (crypt_method, crypt_arg));
 	spent.sp_lstchg = time ((time_t *) 0) / SCALE;
 	spent.sp_min = getdef_num ("PASS_MIN_DAYS", 0);
 	/* 10000 is infinity this week */
@@ -337,12 +344,20 @@
 		static struct option long_options[] = {
 			{"crypt-method", required_argument, NULL, 'c'},
 			{"help", no_argument, NULL, 'h'},
+#ifdef ENCRYPTMETHOD_SELECT
 			{"sha-rounds", required_argument, NULL, 's'},
+#endif
 			{NULL, 0, NULL, '\0'}
 		};
 
 		while ((c =
-			getopt_long (argc, argv, "c:hs:", long_options,
+			getopt_long (argc, argv,
+#ifdef ENCRYPTMETHOD_SELECT
+			             "c:hs:",
+#else
+			             "c:h",
+#endif
+			             long_options,
 			             &option_index)) != -1) {
 			switch (c) {
 			case 'c':
@@ -352,6 +367,7 @@
 			case 'h':
 				usage ();
 				break;
+#ifdef ENCRYPTMETHOD_SELECT
 			case 's':
 				sflg = 1;
 				if (!getlong(optarg, &sha_rounds)) {
@@ -361,6 +377,7 @@
 					usage ();
 				}
 				break;
+#endif
 			case 0:
 				/* long option */
 				break;




More information about the Pkg-shadow-commits mailing list