Example #1
0
void process_flushed_data(struct anonflow *flow)
{
	struct function *flist;

	fprintf(stderr, "process_flushed_data\n");

	if (!flow->modifies)
		return;

	flist = flow->function_list;
	while (flist) {
		if (strcmp(flist->function_info->name, "COOKING") == 0) {
			flist = flist->next;
			break;
		}
		flist = flist->next;
	}

	while (flist) {
		if (flist->function_info->
		    process(flow, flist->internal_data, flow->mod_pkt, &flow->mod_pkt_head) == 0) {
			break;
		}

		if (flow->uncook_ready == 1) {
			fprintf(stderr, "do_uncook_loop: %d\n", flist_size(flow->client_headers));
			do_uncook_loop(flow, flist);
			break;
		} else {
			flist = flist->next;
		}
	}
}
Example #2
0
int pre(char *section, char *dest, char *src, char *rel, char *group, char *argv[]) {
	hashtable_t *cfg, *env;

	char buf[1024], tbuf[50], ubuf[300], *tmp;
	filelist_t *files, *ftmp;
	creditlist_t *credits, *tcred;
	struct subdir_list *subdirs;
	float bcount;
	long fnum;
	int olduid, disks = 1;
	pwdfile *pass;
	chowninfo_t *chown;

	cfg = get_config();
	env = get_context();

	pass = pwd_getpwnam(ht_get(env, PROPERTY_USER));

	if (!pass) {
		printf(" * Error, cannot get your passwd entry! \n");
		return 0;
	}

	chown = chowninfo_find_by_group(group);

	olduid = getuid();
	if (setuid(0) == -1)
		quit(" * Error changing uid, bug sysop to fix perms on foo-pre !\n");

	// find filenames, and collect user's stats + do chowning of files.
	files = filelist_find_by_dir(0, src, "", chown);

	// get totals.
	flist_size(files, &bcount, &fnum);
	printf(" * Totals of this pre for announce: %dF %.0fB\n", fnum, bcount);

	// get credits.
	credits = creditlist_create_from_filelist(files);

	printf(" * Moving files to destination dir.. \n");
	printf("   -- %10.10s: %s\n", "From", src);
	printf("   -- %10.10s: %s", "To", dest);

	// dont forget to chown maindir
	chowninfo_apply_to_file(src, chown);

	// do the actual moving of dir.
	if (pre_move_catalog(src, dest) == -1)
		quit(" Failed!\n");
	else
		printf(" Done\n");

	// give credits to original uploaders
	printf(" * Updating userfiles ..\n");
	strcpy(ubuf, "");
	for (tcred = credits; tcred; tcred = tcred->next) {
		tmp = userfile_update(tcred);
		if (tmp)
			strcat(ubuf, tmp);
	}

	setuid(olduid);

	if (strlen(ubuf) > 2)
		ubuf[strlen(ubuf) - 2] = 0;

	// add to dupefile.
	tmp = ht_get(env, PROPERTY_USER);
	for (ftmp = files; ftmp; ftmp = ftmp->next)
		if (!gl_dupefile_add(flist_getfilename(ftmp), tmp))
			printf(" * Error adding to dupefile: %s\n", ftmp->file);

	subdirs = subdir_flistcollect(files);
	reverse_dirlog_add(subdirs, dest, rel, pass, chown);

	disks = subdirlist_count(subdirs);
	if (disks == 0)
		disks++;

	// create announce.
	tmp = group_get_property(group, PROPERTY_GROUP_ANNOUNCE);

	if (tmp) {

		strcpy(buf, tmp);
		sprintf(tbuf, "%.1f", (float)bcount/(1024*1024));
		pre_replace(buf, "%S", tbuf);
		sprintf(tbuf, "%ld", fnum);
		pre_replace(buf, "%W", ubuf);
		pre_replace(buf, "%F", tbuf);
		sprintf(tbuf, "%d", disks);
		pre_replace(buf, "%C", tbuf);
		pre_replace(buf, "%PP", ht_get(env, "RESOLVEDDESTINATION"));
		pre_replace(buf, "%P", section_get_property(section, PROPERTY_SECTION_DIR));
		pre_replace(buf, "%U", ht_get(env, PROPERTY_USER));
		pre_replace(buf, "%T", ht_get(env, PROPERTY_TAGLINE));
		pre_replace(buf, "%G", ht_get(env, PROPERTY_GROUP));
		pre_replace(buf, "%g", ht_get(env, PROPERTY_USERGROUP));
		pre_replace(buf, "%D", section_get_property(section, PROPERTY_SECTION_NAME));
		pre_replace(buf, "%R", rel);

		gl_gllog_add(buf);

	} else
		printf(" * WARNING: No announce setup ! Go bug sysop :( \n");

	// add to dupelog.
	if (!gl_dupelog_add(rel))
		printf(" * Error adding to dupelog !  (prolly wrong perms, ask sysop to fix)\n");

	sprintf(buf, "%s/%s", ht_get(env, "RESOLVEDDESTINATION"), rel);

	// do additional module stuff
	pre_do_modules(files, buf, argv, subdirs);

	return 1;
}