summaryrefslogtreecommitdiffstats
path: root/misc-utils/mcookie.c
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:25:32 +0100
committerKarel Zak2006-12-07 00:25:32 +0100
commit6dbe3af945a63f025561abb83275cee9ff06c57b (patch)
tree19e59eac8ac465b5bc409b5adf815b582c92f633 /misc-utils/mcookie.c
downloadkernel-qcow2-util-linux-6dbe3af945a63f025561abb83275cee9ff06c57b.tar.gz
kernel-qcow2-util-linux-6dbe3af945a63f025561abb83275cee9ff06c57b.tar.xz
kernel-qcow2-util-linux-6dbe3af945a63f025561abb83275cee9ff06c57b.zip
Imported from util-linux-2.2 tarball.
Diffstat (limited to 'misc-utils/mcookie.c')
-rw-r--r--misc-utils/mcookie.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/misc-utils/mcookie.c b/misc-utils/mcookie.c
new file mode 100644
index 000000000..d0730edde
--- /dev/null
+++ b/misc-utils/mcookie.c
@@ -0,0 +1,44 @@
+/* mcookie.c -- Generates random numbers for xauth
+ * Created: Fri Feb 3 10:42:48 1995 by faith@cs.unc.edu
+ * Revised: Sun Feb 12 20:29:58 1995 by faith@cs.unc.edu
+ * Public Domain 1995 Rickard E. Faith (faith@cs.unc.edu)
+ * This program comes with ABSOLUTELY NO WARRANTY.
+ *
+ * mcookie.c,v 1.1.1.1 1995/02/22 19:09:16 faith Exp
+ */
+
+#define SECURE 1
+
+#include <stdio.h>
+#include <stdlib.h>
+#if SECURE
+#include <sys/time.h>
+#include <unistd.h>
+#endif
+
+int main( void )
+{
+ int i;
+#if SECURE
+ struct timeval tv;
+ struct timezone tz;
+
+ gettimeofday( &tv, &tz );
+ srand( tv.tv_sec + tv.tv_usec );
+#else
+ long int t;
+
+ time( &t );
+ srand( t );
+#endif
+
+ for (i = 0; i < 32; i++) {
+ int r = (rand() & 0x0f0) >> 4;
+
+ if (r < 10) putchar( '0' + r );
+ else putchar( 'a' + r - 10 );
+ }
+ putchar ( '\n' );
+
+ return 0;
+}