summaryrefslogtreecommitdiff
path: root/packages/tinylogin/tinylogin-1.4/cvs-20040608.patch
blob: 1142329a67740e53c74ce97dbcdf107bb9cd0b6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
Index: Config.h
===================================================================
RCS file: /var/cvs/tinylogin/Config.h,v
retrieving revision 1.10
retrieving revision 1.12
diff -u -r1.10 -r1.12
--- a/Config.h	23 Jun 2002 03:09:07 -0000	1.10
+++ b/Config.h	17 Feb 2003 11:51:55 -0000	1.12
@@ -27,15 +27,11 @@
 // Enable checking of /etc/securetty by login
 #define CONFIG_FEATURE_SECURETTY
 //
-// Enable using sha passwords
-#define CONFIG_FEATURE_SHA1_PASSWORDS
-//
 // Enable use of a wheel group
 #define CONFIG_WHEEL_GROUP
 //
-// This compiles out everything but the most 
-// trivial --help usage information (i.e. reduces binary size)
-#define CONFIG_FEATURE_TRIVIAL_HELP
+// Show verbose usage messages
+//#define CONFIG_FEATURE_VERBOSE_USAGE
 //
 // Enable 'tinylogin --install [-s]' to allow tinylogin
 // to create links (or symlinks) at runtime for all the 
@@ -48,10 +44,6 @@
 // Nothing beyond this point should ever be touched by 
 // mere mortals so leave this stuff alone.
 //
-#ifdef CONFIG_FEATURE_SHA1_PASSWORDS
-#define CONFIG_SHA1
-#endif
-//
 #ifdef CONFIG_FEATURE_SHADOWPASSWDS
 #define CONFIG_SHADOW
 #endif
Index: addgroup.c
===================================================================
RCS file: /var/cvs/tinylogin/addgroup.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- a/addgroup.c	12 Dec 2002 08:46:03 -0000	1.22
+++ b/addgroup.c	9 Jan 2003 18:43:29 -0000	1.23
@@ -133,23 +133,33 @@
  * ________________________________________________________________________ */
 int addgroup_main(int argc, char **argv)
 {
+	int opt;
 	char *group;
 	char *user;
 	gid_t gid = 0;
 
-	if (argc < 2) {
-		show_usage();
+	/* get remaining args */
+	while ((opt = getopt (argc, argv, "g:")) != -1) {
+		switch (opt) {
+			case 'g':
+				gid = strtol(optarg, NULL, 10);
+				break;
+			default:
+				show_usage();
+				break;
+		}
 	}
 
-	if (strncmp(argv[1], "-g", 2) == 0) {
-		gid = strtol(argv[2], NULL, 10);
-		group = argv[2];
+	if (optind < argc) {
+		group = argv[optind];
+		optind++;
 	} else {
 		show_usage();
 	}
-	
-	if (argc == 4) {
-		user = argv[3];
+
+	if (optind < argc) {
+		user = argv[optind];
+		optind++;
 	} else {
 		user = "";
 	}
@@ -163,4 +173,4 @@
 	return addgroup(GROUP_FILE, group, gid, user);
 }
 
-/* $Id: addgroup.c,v 1.22 2002/12/12 08:46:03 andersen Exp $ */
+/* $Id: addgroup.c,v 1.23 2003/01/09 18:43:29 andersen Exp $ */
Index: adduser.c
===================================================================
RCS file: /var/cvs/tinylogin/adduser.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- a/adduser.c	12 Dec 2002 08:46:03 -0000	1.37
+++ b/adduser.c	21 Jun 2003 19:35:42 -0000	1.38
@@ -21,6 +21,9 @@
  *
  */
 
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
 #include <errno.h>
 #include <fcntl.h>
 #include <stdarg.h>
@@ -29,6 +32,7 @@
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
+#include <getopt.h>
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -93,21 +97,23 @@
 		}
 	}
 
-	/* EDR check for an already existing gid */
-	while (getgrgid(p->pw_uid) != NULL)
-		p->pw_uid++;
-
-	/* EDR also check for an existing group definition */
-	if (getgrnam(p->pw_name) != NULL)
-		return 3;
+	if (p->pw_gid == 0) {
+		/* EDR check for an already existing gid */
+		while (getgrgid(p->pw_uid) != NULL)
+			p->pw_uid++;
+
+		/* EDR also check for an existing group definition */
+		if (getgrnam(p->pw_name) != NULL)
+			return 3;
+
+		/* EDR create new gid always = uid */
+		p->pw_gid = p->pw_uid;
+	}
 
 	/* EDR bounds check */
 	if ((p->pw_uid > max) || (p->pw_uid < min))
 		return 2;
 
-	/* EDR create new gid always = uid */
-	p->pw_gid = p->pw_uid;
-
 	/* return 1; */
 	return 0;
 }
