Untitled diff

作成日 差分は期限切れになりません
11 削除
372 行
18 追加
379 行
/*
/*
* This file is part of John the Ripper password cracker,
* This file is part of John the Ripper password cracker,
* Copyright (c) 1996-2003,2006,2010,2013 by Solar Designer
* Copyright (c) 1996-2003,2006,2010,2013 by Solar Designer
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted.
* modification, are permitted.
*
*
* There's ABSOLUTELY NO WARRANTY, express or implied.
* There's ABSOLUTELY NO WARRANTY, express or implied.
*/
*/


#define _XOPEN_SOURCE 500 /* for setitimer(2) and siginterrupt(3) */
#define _XOPEN_SOURCE 500 /* for setitimer(2) and siginterrupt(3) */


#ifdef __ultrix__
#ifdef __ultrix__
#define __POSIX
#define __POSIX
#define _POSIX_SOURCE
#define _POSIX_SOURCE
#endif
#endif


#define NEED_OS_TIMER
#define NEED_OS_TIMER
#define NEED_OS_FORK
#define NEED_OS_FORK
#include "os.h"
#include "os.h"


#ifdef _SCO_C_DIALECT
#ifdef _SCO_C_DIALECT
#include <limits.h>
#include <limits.h>
#endif
#endif
#include <stdio.h>
#include <stdio.h>
#include <unistd.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <signal.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/time.h>
#include <errno.h>
#include <errno.h>


#ifdef __DJGPP__
#ifdef __DJGPP__
#include <dos.h>
#include <dos.h>
#endif
#endif


#ifdef __CYGWIN32__
#ifdef __CYGWIN32__
#include <windows.h>
#include <windows.h>
#endif
#endif


#include "arch.h"
#include "arch.h"
#include "misc.h"
#include "misc.h"
#include "params.h"
#include "params.h"
#include "tty.h"
#include "tty.h"
#include "options.h"
#include "options.h"
#include "config.h"
#include "config.h"
#include "bench.h"
#include "bench.h"
#include "john.h"
#include "john.h"


volatile int event_pending = 0;
volatile int event_pending = 0;
volatile int event_abort = 0, event_save = 0, event_status = 0;
volatile int event_abort = 0, event_save = 0, event_status = 0;
volatile int event_ticksafety = 0;
volatile int event_ticksafety = 0;


static int timer_save_interval, timer_save_value;
static int timer_save_interval, timer_save_value;
static clock_t timer_ticksafety_interval, timer_ticksafety_value;
static clock_t timer_ticksafety_interval, timer_ticksafety_value;


#if !OS_TIMER
#if !OS_TIMER


#include <time.h>
#include <time.h>
#include <sys/times.h>
#include <sys/times.h>


static clock_t timer_emu_interval = 0;
static clock_t timer_emu_interval = 0;
static unsigned int timer_emu_count = 0, timer_emu_max = 0;
static unsigned int timer_emu_count = 0, timer_emu_max = 0;


void sig_timer_emu_init(clock_t interval)
void sig_timer_emu_init(clock_t interval)
{
{
timer_emu_interval = interval;
timer_emu_interval = interval;
timer_emu_count = 0; timer_emu_max = 0;
timer_emu_count = 0; timer_emu_max = 0;
}
}


void sig_timer_emu_tick(void)
void sig_timer_emu_tick(void)
{
{
static clock_t last = 0;
static clock_t last = 0;
clock_t current;
clock_t current;
struct tms buf;
struct tms buf;


if (++timer_emu_count < timer_emu_max) return;
if (++timer_emu_count < timer_emu_max) return;


current = times(&buf);
current = times(&buf);


if (!last) {
if (!last) {
last = current;
last = current;
return;
return;
}
}


if (current - last < timer_emu_interval && current >= last) {
if (current - last < timer_emu_interval && current >= last) {
timer_emu_max += timer_emu_max + 1;
timer_emu_max += timer_emu_max + 1;
return;
return;
}
}


last = current;
last = current;
timer_emu_count = 0;
timer_emu_count = 0;
timer_emu_max >>= 1;
timer_emu_max >>= 1;


raise(SIGALRM);
raise(SIGALRM);
}
}


#endif
#endif


static void sig_install_update(void);
static void sig_install_update(void);