Last active
December 25, 2015 20:49
-
-
Save mkuron/7038065 to your computer and use it in GitHub Desktop.
Monkey-patching MathLM on Mac OS X so it does not crash when clients with 32-character (or longer) hostnames request a Mathematica license
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.o | |
*.dylib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
strcpy.dylib: strcpy.c | |
gcc -Wall -o $@ -dynamiclib $< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo -u lmgrduser DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES=strcpy.dylib /usr/local/Wolfram/MathLM/mathlm -foreground -pwfile /usr/local/Wolfram/MathLM/mathpass -timeout 3 -loglevel 4 -logfile /var/log/lmgrd/mathlm.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
void * | |
__strcpy_chk (char* dest, char* src, size_t dstlen) | |
{ | |
size_t len = strlen (src); | |
if (__builtin_expect (dstlen < len, 0)) | |
printf("THIS WOULD HAVE CRASHED: "); | |
printf("Copying %s. Source: %lu bytes, Destination: %lu bytes\n", src, len, dstlen); | |
if (18446744073709551615U == dstlen) | |
return memcpy (dest, src, len + 1); | |
return strncpy (dest, src, dstlen); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment