From: Jens Steube Date: Fri, 8 Jul 2016 12:32:59 +0000 (+0200) Subject: Merge pull request #421 from lifanov/freebsd-port X-Git-Url: https://www.flypig.org.uk/git/?a=commitdiff_plain;h=72abe90e10fd0bae7905c1009f356c7c38a587ef;hp=-c;p=hashcat.git Merge pull request #421 from lifanov/freebsd-port FreeBSD support --- 72abe90e10fd0bae7905c1009f356c7c38a587ef diff --combined src/shared.c index df14f43,5372561..e7d5dc3 --- a/src/shared.c +++ b/src/shared.c @@@ -10,6 -10,11 +10,11 @@@ #include #endif + #ifdef __FreeBSD__ + #include + #include + #endif + #include #include @@@ -2382,7 -2387,7 +2387,7 @@@ int tty_fix( } #endif - #ifdef DARWIN + #if defined(DARWIN) || defined(__FreeBSD__) static struct termios savemodes; static int havemodes = 0; @@@ -4371,6 -4376,23 +4376,23 @@@ char *get_exec_path ( const int len = strlen (exec_path); + #elif __FreeBSD__ + + #include + + int mib[4]; + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PATHNAME; + mib[3] = -1; + + char tmp[32] = { 0 }; + + size_t size = exec_path_len; + sysctl(mib, 4, exec_path, &size, NULL, 0); + + const int len = readlink (tmp, exec_path, exec_path_len - 1); + #else #error Your Operating System is not supported or detected #endif @@@ -4523,6 -4545,9 +4545,9 @@@ void set_cpu_affinity (char *cpu_affini { #ifdef _WIN DWORD_PTR aff_mask = 0; + #elif __FreeBSD__ + cpuset_t cpuset; + CPU_ZERO (&cpuset); #elif _POSIX cpu_set_t cpuset; CPU_ZERO (&cpuset); @@@ -4570,6 -4595,9 +4595,9 @@@ #ifdef _WIN SetProcessAffinityMask (GetCurrentProcess (), aff_mask); SetThreadAffinityMask (GetCurrentThread (), aff_mask); + #elif __FreeBSD__ + pthread_t thread = pthread_self (); + pthread_setaffinity_np (thread, sizeof (cpuset_t), &cpuset); #elif _POSIX pthread_t thread = pthread_self (); pthread_setaffinity_np (thread, sizeof (cpu_set_t), &cpuset); @@@ -4695,9 -4723,8 +4723,9 @@@ int sort_by_hash_t_salt_hccap (const vo const salt_t *s1 = h1->salt; const salt_t *s2 = h2->salt; - // 16 - 2 (since last 2 uints contain the digest) - uint n = 14; + // last 2: salt_buf[10] and salt_buf[11] contain the digest (skip them) + + uint n = 9; // 9 * 4 = 36 bytes (max length of ESSID) while (n--) {