1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-04 22:33:27 +00:00
freebsd-ports/games/crossfire-client/files/patch-ag

48 lines
981 B
Plaintext
Raw Normal View History

--- server/main.c.orig Sun Jan 5 19:59:27 1997
+++ server/main.c Wed Sep 17 15:34:40 1997
@@ -139,6 +139,36 @@
}
}
+#if defined(__FreeBSD__)
+static unsigned char itoa64[] =
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
+
+static void
+to64(char *s, long v, int n)
+{
+ while (--n >= 0) {
+ *s++ = itoa64[v&0x3f];
+ v >>= 6;
+ }
+}
+
+char *
+crypt_string(char *str, char *salt)
+{
+ char s[10];
+ if (salt==NULL) {
+ struct timeval tv;
+ gettimeofday(&tv,0);
+ to64(&s[0], random(), 3);
+ to64(&s[3], tv.tv_usec, 3);
+ to64(&s[6], tv.tv_sec, 2);
+ s[8] = '\0';
+ salt = s;
+ }
+ return (crypt(str, salt));
+}
+#else
+
char *crypt_string(char *str, char *salt) {
static char *c=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
@@ -151,6 +181,7 @@
s[1]= salt[1];
return crypt(str,s);
}
+#endif
int check_password(char *typed,char *crypted) {
return !strcmp(crypt_string(typed,crypted),crypted);