| 6 |
details. |
details. |
| 7 |
|
|
| 8 |
Mixmaster initialization, configuration |
Mixmaster initialization, configuration |
| 9 |
$Id: mix.c,v 1.2 2001/11/06 23:41:58 rabbi Exp $ */ |
$Id: mix.c,v 1.7 2002/07/21 16:28:14 weaselp Exp $ */ |
| 10 |
|
|
| 11 |
|
|
| 12 |
#include "mix3.h" |
#include "mix3.h" |
| 76 |
int PGP = 1; |
int PGP = 1; |
| 77 |
int UNENCRYPTED = 0; |
int UNENCRYPTED = 0; |
| 78 |
int REMIX = 1; |
int REMIX = 1; |
| 79 |
|
int REPGP = 1; |
| 80 |
|
|
| 81 |
int POOLSIZE = 0; |
int POOLSIZE = 0; |
| 82 |
int RATE = 100; |
int RATE = 100; |
| 108 |
long MAXLAT = 36 * 60 * 60; |
long MAXLAT = 36 * 60 * 60; |
| 109 |
char PGPPUBRING[PATHMAX]; |
char PGPPUBRING[PATHMAX]; |
| 110 |
char PGPSECRING[PATHMAX]; |
char PGPSECRING[PATHMAX]; |
| 111 |
|
#ifdef PASSPHRASE |
| 112 |
|
char PASS_PHRASE[LINELEN] = PASSPHRASE; |
| 113 |
|
#else |
| 114 |
|
char PASS_PHRASE[LINELEN] = ""; |
| 115 |
|
#endif |
| 116 |
char MAILBOX[PATHMAX] = "mbox"; |
char MAILBOX[PATHMAX] = "mbox"; |
| 117 |
char MAILABUSE[PATHMAX]; |
char MAILABUSE[PATHMAX]; |
| 118 |
char MAILBLOCK[PATHMAX]; |
char MAILBLOCK[PATHMAX]; |
| 309 |
read_conf_i(REMAIL) || read_conf_i(MIX) || |
read_conf_i(REMAIL) || read_conf_i(MIX) || |
| 310 |
read_conf_i(PGP) || read_conf_i(UNENCRYPTED) || |
read_conf_i(PGP) || read_conf_i(UNENCRYPTED) || |
| 311 |
read_conf_i(REMIX) || read_conf(NEWS) || |
read_conf_i(REMIX) || read_conf(NEWS) || |
| 312 |
|
read_conf_i(REPGP) || |
| 313 |
read_conf(MAILtoNEWS) || read_conf(ERRLOG) || |
read_conf(MAILtoNEWS) || read_conf(ERRLOG) || |
| 314 |
read_conf(ORGANIZATION) || read_conf(MID) || |
read_conf(ORGANIZATION) || read_conf(MID) || |
| 315 |
read_conf(TYPE1) || read_conf_i(POOLSIZE) || |
read_conf(TYPE1) || read_conf_i(POOLSIZE) || |
| 323 |
read_conf_i(DISTANCE) || read_conf_i(MINREL) || |
read_conf_i(DISTANCE) || read_conf_i(MINREL) || |
| 324 |
read_conf_i(RELFINAL) || read_conf_t(MAXLAT) || |
read_conf_i(RELFINAL) || read_conf_t(MAXLAT) || |
| 325 |
read_conf(PGPPUBRING) || read_conf(PGPSECRING) || |
read_conf(PGPPUBRING) || read_conf(PGPSECRING) || |
| 326 |
|
read_conf(PASS_PHRASE) || |
| 327 |
#ifdef USE_SOCK |
#ifdef USE_SOCK |
| 328 |
read_conf_i(POP3DEL) || read_conf_i(POP3SIZELIMIT) || |
read_conf_i(POP3DEL) || read_conf_i(POP3SIZELIMIT) || |
| 329 |
read_conf_t(POP3TIME) || |
read_conf_t(POP3TIME) || |
| 381 |
|
|
| 382 |
#ifdef POSIX |
#ifdef POSIX |
| 383 |
if (err == -1 && pw != NULL) { |
if (err == -1 && pw != NULL) { |
| 384 |
strcatn(line, pw->pw_dir, PATHMAX); |
strncpy(line, pw->pw_dir, PATHMAX); |
| 385 |
|
line[PATHMAX-1] = '\0'; |
| 386 |
if (line[strlen(line) - 1] != DIRSEP) |
if (line[strlen(line) - 1] != DIRSEP) |
| 387 |
strcatn(line, DIRSEPSTR, PATHMAX); |
strcatn(line, DIRSEPSTR, PATHMAX); |
| 388 |
strcatn(line, "Mix", PATHMAX); |
strcatn(line, "Mix", PATHMAX); |
| 634 |
return (0); |
return (0); |
| 635 |
} |
} |
| 636 |
|
|
| 637 |
|
|
| 638 |
|
#ifdef WIN32 |
| 639 |
|
/* Try to detect if we are the service or not... |
| 640 |
|
seems there is no easy reliable way */ |
| 641 |
|
int is_nt_service(void) |
| 642 |
|
{ |
| 643 |
|
static int issvc = -1; |
| 644 |
|
#ifdef WIN32SERVICE |
| 645 |
|
STARTUPINFO StartupInfo; |
| 646 |
|
OSVERSIONINFO VersionInfo; |
| 647 |
|
DWORD dwsize; |
| 648 |
|
|
| 649 |
|
if (issvc != -1) /* do it only once */ |
| 650 |
|
return issvc; |
| 651 |
|
|
| 652 |
|
VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo); |
| 653 |
|
if (GetVersionEx(&VersionInfo)) |
| 654 |
|
if (VersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT) |
| 655 |
|
return issvc = 0; /* not NT - not the service */ |
| 656 |
|
|
| 657 |
|
if (!GetConsoleTitle(&VersionInfo,sizeof(VersionInfo))) |
| 658 |
|
/* reuse VersionInfo to save memory */ |
| 659 |
|
return issvc = 1; /* have no console - we are the service probably */ |
| 660 |
|
|
| 661 |
|
GetStartupInfo(&StartupInfo); |
| 662 |
|
if (StartupInfo.lpDesktop[0] == 0) |
| 663 |
|
return issvc = 1; /* have no desktop - we are the service probably */ |
| 664 |
|
|
| 665 |
|
if (_fileno(stdin) == -1 && _fileno(stdout) == -1 && _fileno(stderr) == -1) |
| 666 |
|
return issvc = 1; /* have no stdin,stderr,stdout - probably service */ |
| 667 |
|
#endif // WIN32SERVICE |
| 668 |
|
|
| 669 |
|
return issvc = 0; // assume not the service |
| 670 |
|
} // is_nt_service |
| 671 |
|
|
| 672 |
|
HANDLE hMustTerminate = NULL; |
| 673 |
|
void set_nt_exit_event(HANDLE h_svc_exit_event) |
| 674 |
|
{ |
| 675 |
|
hMustTerminate = h_svc_exit_event; |
| 676 |
|
} // set_nt_exit_event |
| 677 |
|
|
| 678 |
|
#endif // WIN32 |
| 679 |
|
|
| 680 |
int mix_daemon(void) |
int mix_daemon(void) |
| 681 |
{ |
{ |
| 682 |
long t; |
long t; |
|
#ifdef WIN32SERVICE |
|
|
long t1; |
|
|
HANDLE hMustTerminate = OpenEvent(EVENT_ALL_ACCESS, FALSE, "mixmaster-stop"); |
|
|
#endif |
|
| 683 |
t = SENDPOOLTIME; |
t = SENDPOOLTIME; |
| 684 |
#ifdef USE_SOCK |
#ifdef USE_SOCK |
| 685 |
if (POP3TIME < t) |
if (POP3TIME < t) |
| 690 |
mix_regular(0); |
mix_regular(0); |
| 691 |
#ifdef WIN32 |
#ifdef WIN32 |
| 692 |
#ifdef WIN32SERVICE |
#ifdef WIN32SERVICE |
| 693 |
t1 = t*2; |
if (hMustTerminate) { |
| 694 |
while (t1) { |
if (WaitForSingleObject(hMustTerminate, t * 1000) == WAIT_OBJECT_0) { |
| 695 |
if (hMustTerminate) |
CloseHandle(hMustTerminate); |
| 696 |
if (WaitForSingleObject(hMustTerminate, 500) == WAIT_OBJECT_0) { |
return 0; |
| 697 |
CloseHandle(hMustTerminate); |
} |
| 698 |
return 0; |
} else |
|
} |
|
|
t1--; |
|
|
} |
|
|
#else |
|
|
Sleep(t * 1000); |
|
| 699 |
#endif |
#endif |
| 700 |
|
Sleep(t * 1000); |
| 701 |
#else |
#else |
| 702 |
sleep(t); |
sleep(t); |
| 703 |
#endif |
#endif |