]> code.citadel.org Git - citadel.git/blobdiff - libcitadel/lib/tools.c
Bumped version numbers to 8.11 for upcoming release
[citadel.git] / libcitadel / lib / tools.c
index b269433ef7cfb07cb4127a0fdc92adb4262874f1..43a7882303921c94ceab0ff3ad5880bf8170fe1d 100644 (file)
@@ -875,13 +875,28 @@ char *strcpy(char *dest, const char *src) {
  */
 void generate_uuid(char *buf) {
        static int seq = (-1);
+       static int no_kernel_uuid = 0;
+
+       /* If we are running on Linux then we have a kernelspace uuid generator available */
+
+       if (no_kernel_uuid == 0) {
+               FILE *fp;
+               fp = fopen("/proc/sys/kernel/random/uuid", "rb");
+               if (fp) {
+                       int rv;
+                       rv = fread(buf, 36, 1, fp);
+                       fclose(fp);
+                       if (rv == 1) return;
+               }
+       }
+
+       /* If the kernel didn't provide us with a uuid, we generate a pseudo-random one */
+
+       no_kernel_uuid = 1;
 
-<<<<<<< HEAD
        if (seq == (-1)) {
                seq = (int)rand();
        }
-=======
->>>>>>> d0e228d... generate_uuid() now generates more or less DCE-compliant uuid's
        ++seq;
        seq = (seq % 0x0FFF) ;