Exemple #1
0
/* Called only once during beginning of the program */
int
ssl_init(void *arg)
{
	int i;

	if (IS_MASTER(options)) {
		if (file_present("server.pem") == 0)
			ctx = initialize_ctx("server.pem", PASS, NULL);
	} else {
		if (file_present("client.pem") == 0)
			ctx = initialize_ctx("client.pem", PASS, NULL);
	}
	if (ctx == NULL)
		return (1);

	ssl_locks = malloc(CRYPTO_num_locks() * sizeof (pthread_mutex_t));
	for (i = 0; i < CRYPTO_num_locks(); i++) {
		pthread_mutex_init(&ssl_locks[i], 0);
	}
	CRYPTO_set_id_callback((unsigned long (*)())id_function);
	CRYPTO_set_locking_callback((void (*)())locking_function);

	/*
	 * We also register an atexit function to cleanup the ENGINE
	 * datastructures
	 */
	atexit(ssl_cleanup);
	return (0);
}
Exemple #2
0
dir_index_t * remove_old_files(fsid_index_t * fsid_index) {

	char txtbuf[100];


	DIR *directory_pointer;

	struct dirent *entry;
	dir_index_t * dir_index_list = NULL;
	dir_index_t * dir_index;

	if ((directory_pointer = opendir("/var/index/index")) == NULL) {
		return(0);
	}


	while ((entry = readdir(directory_pointer))) {
		if(strncmp(entry->d_name, ".", 1) != 0) {
			dir_index = new_dir_index();
			add_filename(dir_index, entry->d_name);
			dir_index_list = add_dir_index(dir_index_list, dir_index);
		}
	}

	closedir(directory_pointer);

	dir_index = dir_index_list;

	while(dir_index) {
		if(!file_present(dir_index, fsid_index)) {
			printf("Removing old index /var/index/index/%s\n",dir_index->filename);
			memset(txtbuf, '\0', 99);
			snprintf(txtbuf, 98,"/var/index/index/%s",dir_index->filename );
			if( unlink(txtbuf) == -1) {
				/* Okay this may be a fsid-no index file */
				printf("Removing old no index /var/index/index/%s-no\n",dir_index->filename);
				memset(txtbuf, '\0', 99);
				snprintf(txtbuf, 98,"/var/index/index/%s-no",dir_index->filename );
				unlink(txtbuf);
			}
		}
		dir_index = dir_index->next;
	}

	return(dir_index_list);

}