Changes in / [8076ec0:dce3903]
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
bitlbee.c
r8076ec0 rdce3903 293 293 srand( time( NULL ) ^ getpid() ); 294 294 295 b_main_init();296 297 295 /* Close the listening socket, we're a client. */ 298 296 close( global.listen_socket ); -
bitlbee.conf
r8076ec0 rdce3903 19 19 ## 20 20 # RunMode = Inetd 21 22 ## User:23 ##24 ## If BitlBee is started by root as a daemon, it can drop root privileges,25 ## and change to the specified user.26 ##27 # User = bitlbee28 21 29 22 ## DaemonPort/DaemonInterface: -
conf.c
r8076ec0 rdce3903 63 63 conf->ping_interval = 180; 64 64 conf->ping_timeout = 300; 65 conf->user = NULL;66 65 conf->max_filetransfer_size = G_MAXUINT; 67 66 proxytype = 0; … … 78 77 } 79 78 80 while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR: u:" ) ) >= 0 )79 while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR:" ) ) >= 0 ) 81 80 /* ^^^^ Just to make sure we skip this step from the REHASH handler. */ 82 81 { … … 134 133 " -D Daemon mode. (Still EXPERIMENTAL!)\n" 135 134 " -F Forking daemon. (one process per client)\n" 136 " -u Run daemon as specified user.\n"137 135 " -P Specify PID-file (not for inetd mode)\n" 138 136 " -i Specify the interface (by IP address) to listen on.\n" … … 154 152 ipc_master_set_statefile( optarg ); 155 153 } 156 else if( opt == 'u' )157 {158 g_free( conf->user );159 conf->user = g_strdup( optarg );160 }161 154 } 162 155 … … 200 193 else if( g_strcasecmp( ini->key, "daemoninterface" ) == 0 ) 201 194 { 202 g_free( conf->iface );203 195 conf->iface = g_strdup( ini->value ); 204 196 } 205 197 else if( g_strcasecmp( ini->key, "daemonport" ) == 0 ) 206 198 { 207 g_free( conf->port );208 199 conf->port = g_strdup( ini->value ); 209 200 } … … 219 210 else if( g_strcasecmp( ini->key, "authpassword" ) == 0 ) 220 211 { 221 g_free( conf->auth_pass );222 212 conf->auth_pass = g_strdup( ini->value ); 223 213 } 224 214 else if( g_strcasecmp( ini->key, "operpassword" ) == 0 ) 225 215 { 226 g_free( conf->oper_pass );227 216 conf->oper_pass = g_strdup( ini->value ); 228 217 } 229 218 else if( g_strcasecmp( ini->key, "hostname" ) == 0 ) 230 219 { 231 g_free( conf->hostname );232 220 conf->hostname = g_strdup( ini->value ); 233 221 } … … 294 282 g_free( url ); 295 283 } 296 else if( g_strcasecmp( ini->key, "user" ) == 0 )297 {298 g_free( conf->user );299 conf->user = g_strdup( ini->value );300 }301 284 else 302 285 { -
conf.h
r8076ec0 rdce3903 49 49 int ping_interval; 50 50 int ping_timeout; 51 char *user;52 51 size_t max_filetransfer_size; 53 52 } conf_t; -
configure
r8076ec0 rdce3903 135 135 [ -z "$CFLAGS" ] && CFLAGS=-g 136 136 echo 'DEBUG=1' >> Makefile.settings 137 CFLAGS="$CFLAGS -DDEBUG"137 echo '#define DEBUG' >> config.h 138 138 else 139 139 [ -z "$CFLAGS" ] && CFLAGS="-O2 -fno-strict-aliasing" -
irc.c
r8076ec0 rdce3903 324 324 } 325 325 326 if( ( cs = set_getstr( &irc->set, "charset" ) ) )326 if( ( cs = set_getstr( &irc->set, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) 327 327 { 328 328 conv[IRC_MAX_LINE] = 0; 329 if( do_iconv( cs, "UTF-8", lines[i], conv, 0, IRC_MAX_LINE - 2 ) == -1 ) 330 { 331 if( irc->status & USTATUS_LOGGED_IN ) 332 irc_usermsg( irc, "ERROR: Charset mismatch detected. The charset " 333 "setting is currently set to %s, so please make " 334 "sure your IRC client will send and accept text in " 335 "that charset, or tell BitlBee which charset to " 336 "expect by changing the charset setting. See " 337 "`help set charset' for more information. Your " 338 "message was ignored.", cs ); 339 *conv = 0; 340 } 341 lines[i] = conv; 329 if( do_iconv( cs, "UTF-8", lines[i], conv, 0, IRC_MAX_LINE - 2 ) != -1 ) 330 lines[i] = conv; 342 331 } 343 332 -
lib/events.h
r8076ec0 rdce3903 45 45 #include <gmodule.h> 46 46 47 /* The conditions you can pass to b_input_add()/that will be passed to47 /* The conditions you can pass to gaim_input_add()/that will be passed to 48 48 the given callback function. */ 49 49 typedef enum { … … 58 58 #define GAIM_ERR_COND (G_IO_HUP | G_IO_ERR | G_IO_NVAL) 59 59 60 / * #define event_debug( x... ) printf( x ) */60 // #define event_debug( x... ) printf( x ) 61 61 #define event_debug( x... ) 62 62 -
lib/events_libevent.c
r8076ec0 rdce3903 32 32 #include <unistd.h> 33 33 #include <sys/types.h> 34 #include "proxy.h" 35 34 36 #include <sys/time.h> 35 37 #include <event.h> 36 #include "proxy.h" 37 38 static void b_main_restart(); 39 static guint id_next = 1; 38 39 static guint id_next; 40 40 static GHashTable *id_hash; 41 41 static int quitting = 0; … … 48 48 static GHashTable *write_hash; 49 49 50 struct event_base *leh;51 struct event_base *old_leh;52 53 50 struct b_event_data 54 51 { … … 62 59 void b_main_init() 63 60 { 64 if( leh != NULL ) 65 { 66 /* Clean up the hash tables? */ 67 68 b_main_restart(); 69 old_leh = leh; 70 } 71 72 leh = event_init(); 73 61 event_init(); 62 63 id_next = 1; 74 64 id_hash = g_hash_table_new( g_int_hash, g_int_equal ); 75 65 read_hash = g_hash_table_new( g_int_hash, g_int_equal ); … … 79 69 void b_main_run() 80 70 { 81 /* This while loop is necessary to exit the event loop and start a 82 different one (necessary for ForkDaemon mode). */ 83 while( event_base_dispatch( leh ) == 0 && !quitting ) 84 { 85 if( old_leh != NULL ) 86 { 87 /* For some reason this just isn't allowed... 88 Possibly a bug in older versions, will see later. 89 event_base_free( old_leh ); */ 90 old_leh = NULL; 91 } 92 93 event_debug( "New event loop.\n" ); 94 } 95 } 96 97 static void b_main_restart() 71 event_dispatch(); 72 } 73 74 void b_main_quit() 98 75 { 99 76 struct timeval tv; 100 77 101 memset( &tv, 0, sizeof( struct timeval ) ); 102 event_base_loopexit( leh, &tv ); 103 104 event_debug( "b_main_restart()\n" ); 105 } 106 107 void b_main_quit() 108 { 109 /* Tell b_main_run() that it shouldn't restart the loop. Also, 110 libevent sometimes generates events before really quitting, 78 /* libevent sometimes generates events before really quitting, 111 79 we want to stop them. */ 112 80 quitting = 1; 113 81 114 b_main_restart(); 82 memset( &tv, 0, sizeof( struct timeval ) ); 83 event_loopexit( &tv ); 115 84 } 116 85 -
protocols/jabber/conference.c
r8076ec0 rdce3903 24 24 #include "jabber.h" 25 25 26 static xt_status jabber_chat_join_failed( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );27 28 26 struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char *nick, char *password ) 29 27 { … … 37 35 xt_add_attr( node, "xmlns", XMLNS_MUC ); 38 36 node = jabber_make_packet( "presence", NULL, roomjid, node ); 39 jabber_cache_add( ic, node, jabber_chat_join_failed );40 37 41 38 if( !jabber_write_packet( ic, node ) ) 42 39 { 43 40 g_free( roomjid ); 41 xt_free_node( node ); 44 42 return NULL; 45 43 } 44 xt_free_node( node ); 46 45 47 46 jc = g_new0( struct jabber_chat, 1 ); … … 64 63 65 64 return c; 66 }67 68 static xt_status jabber_chat_join_failed( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )69 {70 struct jabber_error *err;71 struct jabber_buddy *bud;72 char *room;73 74 room = xt_find_attr( orig, "to" );75 if( ( bud = jabber_buddy_by_jid( ic, room, 0 ) ) )76 jabber_chat_free( jabber_chat_by_jid( ic, bud->bare_jid ) );77 78 err = jabber_error_parse( xt_find_node( node->children, "error" ), XMLNS_STANZA_ERROR );79 if( err )80 {81 imcb_error( ic, "Error joining groupchat %s: %s%s%s",82 bud->bare_jid, err->code, err->text ? ": " : "",83 err->text ? err->text : "" );84 jabber_error_free( err );85 }86 87 return XT_HANDLED;88 }89 90 struct groupchat *jabber_chat_by_jid( struct im_connection *ic, const char *name )91 {92 char *normalized = jabber_normalize( name );93 struct groupchat *ret;94 struct jabber_chat *jc;95 96 for( ret = ic->groupchats; ret; ret = ret->next )97 {98 jc = ret->data;99 if( strcmp( normalized, jc->name ) == 0 )100 break;101 }102 g_free( normalized );103 104 return ret;105 65 } 106 66 … … 188 148 char *s; 189 149 190 if( ( chat = jabber_chat_by_ jid( ic, bud->bare_jid ) ) == NULL )150 if( ( chat = jabber_chat_by_name( ic, bud->bare_jid ) ) == NULL ) 191 151 { 192 152 /* How could this happen?? We could do kill( self, 11 ) … … 290 250 return; 291 251 } 292 else if( ( chat = jabber_chat_by_ jid( ic, bud->bare_jid ) ) == NULL )252 else if( ( chat = jabber_chat_by_name( ic, bud->bare_jid ) ) == NULL ) 293 253 { 294 254 /* How could this happen?? We could do kill( self, 11 ) -
protocols/jabber/iq.c
r8076ec0 rdce3903 31 31 { 32 32 struct im_connection *ic = data; 33 struct jabber_data *jd = ic->proto_data; 33 34 struct xt_node *c, *reply = NULL; 34 35 char *type, *s; … … 46 47 if( strcmp( type, "result" ) == 0 || strcmp( type, "error" ) == 0 ) 47 48 { 48 return jabber_cache_handle_packet( ic, node ); 49 struct jabber_cache_entry *entry; 50 51 if( ( s = xt_find_attr( node, "id" ) ) == NULL || 52 strncmp( s, jd->cached_id_prefix, strlen( jd->cached_id_prefix ) ) != 0 ) 53 { 54 /* Silently ignore it, without an ID (or a non-cache 55 ID) we don't know how to handle the packet and we 56 probably don't have to. */ 57 return XT_HANDLED; 58 } 59 60 entry = g_hash_table_lookup( jd->node_cache, s ); 61 62 if( entry == NULL ) 63 imcb_log( ic, "WARNING: Received IQ-%s packet with unknown/expired ID %s!", type, s ); 64 else if( entry->func ) 65 return entry->func( ic, node, entry->node ); 49 66 } 50 67 else if( strcmp( type, "get" ) == 0 ) -
protocols/jabber/jabber.c
r8076ec0 rdce3903 226 226 jd->cached_id_prefix = g_strdup_printf( "%s%s", JABBER_CACHED_ID, s ); 227 227 g_free( s ); 228 229 printf( "%s\n", jd->cached_id_prefix ); 228 230 } 229 231 … … 270 272 return jabber_write( ic, message, strlen( message ) ); 271 273 272 if( ( s = strchr( who, '=' ) ) && jabber_chat_by_ jid( ic, s + 1 ) )274 if( ( s = strchr( who, '=' ) ) && jabber_chat_by_name( ic, s + 1 ) ) 273 275 bud = jabber_buddy_by_ext_jid( ic, who, 0 ); 274 276 else … … 397 399 if( strchr( room, '@' ) == NULL ) 398 400 imcb_error( ic, "Invalid room name: %s", room ); 399 else if( jabber_chat_by_ jid( ic, room ) )401 else if( jabber_chat_by_name( ic, room ) ) 400 402 imcb_error( ic, "Already present in chat `%s'", room ); 401 403 else -
protocols/jabber/jabber.h
r8076ec0 rdce3903 227 227 void jabber_cache_entry_free( gpointer entry ); 228 228 void jabber_cache_clean( struct im_connection *ic ); 229 xt_status jabber_cache_handle_packet( struct im_connection *ic, struct xt_node *node );230 229 const struct jabber_away_state *jabber_away_state_by_code( char *code ); 231 230 const struct jabber_away_state *jabber_away_state_by_name( char *name ); … … 250 249 int jabber_buddy_remove( struct im_connection *ic, char *full_jid ); 251 250 int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid ); 251 struct groupchat *jabber_chat_by_name( struct im_connection *ic, const char *name ); 252 252 time_t jabber_get_timestamp( struct xt_node *xt ); 253 253 struct jabber_error *jabber_error_parse( struct xt_node *node, char *xmlns ); … … 272 272 /* conference.c */ 273 273 struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char *nick, char *password ); 274 struct groupchat *jabber_chat_by_jid( struct im_connection *ic, const char *name );275 274 void jabber_chat_free( struct groupchat *c ); 276 275 int jabber_chat_msg( struct groupchat *ic, char *message, int flags ); -
protocols/jabber/jabber_util.c
r8076ec0 rdce3903 183 183 return FALSE; 184 184 } 185 }186 187 xt_status jabber_cache_handle_packet( struct im_connection *ic, struct xt_node *node )188 {189 struct jabber_data *jd = ic->proto_data;190 struct jabber_cache_entry *entry;191 char *s;192 193 if( ( s = xt_find_attr( node, "id" ) ) == NULL ||194 strncmp( s, jd->cached_id_prefix, strlen( jd->cached_id_prefix ) ) != 0 )195 {196 /* Silently ignore it, without an ID (or a non-cache197 ID) we don't know how to handle the packet and we198 probably don't have to. */199 return XT_HANDLED;200 }201 202 entry = g_hash_table_lookup( jd->node_cache, s );203 204 if( entry == NULL )205 {206 imcb_log( ic, "WARNING: Received %s-%s packet with unknown/expired ID %s!",207 node->name, xt_find_attr( node, "type" ) ? : "(no type)", s );208 }209 else if( entry->func )210 {211 return entry->func( ic, node, entry->node );212 }213 214 return XT_HANDLED;215 185 } 216 186 … … 625 595 } 626 596 597 struct groupchat *jabber_chat_by_name( struct im_connection *ic, const char *name ) 598 { 599 char *normalized = jabber_normalize( name ); 600 struct groupchat *ret; 601 struct jabber_chat *jc; 602 603 for( ret = ic->groupchats; ret; ret = ret->next ) 604 { 605 jc = ret->data; 606 if( strcmp( normalized, jc->name ) == 0 ) 607 break; 608 } 609 g_free( normalized ); 610 611 return ret; 612 } 613 627 614 time_t jabber_get_timestamp( struct xt_node *xt ) 628 615 { … … 676 663 struct jabber_error *jabber_error_parse( struct xt_node *node, char *xmlns ) 677 664 { 678 struct jabber_error *err ;665 struct jabber_error *err = g_new0( struct jabber_error, 1 ); 679 666 struct xt_node *c; 680 667 char *s; 681 668 682 if( node == NULL )683 return NULL;684 685 err = g_new0( struct jabber_error, 1 );686 669 err->type = xt_find_attr( node, "type" ); 687 670 -
protocols/jabber/presence.c
r8076ec0 rdce3903 40 40 { 41 41 *s = 0; 42 if( jabber_chat_by_ jid( ic, from ) )42 if( jabber_chat_by_name( ic, from ) ) 43 43 is_chat = 1; 44 44 *s = '/'; … … 164 164 else if( strcmp( type, "error" ) == 0 ) 165 165 { 166 return jabber_cache_handle_packet( ic, node );167 168 /*169 166 struct jabber_error *err; 167 170 168 if( ( c = xt_find_node( node->children, "error" ) ) ) 171 169 { … … 175 173 err->text ? err->text : "" ); 176 174 jabber_error_free( err ); 177 } */ 175 } 176 /* What else to do with it? */ 178 177 } 179 178 -
protocols/jabber/si.c
r8076ec0 rdce3903 372 372 tf->sid = g_strdup_printf( "BitlBeeJabberSID%d", tf->ft->local_id ); 373 373 374 if( ( s = strchr( who, '=' ) ) && jabber_chat_by_ jid( ic, s + 1 ) )374 if( ( s = strchr( who, '=' ) ) && jabber_chat_by_name( ic, s + 1 ) ) 375 375 bud = jabber_buddy_by_ext_jid( ic, who, 0 ); 376 376 else -
protocols/oscar/msgcookie.c
r8076ec0 rdce3903 131 131 } 132 132 133 #if 0 /* debugging feature */ 134 int aim_dumpcookie(aim_msgcookie_t *cookie) 135 { 136 137 if (!cookie) 138 return -EINVAL; 139 140 printf("\tCookie at %p: %d/%s with %p, next %p\n", 141 cookie, cookie->type, cookie->cookie, 142 cookie->data, cookie->next); 143 144 return 0; 145 } 146 #endif 147 133 148 /** 134 149 * aim_cookie_free - free an aim_msgcookie_t struct -
unix.c
r8076ec0 rdce3903 34 34 #include <sys/time.h> 35 35 #include <sys/wait.h> 36 #include <pwd.h>37 36 38 37 global_t global; /* Against global namespace pollution */ … … 46 45 struct sigaction sig, old; 47 46 47 memset( &global, 0, sizeof( global_t ) ); 48 48 49 log_init(); 49 50 CONF_FILE = g_strdup( CONF_FILE_DEF ); … … 86 87 return( i ); 87 88 88 if( ( global.conf->user && *global.conf->user ) &&89 ( global.conf->runmode == RUNMODE_DAEMON ||90 global.conf->runmode == RUNMODE_FORKDAEMON ) &&91 ( !getuid() || !geteuid() ) )92 {93 struct passwd *pw = NULL;94 pw = getpwnam( global.conf->user );95 if( pw )96 {97 setgid( pw->pw_gid );98 setuid( pw->pw_uid );99 }100 }101 102 89 global.storage = storage_init( global.conf->primary_storage, global.conf->migrate_storage ); 103 if( global.storage == NULL ) 104 { 90 if ( global.storage == NULL) { 105 91 log_message( LOGLVL_ERROR, "Unable to load storage backend '%s'", global.conf->primary_storage ); 106 92 return( 1 ); 107 93 } 94 108 95 109 96 /* Catch some signals to tell the user what's happening before quitting */
Note: See TracChangeset
for help on using the changeset viewer.