@@ -136,7 +142,7 @@
 }
 
 /* putpwent(3) remix */
-static int adduser(const char *filename, struct passwd *p)
+static int adduser(const char *filename, struct passwd *p, int makehome, int setpass)
 {
 	FILE *passwd;
 	int r;
@@ -144,6 +150,11 @@
 	FILE *shadow;
 	struct spwd *sp;
 #endif
+	int new_group = 1;
+
+	/* if using a pre-existing group, don't create one */
+	if (p->pw_gid != 0)
+		new_group = 0;
 
 	/* make sure everything is kosher and setup uid && gid */
 	passwd = wfopen(filename, "a");
@@ -194,29 +205,36 @@
 	}
 #endif
 
-	/* add to group */
-	/* addgroup should be responsible for dealing w/ gshadow */
-	addgroup_wrapper(p->pw_name, p->pw_gid);
+	if (new_group) {
+		/* add to group */
+		/* addgroup should be responsible for dealing w/ gshadow */
+		addgroup_wrapper(p->pw_name, p->pw_gid);
+	}
 
 	/* Clear the umask for this process so it doesn't
 	 * * screw up the permissions on the mkdir and chown. */
 	umask(0);
 
-	/* mkdir */
-	if (mkdir(p->pw_dir, 0755)) {
-		perror_msg("%s", p->pw_dir);
-	}
-	/* Set the owner and group so it is owned by the new user. */
-	if (chown(p->pw_dir, p->pw_uid, p->pw_gid)) {
-		perror_msg("%s", p->pw_dir);
-	}
-	/* Now fix up the permissions to 2755. Can't do it before now
-	 * since chown will clear the setgid bit */
-	if (chmod(p->pw_dir, 02755)) {
-		perror_msg("%s", p->pw_dir);
+	if (makehome) {
+		/* mkdir */
+		if (mkdir(p->pw_dir, 0755)) {
+			perror_msg("%s", p->pw_dir);
+		}
+		/* Set the owner and group so it is owned by the new user. */
+		if (chown(p->pw_dir, p->pw_uid, p->pw_gid)) {
+			perror_msg("%s", p->pw_dir);
+		}
+		/* Now fix up the permissions to 2755. Can't do it before now
+		 * since chown will clear the setgid bit */
+		if (chmod(p->pw_dir, 02755)) {
+			perror_msg("%s", p->pw_dir);
+		}
+	}
+
+	if (setpass) {
+		/* interactively set passwd */
+		passwd_wrapper(p->pw_name);
 	}
-	/* interactively set passwd */
-	passwd_wrapper(p->pw_name);
 
 	return 0;
 }
@@ -228,6 +246,15 @@
 	return geteuid();
 }
 
