blob: 8b6b87d8385f885102f41f3f221680adde4b1c09 (
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
|
UCLIBC have the prototypes in stdlib.h, but not the actual functions (yes, you
guys sucks once again. The better way might be rather to add lib/rad64.c back,
but its higher maintainence our side at least.
--- shadow-4.0.11.1/libmisc/salt.c 2005-08-03 12:50:45.000000000 +0200
+++ shadow-4.0.11.1.az/libmisc/salt.c 2005-08-03 13:07:03.000000000 +0200
@@ -14,6 +14,57 @@
#include "prototypes.h"
#include "defines.h"
#include "getdef.h"
+
+#ifndef HAVE_A64L
+
+/*
+ * i64c - convert an integer to a radix 64 character
+ */
+
+int
+i64c(int i)
+{
+ if (i <= 0)
+ return ('.');
+
+ if (i == 1)
+ return ('/');
+
+ if (i >= 2 && i < 12)
+ return ('0' - 2 + i);
+
+ if (i >= 12 && i < 38)
+ return ('A' - 12 + i);
+
+ if (i >= 38 && i < 63)
+ return ('a' - 38 + i);
+
+ return ('z');
+}
+
+/*
+ * l64a - convert a long to a string of radix 64 characters
+ */
+
+char *
+l64a(long l)
+{
+ static char buf[8];
+ int i = 0;
+
+ if (l < 0L)
+ return ((char *) 0);
+
+ do {
+ buf[i++] = i64c ((int) (l % 64));
+ buf[i] = '\0';
+ } while (l /= 64L, l > 0 && i < 6);
+
+ return (buf);
+}
+
+#endif /* !HAVE_A64L */
+
/*
* Generate 8 base64 ASCII characters of random salt. If MD5_CRYPT_ENAB
* in /etc/login.defs is "yes", the salt string will be prefixed by "$1$"
|