fixed fast cgi crypto

svn path=/trunk/boinc/; revision=164
This commit is contained in:
Michael Gary 2002-07-05 19:20:00 +00:00
parent 373a32295d
commit df08cb7704
6 changed files with 80 additions and 18 deletions

View File

@ -850,3 +850,11 @@ David July 4, 2002
client/app.C
sched/file_upload_handler.C
Michael Gary July 5, 2002
- fixed fast cgi crypto
use fgets and sscanf instead of fscanf, which
is not implemented in fcgi_stdio.h
sched/Makefile.in
lib/crypt.C

View File

@ -25,17 +25,33 @@
#ifdef _WIN32
#include <io.h>
#else
#include <windows.h>
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#if HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#if HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#if HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_SYS_SIGNAL_H
#include <sys/signal.h>
#endif
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include <ctype.h>
#if HAVE_SIGNAL_H
#include <signal.h>
#endif
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
@ -311,9 +327,18 @@ int ACTIVE_TASK::start(bool first_time) {
void ACTIVE_TASK::request_exit(int seconds) {
int retval;
#if HAVE_SIGNAL_H
#if HAVE_SYS_TYPES_H
retval = kill(pid, SIGTERM);
sleep(seconds);
if(retval) kill(pid, SIGKILL);
#endif
#endif
#ifdef _WIN32
//retval = ExitProcess();
sleep(seconds);
//if(retval) TerminateProcess();
#endif
}
int ACTIVE_TASK_SET::insert(ACTIVE_TASK* atp) {
@ -377,7 +402,9 @@ bool ACTIVE_TASK_SET::poll() {
}
#endif
#ifdef unix
#if HAVE_SYS_RESOURCE_H
#if HAVE_SYS_WAIT_H
#if HAVE_SYS_TIME_H
struct rusage rs;
int pid;
@ -402,6 +429,8 @@ bool ACTIVE_TASK_SET::poll() {
atp->state = PROCESS_EXIT_UNKNOWN;
atp->result->exit_status = -1;
}
#endif
#endif
#endif
// check for the stderr file, copy to result record

View File

@ -1,22 +1,34 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(http.C)
AC_INIT(error_numbers.h)
dnl Checks for programs.
AC_PROG_CC
dnl Checks for libraries.
dnl Replace `main' with a function in -lgen:
AC_CHECK_LIB(gen, main)
dnl Replace `main' with a function in -lm:
AC_CHECK_LIB(m, main)
dnl Replace `main' with a function in -lnsl:
AC_CHECK_LIB(nsl, main)
dnl Replace `main' with a function in -lsocket:
AC_CHECK_LIB(socket, main)
dnl Replace `main' with a function in -lstdc:
AC_CHECK_LIB(stdc, main)
dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h sys/ioctl.h sys/time.h unistd.h)
AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
AC_HEADER_TIME
dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_WAIT3
AC_CHECK_FUNCS(gethostname gettimeofday mkdir select socket strstr uname)
AC_CHECK_FUNCS(gethostname gettimeofday mkdir select socket strdup strstr uname)
AC_OUTPUT(Makefile makefile)
AC_OUTPUT(Makefile)

View File

@ -221,14 +221,12 @@ int get_host_info(HOST_INFO& host) {
#endif
#ifdef linux
memset(&host, 0, sizeof(host));
#endif
get_local_domain_name(host.domain_name);
get_local_ip_addr_str(host.ip_addr);
#ifdef linux
memset(&host, 0, sizeof(host));
parse_cpuinfo(host);
parse_meminfo(host);
#endif
get_local_domain_name(host.domain_name);
get_local_ip_adr_str(host.ip_addr);
#ifdef HAVE_SYS_UTSNAME_H
get_osinfo(host);
#endif

View File

@ -42,9 +42,13 @@ int sprint_hex_data(char* p, DATA_BLOCK& x) {
int scan_hex_data(FILE* f, DATA_BLOCK& x) {
int n;
x.len = 0;
char *retval, buf[3];
while (1) {
n = fscanf(f, "%2x", x.data+x.len);
if (n <= 0) break;
retval = fgets(buf, 2, f);
if(retval == NULL) break;
sscanf(buf, "%2x", x.data+x.len);
//n = fscanf(f, "%2x", x.data+x.len);
//if (n <= 0) break;
x.len++;
}
return 0;
@ -80,14 +84,18 @@ int print_key_hex(FILE* f, KEY* key, int size) {
int scan_key_hex(FILE* f, KEY* key, int size) {
int len, i, n;
fscanf(f, "%d", &key->bits);
char buf[size+1];
//fscanf(f, "%d", &key->bits);
fgets(buf, size, f);
sscanf(buf, "%2x", &key->bits);
len = size - sizeof(key->bits);
for (i=0; i<len; i++) {
fscanf(f, "%2x", &n);
//fscanf(f, "%2x", &n);
sscanf(buf, "%2x", &n);
key->data[i] = n;
}
fscanf(f, ".");
//fscanf(f, ".");
sscanf(buf, ".");
return 0;
}
@ -113,7 +121,7 @@ int encrypt_private(
}
int decrypt_public(R_RSA_PUBLIC_KEY& key, DATA_BLOCK& in, DATA_BLOCK& out) {
RSAPublicDecrypt(out.data, &out.len, in.data, in.len, &key);
return RSAPublicDecrypt(out.data, &out.len, in.data, in.len, &key);
}
int sign_file(char* path, R_RSA_PRIVATE_KEY& key, DATA_BLOCK& signature) {

View File

@ -61,6 +61,10 @@ FCGI_OBJS = \
../db/mysql_util.fcgi.o \
../lib/shmem.fcgi.o \
../lib/parse.fcgi.o \
../lib/crypt.fcgi.o \
../lib/md5.o \
../lib/md5_file.o \
../RSAEuro/source/rsaeuro.a \
../tools/process_result_template.fcgi.o
FCGI_LIBS = -lfcgi -lfcgi++
FCGI_FLAGS = -include /usr/local/include/fcgi_stdio.h -D_USING_FCGI_
@ -74,6 +78,9 @@ MYSQL_LIBS = \
%.fcgi.o: %.C
$(CC) $(FCGI_FLAGS) -c $*.C -o $*.fcgi.o
%.fcgi.o: %.c
$(CC) $(FCGI_FLAGS) -c $*.c -o $*.fcgi.o
.C.o:
$(CC) -c -o $*.o $<