+struct option long_options[] = {
+  { "home",		1, NULL, 'h' },
+  { "disabled-password", 0, NULL, 'D' },
+  { "system",		0, NULL, 'S' },
+  { "ingroup",		1, NULL, 'G' },
+  { "no-create-home",   0, NULL, 'H' },
+  { 0,			0, 0, 0 }
+};
+
 /*
  * adduser will take a login_name as its first parameter.
  *
@@ -244,6 +271,11 @@
 	const char *gecos;
 	const char *home = NULL;
 	const char *shell;
+	const char *usegroup = NULL;
+	int option_index = -1;
+	int setpass = 1;
+	int makehome = 1;
+	int system = 0;
 
 	struct passwd pw;
 
@@ -255,7 +287,7 @@
 	shell = default_shell;
 
 	/* get args */
-	while ((opt = getopt (argc, argv, "h:g:s:")) != -1) {
+	while ((opt = getopt_long (argc, argv, "h:g:s:G:DSH", long_options, &option_index)) != -1) {
 		switch (opt) {
 			case 'h':
 				home = optarg;
@@ -266,6 +298,18 @@
 			case 's':
 				shell = optarg;
 				break;
+			case 'H':
+				makehome = 0;
+				break;
+			case 'D':
+				setpass = 0;
+				break;
+			case 'S':
+				system = 1;
+				break;
+			case 'G':
+				usegroup = optarg;
+				break;
 			default:
 				show_usage ();
 				break;
@@ -301,8 +345,19 @@
 	pw.pw_dir = (char *)home;
 	pw.pw_shell = (char *)shell;
 
+	if (usegroup) {
+		/* Add user to a group that already exists */
+		struct group *g;
+
+		g = getgrnam(usegroup);
+		if (g == NULL)
+			error_msg_and_die("group %s does not exist", usegroup);
+
+		pw.pw_gid = g->gr_gid;
+	}
+
 	/* grand finale */
-	return adduser(PASSWD_FILE, &pw);
+	return adduser(PASSWD_FILE, &pw, makehome, setpass);
 }
 
-/* $Id: adduser.c,v 1.37 2002/12/12 08:46:03 andersen Exp $ */
+/* $Id: adduser.c,v 1.38 2003/06/21 19:35:42 andersen Exp $ */
Index: install.sh
===================================================================
RCS file: /var/cvs/tinylogin/install.sh,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- a/install.sh	23 Jun 2002 03:09:07 -0000	1.10
+++ b/install.sh	6 Mar 2003 19:29:17 -0000	1.11
@@ -21,11 +21,11 @@
 h=`sort tinylogin.links | uniq`
 
 
-mkdir -p $prefix/bin || exit 1
+install -d -m 0755 $prefix/bin || exit 1
 
 for i in $h ; do
 	appdir=`dirname $i`
-	mkdir -p $prefix/$appdir || exit 1
+	install -d -m 0755 $prefix/$appdir || exit 1
 	if [ "$2" = "--hardlinks" ]; then
 	    bb_path="$prefix/bin/tinylogin"
 	else
Index: passwd.c
===================================================================
RCS file: /var/cvs/tinylogin/passwd.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- a/passwd.c	7 Nov 2002 02:34:15 -0000	1.19
+++ b/passwd.c	17 Feb 2003 11:51:55 -0000	1.20
@@ -25,10 +25,6 @@
 {
 	int x = 0;					/* standart: DES */
 
-#ifdef CONFIG_FEATURE_SHA1_PASSWORDS
-	if (strcasecmp(a, "sha1") == 0)
-		x = 2;
-#endif
 	if (strcasecmp(a, "md5") == 0)
 		x = 1;
 	return x;
@@ -394,11 +390,6 @@
 	bzero(cp, strlen(cp));
 	bzero(orig, sizeof(orig));
 
-#ifdef CONFIG_FEATURE_SHA1_PASSWORDS
-	if (algo == 2) {
-		cp = pw_encrypt(pass, "$2$");
-	} else
-#endif
 	if (algo == 1) {
 		cp = pw_encrypt(pass, "$1$");
 	} else
Index: sha1.c
===================================================================
RCS file: sha1.c
diff -N sha1.c
--- a/sha1.c	20 Dec 2000 21:54:28 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,187 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/* 
-   Implements the Secure Hash Algorithm (SHA1)
-
-   Copyright (C) 1999 Scott G. Miller
-
-   Released under the terms of the GNU General Public License v2
-   see file COPYING for details
-
-   Credits: 
-      Robert Klep <robert@ilse.nl>  -- Expansion function fix 
-   ---
-   FIXME: This source takes int to be a 32 bit integer.  This
-   may vary from system to system.  I'd use autoconf if I was familiar
-   with it.  Anyone want to help me out?
-*/
-
-void sha_hash(int *, int *);
-void sha_init(int *);
-char *sprint_hash(int *);
-void do_sha_hash(int *, int *);
-
-/*
-  added 3 functions for sha passowrd stuff (mainly inspired from stuff seen in main.c from shasum-1.3 package)
-*/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <endian.h>
-/* On big endian machines, we need to reverse the input to process
-   the blocks correctly */
-
-#define switch_endianness(x) (x<<24 & 0xff000000) | \
-                             (x<<8  & 0x00ff0000) | \
-                             (x>>8  & 0x0000ff00) | \
-                             (x>>24 & 0x000000ff)
-
-/* Initial hash values */
-#define Ai 0x67452301
-#define Bi 0xefcdab89
-#define Ci 0x98badcfe
-#define Di 0x10325476
-#define Ei 0xc3d2e1f0
-
-/* SHA1 round constants */
-#define K1 0x5a827999
-#define K2 0x6ed9eba1
-#define K3 0x8f1bbcdc
-#define K4 0xca62c1d6
-
-/* Round functions.  Note that f2() is used in both rounds 2 and 4 */
-#define f1(B,C,D) ((B & C) | ((~B) & D))
-#define f2(B,C,D) (B ^ C ^ D)
-#define f3(B,C,D) ((B & C) | (B & D) | (C & D))
-
-/* left circular shift functions (rotate left) */
-#define rol1(x) ((x<<1) | ((x>>31) & 1))
-#define rol5(A) ((A<<5) | ((A>>27) & 0x1f))
-#define rol30(B) ((B<<30) | ((B>>2) & 0x3fffffff))
-
-/*
-  Hashes 'data', which should be a pointer to 512 bits of data (sixteen
-  32 bit ints), into the ongoing 160 bit hash value (five 32 bit ints)
-  'hash'
-*/
-void sha_hash(int *data, int *hash)
-{
-	int W[80];
-	unsigned int A = hash[0], B = hash[1], C = hash[2], D = hash[3], E =
-		hash[4];
-	unsigned int t, x, TEMP;
-
-	for (t = 0; t < 16; t++) {
-#ifdef BIG_ENDIAN
-		W[t] = switch_endianness(data[t]);
-#else
-		W[t] = data[t];
-#endif
-	}
-
-
-	/* SHA1 Data expansion */
-	for (t = 16; t < 80; t++) {
-		x = W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16];
-		W[t] = rol1(x);
-	}
-
-	/* SHA1 main loop (t=0 to 79) 
-	   This is broken down into four subloops in order to use
-	   the correct round function and constant */
-	for (t = 0; t < 20; t++) {
-		TEMP = rol5(A) + f1(B, C, D) + E + W[t] + K1;
-		E = D;
-		D = C;
-		C = rol30(B);
-		B = A;
-		A = TEMP;
-	}
-	for (; t < 40; t++) {
-		TEMP = rol5(A) + f2(B, C, D) + E + W[t] + K2;
-		E = D;
-		D = C;
-		C = rol30(B);
-		B = A;
-		A = TEMP;
-	}
-	for (; t < 60; t++) {
-		TEMP = rol5(A) + f3(B, C, D) + E + W[t] + K3;
-		E = D;
-		D = C;
-		C = rol30(B);
-		B = A;
-		A = TEMP;
-	}
-	for (; t < 80; t++) {
-		TEMP = rol5(A) + f2(B, C, D) + E + W[t] + K4;
-		E = D;
-		D = C;
-		C = rol30(B);
-		B = A;
-		A = TEMP;
-	}
-	hash[0] += A;
-	hash[1] += B;
-	hash[2] += C;
-	hash[3] += D;
-	hash[4] += E;
-}
-
-/*
-  Takes a pointer to a 160 bit block of data (five 32 bit ints) and
-  intializes it to the start constants of the SHA1 algorithm.  This
-  must be called before using hash in the call to sha_hash
-*/
-void sha_init(int *hash)
-{
-	hash[0] = Ai;
-	hash[1] = Bi;
-	hash[2] = Ci;
-	hash[3] = Di;
-	hash[4] = Ei;
-}
-
-
-/*
- * write the hash to a string
- */
-char *sprint_sha1_hash(int *hashval)
-{
-	int x = 0;
-	char *out = NULL;
-
-	if ((out = malloc(43)) == NULL)
-		return NULL;
-	memset(out, 0x00, 43);
-	strcpy(out, "$2$");
-	for (x = 0; x < 5; x++) {
-		sprintf(out + (x * 8) + 3, "%08x", hashval[x]);
-	}
-	out[43] = 0;
-	return out;
-}
-
-
-/*
- * hash the password
- */
-void do_sha_hash(int *hashval, int *pw)
-{
-	sha_init(hashval);
-	sha_hash(pw, hashval);
-}
-
-
-/*
- * hash a charakter string and return the 160bit integer in hex as a character string
- */
-char *sha1_crypt(const char *pw)
-{
-	int hashval[20];
-
-	memset(hashval, 0x00, sizeof(hashval));
-	do_sha_hash(hashval, (int *) ((char *) pw + 3));
-
-	return sprint_sha1_hash(hashval);
-}
Index: vlock.c
===================================================================
RCS file: /var/cvs/tinylogin/vlock.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- a/vlock.c	19 Sep 2002 03:50:31 -0000	1.13
+++ b/vlock.c	17 Feb 2003 11:51:56 -0000	1.14
@@ -26,7 +26,7 @@
  * minimalistic vlock.
  */
 /* Fixed by Erik Andersen to do passwords the tinylogin way...
- * It now works with md5, sha1, etc passwords. */
+ * It now works with md5, etc passwords. */
 
 #include "tinylogin.h"
 #include <stdio.h>
Index: docs/tinylogin.busybox.net/index.html
===================================================================
RCS file: /var/cvs/tinylogin/docs/tinylogin.busybox.net/index.html,v
retrieving revision 1.23
retrieving revision 1.25
diff -u -r1.23 -r1.25
--- a/docs/tinylogin.busybox.net/index.html	3 Jan 2003 10:56:32 -0000	1.23
+++ b/docs/tinylogin.busybox.net/index.html	3 Jan 2003 11:21:53 -0000	1.25
@@ -56,6 +56,9 @@
 Erik Andersen</a>, and licensed under the 
 <a href="http://www.gnu.org/copyleft/gpl.html">GNU GENERAL PUBLIC LICENSE</a>.
 
+<h3>Mailing List Information</h3>
+Here are the Tinylogin <a href="/lists/tinylogin/">mailing list archives</a><br>
+To subscribe, go and visit <a href= "/mailman/listinfo/tinylogin">this page</a>. 
 
 <!-- Begin Download section -->
 
@@ -222,19 +225,19 @@
 <ul> 
     <li>  <A HREF="http://freshmeat.net/projects/tinylogin/?highlight=tinylogin">
     Freshmeat AppIndex record for TinyLogin</A>
+    <p>
 
     <li><a href="http://www.busybox.net/">BusyBox</a>
     combines tiny versions of many common UNIX utilities into a single small 
     executable. It provides minimalist replacements for most of the utilities 
     you usually find on a standard Linux system.
-
     <p>
+
     <li><a href="http://uclibc.org/uClibc.html">uClibc</a>
 	is a C library for embedded systems.  You can actually statically link
 	a "Hello World" application under x86 that only takes 4k (as opposed to
 	200k under GNU libc).  It can do dynamic linking too and works nicely with
 	BusyBox to create very small embedded systems.
-
     <p>
 
 </ul>
Index: include/libbb.h
===================================================================
RCS file: /var/cvs/tinylogin/include/libbb.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- a/include/libbb.h	23 Jun 2002 03:09:10 -0000	1.1
+++ b/include/libbb.h	17 Feb 2003 11:51:57 -0000	1.2
@@ -39,9 +39,6 @@
 #ifdef CONFIG_FEATURE_SHADOWPASSWDS
 #include "shadow_.h"
 #endif
-#ifdef CONFIG_FEATURE_SHA1_PASSWORDS
-# include "sha1.h"
-#endif
 
 #if (__GNU_LIBRARY__ < 5) && (!defined __dietlibc__)
 /* libc5 doesn't define socklen_t */
Index: include/sha1.h
===================================================================
RCS file: include/sha1.h
diff -N include/sha1.h
--- a/include/sha1.h	23 Jun 2002 03:09:10 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,3 +0,0 @@
-/* SHA1.H - header file for SHA1.C */
-
-char *sha1_crypt(const char *pw);
Index: include/usage.h
===================================================================
RCS file: /var/cvs/tinylogin/include/usage.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- a/include/usage.h	3 Jul 2002 05:57:00 -0000	1.2
+++ b/include/usage.h	17 Feb 2003 11:51:57 -0000	1.3
@@ -33,11 +33,6 @@
 	"\t-h\tName of the remote host for this login.\n" \
 	"\t-p\tPreserve environment."
 
-#ifdef CONFIG_FEATURE_SHA1_PASSWORDS
-  #define PASSWORD_ALG_TYPES(a) a
-#else
-  #define PASSWORD_ALG_TYPES(a)
-#endif
 #define passwd_trivial_usage \
 	"[OPTION] [name]"
 #define passwd_full_usage \
@@ -46,7 +41,6 @@
 	"Options:\n" \
 	"\t-a\tDefine which algorithm shall be used for the password.\n" \
 	"\t\t\t(Choices: des, md5" \
-	PASSWORD_ALG_TYPES(", sha1") \
 	")\n\t-d\tDelete the password for the specified user account.\n" \
 	"\t-l\tLocks (disables) the specified user account.\n" \
 	"\t-u\tUnlocks (re-enables) the specified user account."
Index: libbb/obscure.c
===================================================================
RCS file: /var/cvs/tinylogin/libbb/obscure.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- a/libbb/obscure.c	23 Jun 2002 04:05:59 -0000	1.2
+++ b/libbb/obscure.c	30 Jul 2003 08:41:33 -0000	1.3
@@ -44,7 +44,7 @@
  * can't be a palindrome - like `R A D A R' or `M A D A M'
  */
 
-static int palindrome(const char *old, const char *newval)
+static int palindrome(const char *newval)
 {
 	int i, j;
 
@@ -79,24 +79,25 @@
  * a nice mix of characters.
  */
 
-static int simple(const char *old, const char *newval)
+static int simple(const char *newval)
 {
 	int digits = 0;
 	int uppers = 0;
 	int lowers = 0;
 	int others = 0;
+	int c;
 	int size;
 	int i;
 
-	for (i = 0; newval[i]; i++) {
-		if (isdigit(newval[i]))
-			digits++;
-		else if (isupper(newval[i]))
-			uppers++;
-		else if (islower(newval[i]))
-			lowers++;
+	for (i = 0; (c = *newval++) != 0; i++) {
+		if (isdigit(c))
+			digits = c;
+		else if (isupper(c))
+			uppers = c;
+		else if (islower(c))
+			lowers = c;
 		else
-			others++;
+			others = c;
 	}
 
 	/*
@@ -129,49 +130,53 @@
 	return string;
 }
 
-static char *password_check(const char *old, const char *newval, const struct passwd *pwdp)
+static const char *
+password_check(const char *old, const char *newval, const struct passwd *pwdp)
 {
-	char *msg = NULL;
-	char *oldmono, *newmono, *wrapped;
+	const char *msg;
+	char *newmono, *wrapped;
+	int lenwrap;
 
 	if (strcmp(newval, old) == 0)
 		return "no change";
+	if (simple(newval))
+		return "too simple";
 
+	msg = NULL;
 	newmono = str_lower(xstrdup(newval));
-	oldmono = str_lower(xstrdup(old));
-	wrapped = (char *) xmalloc(strlen(oldmono) * 2 + 1);
-	strcpy(wrapped, oldmono);
-	strcat(wrapped, oldmono);
+	lenwrap = strlen(old) * 2 + 1;
+	wrapped = (char *) xmalloc(lenwrap);
+	str_lower(strcpy(wrapped, old));
 
-	if (palindrome(oldmono, newmono))
+	if (palindrome(newmono))
 		msg = "a palindrome";
 
-	if (!msg && strcmp(oldmono, newmono) == 0)
+	else if (strcmp(wrapped, newmono) == 0)
 		msg = "case changes only";
 
-	if (!msg && similiar(oldmono, newmono))
+	else if (similiar(wrapped, newmono))
 		msg = "too similiar";
 
-	if (!msg && simple(old, newval))
-		msg = "too simple";
-
-	if (!msg && strstr(wrapped, newmono))
-		msg = "rotated";
+	else {
+		safe_strncpy(wrapped + lenwrap, wrapped, lenwrap + 1);
+		if (strstr(wrapped, newmono))
+			msg = "rotated";
+	}
 
 	bzero(newmono, strlen(newmono));
-	bzero(oldmono, strlen(oldmono));
-	bzero(wrapped, strlen(wrapped));
+	bzero(wrapped, lenwrap);
 	free(newmono);
-	free(oldmono);
 	free(wrapped);
 
 	return msg;
 }
 
-static char *obscure_msg(const char *old, const char *newval, const struct passwd *pwdp)
+static const char *
+obscure_msg(const char *old, const char *newval, const struct passwd *pwdp)
 {
 	int maxlen, oldlen, newlen;
-	char *new1, *old1, *msg;
+	char *new1, *old1;
+	const char *msg;
 
 	oldlen = strlen(old);
 	newlen = strlen(newval);
@@ -233,7 +238,7 @@
 
 extern int obscure(const char *old, const char *newval, const struct passwd *pwdp)
 {
-	char *msg = obscure_msg(old, newval, pwdp);
+	const char *msg = obscure_msg(old, newval, pwdp);
 
 	/*  if (msg) { */
 	if (msg != NULL) {
Index: libbb/pw_encrypt.c
===================================================================
RCS file: /var/cvs/tinylogin/libbb/pw_encrypt.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- a/libbb/pw_encrypt.c	23 Jun 2002 03:09:12 -0000	1.1
+++ b/libbb/pw_encrypt.c	17 Feb 2003 11:51:58 -0000	1.2
@@ -30,11 +30,6 @@
 	static char cipher[128];
 	char *cp;
 
-#ifdef CONFIG_FEATURE_SHA1_PASSWORDS
-	if (strncmp(salt, "$2$", 3) == 0) {
-		return sha1_crypt(clear);
-	}
-#endif
 	cp = (char *) crypt(clear, salt);
 	/* if crypt (a nonstandard crypt) returns a string too large,
 	   truncate it so we don't overrun buffers and hope there is