]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/hmac.cpp
Remove debug, thanks for reminding me danieldg
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / hmac.cpp
index 4b99a3eb7c3dc051fabfc54a3fdc235bdf970948..4ad6658b8f5d38fee1491f8b35af56fa3336cfc5 100644 (file)
@@ -90,35 +90,36 @@ std::string TreeSocket::MakePass(const std::string &password, const std::string
                return "HMAC-SHA256:"+ hmac;
        }
        else if (!challenge.empty() && !sha256)
-               Instance->Log(DEFAULT,"Not authenticating to server using SHA256/HMAC because we don't have m_sha256 loaded!");
+               Instance->Logs->Log("m_spanningtree",DEFAULT,"Not authenticating to server using SHA256/HMAC because we don't have m_sha256 loaded!");
 
        return password;
 }
 
-std::string TreeSocket::RandString(unsigned int length)
+std::string TreeSocket::RandString(unsigned int ilength)
 {
-       char* randombuf = new char[length+1];
+       char* randombuf = new char[ilength+1];
        std::string out;
 #ifdef WINDOWS
-       int fd = -1;
+       int f = -1;
 #else
-       int fd = open("/dev/urandom", O_RDONLY, 0);
+       int f = open("/dev/urandom", O_RDONLY, 0);
 #endif
 
-       if (fd >= 0)
+       if (f >= 0)
        {
 #ifndef WINDOWS
-               read(fd, randombuf, length);
-               close(fd);
+               if (read(f, randombuf, ilength) < 1)
+                       Instance->Logs->Log("m_spanningtree", DEFAULT, "There are crack smoking monkeys in your kernel (in other words, nonblocking /dev/urandom blocked.)");
+               close(f);
 #endif
        }
        else
        {
-               for (unsigned int i = 0; i < length; i++)
+               for (unsigned int i = 0; i < ilength; i++)
                        randombuf[i] = rand();
        }
 
-       for (unsigned int i = 0; i < length; i++)
+       for (unsigned int i = 0; i < ilength; i++)
        {
                char randchar = static_cast<char>((randombuf[i] & 0x7F) | 0x21);
                out += (randchar == '=' ? '_' : randchar);