Mercurial > hg > xemacs-beta
comparison lib-src/gnuserv.c @ 371:cc15677e0335 r21-2b1
Import from CVS: tag r21-2b1
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:03:08 +0200 |
parents | 1d62742628b6 |
children | 8626e4521993 |
comparison
equal
deleted
inserted
replaced
370:bd866891f083 | 371:cc15677e0335 |
---|---|
27 * | 27 * |
28 * (If gnuserv came bundled with your emacs, the README file is probably | 28 * (If gnuserv came bundled with your emacs, the README file is probably |
29 * ../etc/gnuserv.README relative to the directory containing this file) | 29 * ../etc/gnuserv.README relative to the directory containing this file) |
30 */ | 30 */ |
31 | 31 |
32 #if 0 | |
33 static char rcsid [] = "!Header: gnuserv.c,v 2.1 95/02/16 11:58:27 arup alpha !"; | |
34 #endif | |
35 | |
32 #include "gnuserv.h" | 36 #include "gnuserv.h" |
33 | |
34 char gnuserv_version[] = "gnuserv version" GNUSERV_VERSION; | |
35 | |
36 | 37 |
37 #ifdef USE_LITOUT | 38 #ifdef USE_LITOUT |
38 #ifdef linux | 39 #ifdef linux |
39 #include <bsd/sgtty.h> | 40 #include <bsd/sgtty.h> |
40 #else | 41 #else |
456 struct entry *entry; | 457 struct entry *entry; |
457 | 458 |
458 char auth_protocol[128]; | 459 char auth_protocol[128]; |
459 char buf[1024]; | 460 char buf[1024]; |
460 int auth_data_len; | 461 int auth_data_len; |
461 int auth_data_pos; | |
462 int auth_mismatches; | |
463 | 462 |
464 if (fd > 0) | 463 if (fd > 0) |
465 { | 464 { |
466 /* we are checking permission on a real connection */ | 465 /* we are checking permission on a real connection */ |
467 | 466 |
490 if (timed_read(fd, buf, 10, AUTH_TIMEOUT, 1) <= 0) | 489 if (timed_read(fd, buf, 10, AUTH_TIMEOUT, 1) <= 0) |
491 return FALSE; | 490 return FALSE; |
492 | 491 |
493 auth_data_len = atoi(buf); | 492 auth_data_len = atoi(buf); |
494 | 493 |
495 if (auth_data_len <= 0 || auth_data_len > sizeof(buf)) | |
496 { | |
497 return FALSE; | |
498 } | |
499 | |
500 if (timed_read(fd, buf, auth_data_len, AUTH_TIMEOUT, 0) != auth_data_len) | 494 if (timed_read(fd, buf, auth_data_len, AUTH_TIMEOUT, 0) != auth_data_len) |
501 return FALSE; | 495 return FALSE; |
502 | 496 |
503 #ifdef AUTH_MAGIC_COOKIE | 497 #ifdef AUTH_MAGIC_COOKIE |
504 if (server_xauth && server_xauth->data) | 498 if (server_xauth && server_xauth->data && |
505 { | 499 !memcmp(buf, server_xauth->data, auth_data_len)) |
506 /* Do a compare without comprising info about | 500 { |
507 the size of the cookie */ | 501 return TRUE; |
508 auth_mismatches = | 502 } |
509 ( auth_data_len ^ | |
510 server_xauth->data_length ); | |
511 | |
512 for(auth_data_pos=0; auth_data_pos < auth_data_len; ++auth_data_pos) | |
513 auth_mismatches |= | |
514 ( buf[auth_data_pos] ^ | |
515 server_xauth->data[auth_data_pos % server_xauth->data_length]); | |
516 | |
517 if (auth_mismatches == 0) | |
518 return TRUE; | |
519 | |
520 for(;rand() % 1000;); | |
521 } | |
522 | |
523 #else | 503 #else |
524 printf ("client tried Xauth, but server is not compiled with Xauth\n"); | 504 printf ("client tried Xauth, but server is not compiled with Xauth\n"); |
525 #endif | 505 #endif |
526 | 506 |
527 /* | 507 /* |
850 } /* handle_unix_request */ | 830 } /* handle_unix_request */ |
851 #endif /* UNIX_DOMAIN_SOCKETS */ | 831 #endif /* UNIX_DOMAIN_SOCKETS */ |
852 | 832 |
853 | 833 |
854 int | 834 int |
855 main (int argc, char *argv[]) | 835 main(argc,argv) |
836 int argc; | |
837 char *argv[]; | |
856 { | 838 { |
857 int chan; /* temporary channel number */ | 839 int chan; /* temporary channel number */ |
858 #ifdef SYSV_IPC | 840 #ifdef SYSV_IPC |
859 struct msgbuf *msgp; /* message buffer */ | 841 struct msgbuf *msgp; /* message buffer */ |
860 #else | 842 #else |