Exemplo n.º 1
0
int
LoadRelocData(FILE *fi, RelocInfo *r)
{
    switch(r->ri_RelocSize) {
    case 0:
	return(0);
    case 1:
	{
	    ubyte c;
	    fread(&c, 1, 1, fi);
	    return(c);
	}
    case 2:
	{
	    uword c;
	    freadl(&c, 2, 1, fi);
	    return(c);
	}
    case 4:
	{
	    ulong c;
	    freadl(&c, 4, 1, fi);
	    return(c);
	}
    default:
	fseek(fi, r->ri_RelocSize, 1);
	return(0);
    }
}
Exemplo n.º 2
0
int pfb_setup( struct msg_t *qptr1, struct be_msg_t *qptr2 ) {
	char pconf[BUF_SIZE];
	FILE *p;

	msg_max = pfb_conf.msg_max;
	dig_limit = pfb_conf.scan_limit;
	ext_queue = qptr1;
	my_queue = qptr2;

	CURQ = 0;
	pfb_using_envelope = 0;
	pfb_caps = BECAPS_MSG_HOLD | BECAPS_MSG_DEL | BECAPS_MSG_REQUEUE | BECAPS_MSG_ENVELOPE;

	memset ( config_path, 0, sizeof(config_path) );
	memset ( pftools_path, 0, sizeof(pftools_path) );
	memset ( postconf_path, 0, sizeof(postconf_path) );
	memset ( postsuper_path, 0, sizeof(postsuper_path) );
	memset ( postcat_path, 0, sizeof(postcat_path) );

	if ( strlen(pfb_conf.command_path) )
		snprintf ( pftools_path, BUF_SIZE-1, "%s", pfb_conf.command_path );

	if ( strlen(pfb_conf.config_path) ) {
		snprintf ( config_path, BUF_SIZE-1, "%s", pfb_conf.config_path );
		has_configpath = 1;
	}

	// If -p is not specified, use commands without path
	if ( strlen ( pftools_path ) ) {
		snprintf ( postconf_path, BUF_SIZE, "%s/postconf", pftools_path );
		snprintf ( postsuper_path, BUF_SIZE, "%s/postsuper", pftools_path );
		snprintf ( postcat_path, BUF_SIZE, "%s/postcat", pftools_path );
	} else {
		snprintf ( postconf_path, BUF_SIZE, "postconf" );
		snprintf ( postsuper_path, BUF_SIZE, "postsuper" );
		snprintf ( postcat_path, BUF_SIZE, "postcat" );
	}

	// Look for queue_directory
	if ( has_configpath ) 
		snprintf ( pconf, BUF_SIZE, "%s -c %s -h queue_directory 2> /dev/null", postconf_path, config_path );
	else
		snprintf ( pconf, BUF_SIZE, "%s -h queue_directory 2> /dev/null", postconf_path );
	p = popen ( pconf, "r" );
	if ( !p ) {
		syslog ( LOGLEVEL, "pfqueue postfix1 backend: cannot use postconf to search queue_directory, command was: \"%s\"", pconf );
		pclose ( p );
		return PFBE_UNUSABLE;
	}
	if ( !freadl ( p, queue_path, sizeof(queue_path) ) ) {
		syslog ( LOGLEVEL, "pfqueue postfix1 backend: cannot use postconf to search queue_directory, command was: \"%s\"", pconf );
		pclose ( p );
		return PFBE_UNUSABLE;
	}
	pclose ( p );

	return PFBE_OK;
}
Exemplo n.º 3
0
int pfb_retr_status( const char* msgid ) {
	FILE *p;
	char buf[BUF_SIZE];
	char buf2[BUF_SIZE];
	char *c;
	struct msg_t *msg;
	
	msg = msg_from_id(msgid);
	if ( !msg )
		return 2;

	if ( msg->scached )
		return 1;
	
	if ( CURQ == Q_DEFERRED ) {
		// replace 'deferred' with 'defer'
		c = strstr ( msg->path, "deferred" );
		if ( c ) {
			memset ( buf, 0, sizeof(buf) );
			strncpy ( buf, msg->path, c - msg->path );
			sprintf ( buf2, "%sdefer%s", buf, c+8 );
		}
		p = fopen ( buf2, "r" );
		if ( !p )
			strcpy ( msg->stat, "Deferred, no reason" );
		else {
			freadl ( p, msg->stat, sizeof(msg->stat) );
		}

		if ( p )
			fclose ( p );
	} else if ( CURQ == Q_ACTIVE )
		strcpy ( msg->stat, "Active" );
	else if ( CURQ == Q_HOLD )
		strcpy ( msg->stat, "Held" );
	else if ( CURQ == Q_INCOMING )
		strcpy ( msg->stat, "Incoming" );
	msg->scached = 1;
	return 1;
}
Exemplo n.º 4
0
int pfb_retr_headers( const char* msgid ) {
	FILE *p;
	char buf[BUF_SIZE];
	int f1, f2, f3, l1, l2;
	char *s1, *s2;
	struct msg_t *msg;
	int dirty;
	
	msg = msg_from_id(msgid);
	if ( !msg )
		return PFBE_MSGNOTEX;

	if ( msg->hcached )
		return PFBE_MSGCACHED;

	if ( has_configpath )
		snprintf ( buf, BUF_SIZE, "%s -c %s %s 2> /dev/null", 
			postcat_path, config_path, msg->path );
	else
		snprintf ( buf, BUF_SIZE, "%s %s 2> /dev/null", 
			postcat_path, msg->path );

	p = popen ( buf, "r" );
	if ( !p ) {
		strcpy ( msg->from, PFBE_SERROR );
		strcpy ( msg->to,   PFBE_SERROR );
		msg->hcached = 0;
		return PFBE_MSGNOTEX;
	}
	
	f1 = f2 = f3 = 0;
	
	dirty = 1;
	strcpy ( msg->from, PFBE_SNOTFOUND );
	strcpy ( msg->to,   PFBE_SNOTFOUND );

	if ( pfb_using_envelope ) {
		l1 = ENVELOPE_FROM_LEN;
		l2 = ENVELOPE_TO_LEN;
		s1 = ENVELOPE_FROM;
		s2 = ENVELOPE_TO;
	} else {
		l1 = HEADER_FROM_LEN;
		l2 = HEADER_TO_LEN;
		s1 = HEADER_FROM;
		s2 = HEADER_TO;
	}

	while ( (f1==0||f2==0||f3==0) && freadl ( p, buf, BUF_SIZE ) ) {
		if ( !f1 && ( !strncmp ( buf, s1, l1 ) ) ) {
			memcpy ( msg->from, buf+l1, sizeof(msg->from) );
			if ( !strlen(msg->from) )
				strcpy ( msg->from, ENVELOPE_NULL_SENDER );
			f1++;
		}
		if ( !f2 && ( !strncmp ( buf, s2, l2 ) ) ) {
			memcpy ( msg->to, buf+l2, sizeof(msg->to) );
			f2++;
		}
		if ( !f3 && !strncmp ( buf, HEADER_SUBJECT, HEADER_SUBJECT_LEN ) ) {
			memcpy ( msg->subj, buf+HEADER_SUBJECT_LEN, sizeof(msg->subj) );
			f3++;
		}
	}
	pclose ( p );

	if ( f1 && f2 && f3 )
		dirty = 0;
	
	if ( (!dirty) && strlen(msg->to) && strlen(msg->from) )
		msg->hcached = 1;
	else
		msg->hcached = 0;
	return PFBE_OK;
}