Exemplo n.º 1
0
static int send_file(const char *fname, int patches, const char *best, const char *datapth, unsigned long long *bytes, char cmd, int64_t winattr, struct cntr *cntr, struct config *cconf)
{
	int ret=0;
	FILE *fp=NULL;
	if(open_file_for_send(NULL, &fp, best, winattr, cntr))
		return -1;
	//logp("sending: %s\n", best);
	if(async_write(cmd, fname, strlen(fname)))
		ret=-1;
	else if(patches)
	{
		// If we did some patches, the resulting file
		// is not gzipped. Gzip it during the send. 
		ret=send_whole_file_gz(best, datapth, 1, bytes, NULL, cntr,
			9, NULL, fp, NULL, 0);
	}
	else
	{
		// If it was encrypted, it may or may not have been compressed
		// before encryption. Send it as it as, and let the client
		// sort it out.
		if(cmd==CMD_ENC_FILE
		  || cmd==CMD_ENC_METADATA
		  || cmd==CMD_EFS_FILE)
		{
			ret=send_whole_file(cmd, best,
				datapth, 1, bytes, cntr, NULL, fp, NULL, 0);
		}
		// It might have been stored uncompressed. Gzip it during
		// the send. If the client knew what kind of file it would be
		// receiving, this step could disappear.
		else if(!dpth_is_compressed(datapth))
		{
			ret=send_whole_file_gz(best, datapth, 1, bytes,
				NULL, cntr, 9, NULL, fp, NULL, 0);
		}
		else
		{
			// If we did not do some patches, the resulting
			// file might already be gzipped. Send it as it is.
			ret=send_whole_file(cmd, best,
				datapth, 1, bytes, cntr, NULL, fp, NULL, 0);
		}
	}
	close_file_for_send(NULL, &fp);
	return ret;
}
Exemplo n.º 2
0
static int send_whole_file_w(char cmd, const char *fname, const char *datapth, int quick_read, unsigned long long *bytes, const char *encpassword, struct cntr *cntr, int compression, BFILE *bfd, FILE *fp, const char *extrameta, size_t elen)
{
    if((compression || encpassword) && cmd!=CMD_EFS_FILE)
        return send_whole_file_gz(fname, datapth, quick_read, bytes,
                                  encpassword, cntr, compression, bfd, fp, extrameta, elen);
    else
        return send_whole_file(cmd, fname, datapth, quick_read, bytes,
                               cntr, bfd, fp, extrameta, elen);
}
Exemplo n.º 3
0
/* Windows will use this function, when sending a certificate signing request.
   It is not using the Windows API stuff because it needs to arrive on the
   server side without any junk in it. */
int send_a_file(struct asfd *asfd, const char *path, struct conf **confs)
{
	int ret=0;
	FILE *fp=NULL;
	unsigned long long bytes=0;
	if(!(fp=open_file(path, "rb"))
	  || send_whole_file_gz(asfd, path, "datapth", 0, &bytes,
		confs, 9 /*compression*/, fp))
	{
		ret=-1;
		goto end;
	}
	logp("Sent %s\n", path);
end:
	close_fp(&fp);
	return ret;
}
Exemplo n.º 4
0
Arquivo: handy.c Projeto: goneri/burp
/* Windows will use this function, when sending a certificate signing request.
   It is not using the Windows API stuff because it needs to arrive on the
   server side without any junk in it. */
int send_a_file(const char *path, struct cntr *p1cntr)
{
	int ret=0;
	FILE *fp=NULL;
	unsigned long long bytes=0;
	if(open_file_for_send(NULL, &fp, path, 0, p1cntr)
	  || send_whole_file_gz(path, "datapth", 0, &bytes, NULL,
		p1cntr, 9, // compression
		NULL, fp, NULL, 0))
	{
		ret=-1;
		goto end;
	}
	logp("Sent %s\n", path);
end:
	close_file_for_send(NULL, &fp);
	return ret;
}