diff options
| -rw-r--r-- | protocols/jabber/io.c | 3 | ||||
| -rw-r--r-- | protocols/jabber/jabber.c | 32 | ||||
| -rw-r--r-- | protocols/jabber/jabber.h | 2 | ||||
| -rw-r--r-- | unix.c | 6 | 
4 files changed, 42 insertions, 1 deletions
| diff --git a/protocols/jabber/io.c b/protocols/jabber/io.c index a28eea90..d3383375 100644 --- a/protocols/jabber/io.c +++ b/protocols/jabber/io.c @@ -172,6 +172,9 @@ static gboolean jabber_read_callback( gpointer data, gint fd, b_input_condition  	if( st > 0 )  	{ +		if( jd->flags & JFLAG_MOCK ) +			return TRUE; +		  		/* Parse. */  		if( xt_feed( jd->xt, buf, st ) < 0 )  		{ diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index 7d9547ab..fae55ffe 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -335,6 +335,25 @@ static int jabber_buddy_msg( struct im_connection *ic, char *who, char *message,  	if( g_strcasecmp( who, JABBER_XMLCONSOLE_HANDLE ) == 0 )  		return jabber_write( ic, message, strlen( message ) ); + +	if( g_strcasecmp( who, JABBER_MOCK_HANDLE ) == 0 ) +	{ +		/* Parse. */ +		if( xt_feed( jd->xt, message, strlen( message ) ) < 0 ) +		{ +			imcb_error( ic, "XML stream error" ); +			imc_logout( ic, TRUE ); +			return FALSE; +		} +		 +		/* Execute all handlers. */ +		if( !xt_handle( jd->xt, NULL, 1 ) ) +		{ +			/* Don't do anything, the handlers should have +			   aborted the connection already. */ +			return FALSE; +		} +	}  	if( ( s = strchr( who, '=' ) ) && jabber_chat_by_jid( ic, s + 1 ) )  		bud = jabber_buddy_by_ext_jid( ic, who, 0 ); @@ -425,7 +444,13 @@ static void jabber_add_buddy( struct im_connection *ic, char *who, char *group )  	if( g_strcasecmp( who, JABBER_XMLCONSOLE_HANDLE ) == 0 )  	{  		jd->flags |= JFLAG_XMLCONSOLE; -		imcb_add_buddy( ic, JABBER_XMLCONSOLE_HANDLE, NULL ); +		imcb_add_buddy( ic, who, NULL ); +		return; +	} +	else if( g_strcasecmp( who, JABBER_MOCK_HANDLE ) == 0 ) +	{ +		jd->flags |= JFLAG_MOCK; +		imcb_add_buddy( ic, who, NULL );  		return;  	} @@ -447,6 +472,11 @@ static void jabber_remove_buddy( struct im_connection *ic, char *who, char *grou  		*/  		return;  	} +	else if( g_strcasecmp( who, JABBER_MOCK_HANDLE ) == 0 ) +	{ +		jd->flags &= ~JFLAG_MOCK; +		return; +	}  	/* We should always do this part. Clean up our administration a little bit. */  	jabber_buddy_remove_bare( ic, who ); diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index adf9a291..364d561c 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -46,6 +46,7 @@ typedef enum  	                                   activates all XEP-85 related code. */  	JFLAG_XMLCONSOLE = 64,          /* If the user added an xmlconsole buddy. */  	JFLAG_STARTTLS_DONE = 128,      /* If a plaintext session was converted to TLS. */ +	JFLAG_MOCK = 256,               /* If the user added a mock buddy. */  } jabber_flags_t;  typedef enum @@ -187,6 +188,7 @@ struct jabber_transfer  };  #define JABBER_XMLCONSOLE_HANDLE "xmlconsole" +#define JABBER_MOCK_HANDLE "mock"  /* Prefixes to use for packet IDs (mainly for IQ packets ATM). Usually the     first one should be used, but when storing a packet in the cache, a @@ -40,6 +40,7 @@  #include <sys/wait.h>  #include <pwd.h>  #include <locale.h> +#include <grp.h>  #if defined(OTR_BI) || defined(OTR_PI)  #include "otr.h" @@ -151,9 +152,14 @@ int main( int argc, char *argv[] )  		pw = getpwnam( global.conf->user );  		if( pw )  		{ +			initgroups( global.conf->user, pw->pw_gid );  			setgid( pw->pw_gid );  			setuid( pw->pw_uid );  		} +		else +		{ +			log_message( LOGLVL_WARNING, "Failed to look up user %s.", global.conf->user ); +		}  	}  	/* Catch some signals to tell the user what's happening before quitting */ | 
