Changes in / [22bf64e:e7f46c5]
- Files:
-
- 3 deleted
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
.bzrignore
r22bf64e re7f46c5 8 8 build-arch-stamp 9 9 tags 10 decode11 encode -
Makefile
r22bf64e re7f46c5 10 10 11 11 # Program variables 12 objects = account.o bitlbee.o commands.o conf.o crypting.o help.o ini.o irc.o log.o nick.o query.o set.o unix.o url.o user.o storage_text.o storage.o12 objects = account.o bitlbee.o commands.o conf.o crypting.o help.o ini.o irc.o log.o nick.o query.o set.o unix.o url.o user.o 13 13 subdirs = protocols 14 14 -
bitlbee.c
r22bf64e re7f46c5 27 27 #include "bitlbee.h" 28 28 #include "commands.h" 29 #include "crypting.h" 29 30 #include "protocols/nogaim.h" 30 31 #include "help.h" … … 164 165 return FALSE; 165 166 } 166 167 /* Very naughty, go read the RFCs! >:) */ 168 if( irc->readbuffer && ( strlen( irc->readbuffer ) > 1024 ) ) 169 { 170 log_message( LOGLVL_ERROR, "Maximum line length exceeded." ); 171 irc_free( irc ); 172 return FALSE; 173 } 174 167 175 168 return TRUE; 176 169 } … … 243 236 } 244 237 238 int bitlbee_load( irc_t *irc, char* password ) 239 { 240 char s[512]; 241 char *line; 242 int proto; 243 char nick[MAX_NICK_LENGTH+1]; 244 FILE *fp; 245 user_t *ru = user_find( irc, ROOT_NICK ); 246 247 if( irc->status == USTATUS_IDENTIFIED ) 248 return( 1 ); 249 250 g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" ); 251 fp = fopen( s, "r" ); 252 if( !fp ) return( 0 ); 253 254 fscanf( fp, "%32[^\n]s", s ); 255 if( setpass( irc, password, s ) < 0 ) 256 { 257 fclose( fp ); 258 return( -1 ); 259 } 260 261 /* Do this now. If the user runs with AuthMode = Registered, the 262 account command will not work otherwise. */ 263 irc->status = USTATUS_IDENTIFIED; 264 265 while( fscanf( fp, "%511[^\n]s", s ) > 0 ) 266 { 267 fgetc( fp ); 268 line = deobfucrypt( irc, s ); 269 root_command_string( irc, ru, line, 0 ); 270 g_free( line ); 271 } 272 fclose( fp ); 273 274 g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" ); 275 fp = fopen( s, "r" ); 276 if( !fp ) return( 0 ); 277 while( fscanf( fp, "%s %d %s", s, &proto, nick ) > 0 ) 278 { 279 http_decode( s ); 280 nick_set( irc, s, proto, nick ); 281 } 282 fclose( fp ); 283 284 if( set_getint( irc, "auto_connect" ) ) 285 { 286 strcpy( s, "account on" ); /* Can't do this directly because r_c_s alters the string */ 287 root_command_string( irc, ru, s, 0 ); 288 } 289 290 return( 1 ); 291 } 292 293 int bitlbee_save( irc_t *irc ) 294 { 295 char s[512]; 296 char path[512], new_path[512]; 297 char *line; 298 nick_t *n; 299 set_t *set; 300 mode_t ou = umask( 0077 ); 301 account_t *a; 302 FILE *fp; 303 char *hash; 304 305 /*\ 306 * [SH] Nothing should be saved if no password is set, because the 307 * password is not set if it was wrong, or if one is not identified 308 * yet. This means that a malicious user could easily overwrite 309 * files owned by someone else: 310 * a Bad Thing, methinks 311 \*/ 312 313 /* [WVG] No? Really? */ 314 315 /*\ 316 * [SH] Okay, okay, it wasn't really Wilmer who said that, it was 317 * me. I just thought it was funny. 318 \*/ 319 320 hash = hashpass( irc ); 321 if( hash == NULL ) 322 { 323 irc_usermsg( irc, "Please register yourself if you want to save your settings." ); 324 return( 0 ); 325 } 326 327 g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks~" ); 328 fp = fopen( path, "w" ); 329 if( !fp ) return( 0 ); 330 for( n = irc->nicks; n; n = n->next ) 331 { 332 strcpy( s, n->handle ); 333 s[169] = 0; /* Prevent any overflow (169 ~ 512 / 3) */ 334 http_encode( s ); 335 g_snprintf( s + strlen( s ), 510 - strlen( s ), " %d %s", n->proto, n->nick ); 336 if( fprintf( fp, "%s\n", s ) != strlen( s ) + 1 ) 337 { 338 irc_usermsg( irc, "fprintf() wrote too little. Disk full?" ); 339 fclose( fp ); 340 return( 0 ); 341 } 342 } 343 if( fclose( fp ) != 0 ) 344 { 345 irc_usermsg( irc, "fclose() reported an error. Disk full?" ); 346 return( 0 ); 347 } 348 349 g_snprintf( new_path, 512, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" ); 350 if( unlink( new_path ) != 0 ) 351 { 352 if( errno != ENOENT ) 353 { 354 irc_usermsg( irc, "Error while removing old .nicks file" ); 355 return( 0 ); 356 } 357 } 358 if( rename( path, new_path ) != 0 ) 359 { 360 irc_usermsg( irc, "Error while renaming new .nicks file" ); 361 return( 0 ); 362 } 363 364 g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts~" ); 365 fp = fopen( path, "w" ); 366 if( !fp ) return( 0 ); 367 if( fprintf( fp, "%s", hash ) != strlen( hash ) ) 368 { 369 irc_usermsg( irc, "fprintf() wrote too little. Disk full?" ); 370 fclose( fp ); 371 return( 0 ); 372 } 373 g_free( hash ); 374 375 for( a = irc->accounts; a; a = a->next ) 376 { 377 if( a->protocol == PROTO_OSCAR || a->protocol == PROTO_ICQ || a->protocol == PROTO_TOC ) 378 g_snprintf( s, sizeof( s ), "account add oscar \"%s\" \"%s\" %s", a->user, a->pass, a->server ); 379 else 380 g_snprintf( s, sizeof( s ), "account add %s \"%s\" \"%s\" \"%s\"", 381 proto_name[a->protocol], a->user, a->pass, a->server ? a->server : "" ); 382 383 line = obfucrypt( irc, s ); 384 if( *line ) 385 { 386 if( fprintf( fp, "%s\n", line ) != strlen( line ) + 1 ) 387 { 388 irc_usermsg( irc, "fprintf() wrote too little. Disk full?" ); 389 fclose( fp ); 390 return( 0 ); 391 } 392 } 393 g_free( line ); 394 } 395 396 for( set = irc->set; set; set = set->next ) 397 { 398 if( set->value && set->def ) 399 { 400 g_snprintf( s, sizeof( s ), "set %s \"%s\"", set->key, set->value ); 401 line = obfucrypt( irc, s ); 402 if( *line ) 403 { 404 if( fprintf( fp, "%s\n", line ) != strlen( line ) + 1 ) 405 { 406 irc_usermsg( irc, "fprintf() wrote too little. Disk full?" ); 407 fclose( fp ); 408 return( 0 ); 409 } 410 } 411 g_free( line ); 412 } 413 } 414 415 if( strcmp( irc->mynick, ROOT_NICK ) != 0 ) 416 { 417 g_snprintf( s, sizeof( s ), "rename %s %s", ROOT_NICK, irc->mynick ); 418 line = obfucrypt( irc, s ); 419 if( *line ) 420 { 421 if( fprintf( fp, "%s\n", line ) != strlen( line ) + 1 ) 422 { 423 irc_usermsg( irc, "fprintf() wrote too little. Disk full?" ); 424 fclose( fp ); 425 return( 0 ); 426 } 427 } 428 g_free( line ); 429 } 430 if( fclose( fp ) != 0 ) 431 { 432 irc_usermsg( irc, "fclose() reported an error. Disk full?" ); 433 return( 0 ); 434 } 435 436 g_snprintf( new_path, 512, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" ); 437 if( unlink( new_path ) != 0 ) 438 { 439 if( errno != ENOENT ) 440 { 441 irc_usermsg( irc, "Error while removing old .accounts file" ); 442 return( 0 ); 443 } 444 } 445 if( rename( path, new_path ) != 0 ) 446 { 447 irc_usermsg( irc, "Error while renaming new .accounts file" ); 448 return( 0 ); 449 } 450 451 umask( ou ); 452 453 return( 1 ); 454 } 455 245 456 void bitlbee_shutdown( gpointer data ) 246 457 { -
bitlbee.h
r22bf64e re7f46c5 30 30 31 31 #define PACKAGE "BitlBee" 32 #define BITLBEE_VERSION " BZR"32 #define BITLBEE_VERSION "1.0pre" 33 33 #define VERSION BITLBEE_VERSION 34 34 … … 100 100 101 101 #include "irc.h" 102 #include "storage.h"103 102 #include "set.h" 104 103 #include "protocols/nogaim.h" … … 116 115 help_t *help; 117 116 conf_t *conf; 118 GList *storage; /* The first backend in the list will be used for saving */119 117 char *helpfile; 120 118 GMainLoop *loop; … … 129 127 int root_command_string( irc_t *irc, user_t *u, char *command, int flags ); 130 128 int root_command( irc_t *irc, char *command[] ); 129 int bitlbee_load( irc_t *irc, char *password ); 130 int bitlbee_save( irc_t *irc ); 131 131 void bitlbee_shutdown( gpointer data ); 132 132 double gettime( void ); -
commands.c
r22bf64e re7f46c5 86 86 int cmd_identify( irc_t *irc, char **cmd ) 87 87 { 88 storage_status_t status = storage_load( irc->nick, cmd[1], irc);89 90 switch (status) {91 case STORAGE_INVALID_PASSWORD:88 int checkie = bitlbee_load( irc, cmd[1] ); 89 90 if( checkie == -1 ) 91 { 92 92 irc_usermsg( irc, "Incorrect password" ); 93 break; 94 case STORAGE_NO_SUCH_USER: 93 } 94 else if( checkie == 0 ) 95 { 95 96 irc_usermsg( irc, "The nick is (probably) not registered" ); 96 break; 97 case STORAGE_OK: 97 } 98 else if( checkie == 1 ) 99 { 98 100 irc_usermsg( irc, "Password accepted" ); 99 break; 100 default: 101 } 102 else 103 { 101 104 irc_usermsg( irc, "Something very weird happened" ); 102 break; 103 } 104 105 } 106 105 107 return( 0 ); 106 108 } … … 108 110 int cmd_register( irc_t *irc, char **cmd ) 109 111 { 112 int checkie; 113 char path[512]; 114 110 115 if( global.conf->authmode == AUTHMODE_REGISTERED ) 111 116 { … … 113 118 return( 0 ); 114 119 } 115 116 irc_setpass( irc, cmd[1] ); 117 switch( storage_save( irc, FALSE )) { 118 case STORAGE_ALREADY_EXISTS: 119 irc_usermsg( irc, "Nick is already registered" ); 120 break; 121 122 case STORAGE_OK: 123 irc->status = USTATUS_IDENTIFIED; 124 break; 125 126 default: 127 irc_usermsg( irc, "Error registering" ); 128 break; 120 121 g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" ); 122 checkie = access( path, F_OK ); 123 124 g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" ); 125 checkie += access( path, F_OK ); 126 127 if( checkie == -2 ) 128 { 129 setpassnc( irc, cmd[1] ); 130 root_command_string( irc, user_find( irc, irc->mynick ), "save", 0 ); 131 irc->status = USTATUS_IDENTIFIED; 132 } 133 else 134 { 135 irc_usermsg( irc, "Nick is already registered" ); 129 136 } 130 137 … … 134 141 int cmd_drop( irc_t *irc, char **cmd ) 135 142 { 136 storage_status_t status; 137 138 status = storage_remove (irc->nick, cmd[1]); 139 switch (status) { 140 case STORAGE_NO_SUCH_USER: 143 char s[512]; 144 FILE *fp; 145 146 g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" ); 147 fp = fopen( s, "r" ); 148 if( !fp ) 149 { 141 150 irc_usermsg( irc, "That account does not exist" ); 142 151 return( 0 ); 143 case STORAGE_INVALID_PASSWORD: 144 irc_usermsg( irc, "Password invalid" ); 145 return( 0 ); 146 case STORAGE_OK: 147 irc_setpass( irc, NULL ); 148 irc_usermsg( irc, "Account `%s' removed", irc->nick ); 149 return( 0 ); 150 default: 151 irc_usermsg( irc, "Error: '%d'", status ); 152 return( 0 ); 153 } 152 } 153 154 fscanf( fp, "%32[^\n]s", s ); 155 fclose( fp ); 156 if( setpass( irc, cmd[1], s ) < 0 ) 157 { 158 irc_usermsg( irc, "Incorrect password" ); 159 return( 0 ); 160 } 161 162 g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" ); 163 unlink( s ); 164 165 g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" ); 166 unlink( s ); 167 168 setpassnc( irc, NULL ); 169 irc_usermsg( irc, "Files belonging to account `%s' removed", irc->nick ); 170 171 return( 0 ); 154 172 } 155 173 … … 616 634 int cmd_save( irc_t *irc, char **cmd ) 617 635 { 618 if( storage_save( irc, TRUE ) == STORAGE_OK)636 if( bitlbee_save( irc ) ) 619 637 irc_usermsg( irc, "Configuration saved" ); 620 638 else -
conf.c
r22bf64e re7f46c5 50 50 conf->nofork = 0; 51 51 conf->verbose = 0; 52 conf->primary_storage = "text";53 52 conf->runmode = RUNMODE_INETD; 54 53 conf->authmode = AUTHMODE_OPEN; … … 199 198 conf->motdfile = g_strdup( ini->value ); 200 199 } 201 else if( g_strcasecmp( ini->key, "account_storage" ) == 0 )202 {203 g_free( conf->primary_storage );204 conf->primary_storage = g_strdup( ini->value );205 }206 else if( g_strcasecmp( ini->key, "account_storage_migrate" ) == 0 )207 {208 g_strfreev( conf->migrate_storage );209 conf->migrate_storage = g_strsplit( ini->value, " \t,;", -1 );210 }211 200 else if( g_strcasecmp( ini->key, "pinginterval" ) == 0 ) 212 201 { -
conf.h
r22bf64e re7f46c5 42 42 char *configdir; 43 43 char *motdfile; 44 char *primary_storage;45 char **migrate_storage;46 44 int ping_interval; 47 45 int ping_timeout; -
configure
r22bf64e re7f46c5 343 343 case "$arch" in 344 344 Linux ) 345 echo 'Linux.' 345 346 ;; 346 347 GNU/* ) 348 echo 'Debian with non-Linux kernel?' 347 349 ;; 348 350 *BSD ) 351 echo '*BSD.' 349 352 echo 'EFLAGS+=-liconv' >> Makefile.settings; 350 353 ;; 351 354 SunOS ) 355 echo 'Solaris.' 352 356 echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings 353 357 echo 'STRIP=\# skip strip' >> Makefile.settings … … 355 359 ;; 356 360 Darwin ) 361 echo 'Darwin/Mac OS X.' 357 362 echo 'EFLAGS+=-liconv' >> Makefile.settings; 358 363 ;; 359 364 IRIX ) 365 echo 'IRIX.' 360 366 ;; 361 367 CYGWIN* ) … … 363 369 ;; 364 370 * ) 365 echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.' 366 echo 'Please report any problems at http://bugs.bitlbee.org/.' 371 echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV. Please report any problems to <wilmer@gaast.net>.' 367 372 ;; 368 373 esac -
crypting.c
r22bf64e re7f46c5 29 29 the programs will be built. */ 30 30 31 #ifndef CRYPTING_MAIN 32 #define BITLBEE_CORE 33 #include "bitlbee.h" 34 #include "irc.h" 31 35 #include "md5.h" 32 36 #include "crypting.h" … … 35 39 #include <stdlib.h> 36 40 41 #else 42 43 typedef struct irc 44 { 45 char *password; 46 } irc_t; 47 48 #define set_add( a, b, c, d ) 49 #define set_find( a, b ) NULL 50 51 #include "md5.h" 52 #include "crypting.h" 53 #include <string.h> 54 #include <stdio.h> 55 #include <stdlib.h> 56 57 #define irc_usermsg 58 59 #endif 60 37 61 /*\ 38 62 * [SH] Do _not_ call this if it's not entirely sure that it will not cause … … 41 65 \*/ 42 66 43 int checkpass (const char *pass, const char *md5sum) 44 { 67 /* USE WITH CAUTION! 68 Sets pass without checking */ 69 void setpassnc (irc_t *irc, char *pass) { 70 if (!set_find (irc, "password")) 71 set_add (irc, "password", NULL, passchange); 72 73 if (irc->password) g_free (irc->password); 74 75 if (pass) { 76 irc->password = g_strdup (pass); 77 irc_usermsg (irc, "Password successfully changed"); 78 } else { 79 irc->password = NULL; 80 } 81 } 82 83 char *passchange (irc_t *irc, void *set, char *value) { 84 setpassnc (irc, value); 85 return (NULL); 86 } 87 88 int setpass (irc_t *irc, char *pass, char* md5sum) { 45 89 md5_state_t md5state; 46 90 md5_byte_t digest[16]; … … 59 103 if (digits[1] != md5sum[j + 1]) return (-1); 60 104 } 61 62 return( 0 ); 63 } 64 65 66 char *hashpass (const char *password) 67 { 105 106 /* If pass is correct, we end up here and we set the pass */ 107 setpassnc (irc, pass); 108 109 return (0); 110 } 111 112 char *hashpass (irc_t *irc) { 68 113 md5_state_t md5state; 69 114 md5_byte_t digest[16]; … … 72 117 char *rv; 73 118 74 if (password == NULL) return (NULL); 75 76 rv = g_new0 (char, 33); 119 if (irc->password == NULL) return (NULL); 120 121 rv = (char *)g_malloc (33); 122 memset (rv, 0, 33); 77 123 78 124 md5_init (&md5state); 79 md5_append (&md5state, ( const unsigned char *)password, strlen (password));125 md5_append (&md5state, (unsigned char *)irc->password, strlen (irc->password)); 80 126 md5_finish (&md5state, digest); 81 127 … … 89 135 } 90 136 91 char *obfucrypt (char *line, const char *password) 92 { 137 char *obfucrypt (irc_t *irc, char *line) { 93 138 int i, j; 94 139 char *rv; 95 140 96 if (password == NULL) return (NULL); 97 98 rv = g_new0 (char, strlen (line) + 1); 141 if (irc->password == NULL) return (NULL); 142 143 rv = (char *)g_malloc (strlen (line) + 1); 144 memset (rv, '\0', strlen (line) + 1); 99 145 100 146 i = j = 0; … … 102 148 /* Encrypt/obfuscate the line, using the password */ 103 149 if (*(signed char*)line < 0) *line = - (*line); 104 105 rv[j] = *line + password[i]; /* Overflow intended */ 150 if (((signed char*)irc->password)[i] < 0) irc->password[i] = - irc->password[i]; 151 152 rv[j] = *line + irc->password[i]; /* Overflow intended */ 106 153 107 154 line++; 108 if (! password[++i]) i = 0;155 if (!irc->password[++i]) i = 0; 109 156 j++; 110 157 } … … 113 160 } 114 161 115 char *deobfucrypt (char *line, const char *password) 116 { 162 char *deobfucrypt (irc_t *irc, char *line) { 117 163 int i, j; 118 164 char *rv; 119 165 120 if (password == NULL) return (NULL); 121 122 rv = g_new0 (char, strlen (line) + 1); 166 if (irc->password == NULL) return (NULL); 167 168 rv = (char *)g_malloc (strlen (line) + 1); 169 memset (rv, '\0', strlen (line) + 1); 123 170 124 171 i = j = 0; 125 172 while (*line) { 126 173 /* Decrypt/deobfuscate the line, using the pass */ 127 rv[j] = *line - password[i]; /* Overflow intended */174 rv[j] = *line - irc->password[i]; /* Overflow intended */ 128 175 129 176 line++; 130 if (! password[++i]) i = 0;177 if (!irc->password[++i]) i = 0; 131 178 j++; 132 179 } … … 142 189 int main( int argc, char *argv[] ) 143 190 { 191 irc_t *irc = g_malloc( sizeof( irc_t ) ); 144 192 char *hash, *action, line[256]; 145 char* (*func)( char *, constchar * );193 char* (*func)( irc_t *, char * ); 146 194 147 195 if( argc < 2 ) … … 153 201 } 154 202 155 hash = hashpass( argv[1] ); 203 memset( irc, 0, sizeof( irc_t ) ); 204 irc->password = g_strdup( argv[1] ); 205 206 hash = hashpass( irc ); 156 207 action = argv[0] + strlen( argv[0] ) - strlen( "encode" ); 157 208 … … 185 236 fgetc( stdin ); 186 237 187 out = func( line, argv[1]);238 out = func( irc, line ); 188 239 printf( "%s\n", out ); 189 240 g_free( out ); -
crypting.h
r22bf64e re7f46c5 24 24 */ 25 25 26 int checkpass (const char *password, const char *md5sum); 27 char *hashpass (const char *password); 28 char *obfucrypt (char *line, const char *password); 29 char *deobfucrypt (char *line, const char *password); 26 void setpassnc (irc_t *irc, char *pass); /* USE WITH CAUTION! */ 27 char *passchange (irc_t *irc, void *set, char *value); 28 int setpass (irc_t *irc, char *pass, char* md5sum); 29 char *hashpass (irc_t *irc); 30 char *obfucrypt (irc_t *irc, char *line); 31 char *deobfucrypt (irc_t *irc, char *line); -
doc/AUTHORS
r22bf64e re7f46c5 4 4 Main developer 5 5 6 Jelmer 'ctrlsoft' Vernooij <jelmer@ samba.org>6 Jelmer 'ctrlsoft' Vernooij <jelmer@nl.linux.org> 7 7 Documentation, general hacking, Win32 port 8 8 -
doc/CHANGES
r22bf64e re7f46c5 22 22 abusing it as a port scanner. We aren't aware of any Jabber server that 23 23 runs on other ports than those. If you are, please warn us. 24 - Send flood protection can't be enabled anymore. It was disabled by default 25 for a good reason for some time already, but some package maintainers 26 turned it back on while it's way too unreliable and trigger-happy to be 27 used. 28 - Removed TODO file, the current to-do list is always in the on-line bug 29 tracking system. 30 - Fixed a potential DoS bug in input handling. 31 32 Finished 4 Dec 2005 24 25 Finished ... 33 26 34 27 Version 0.99: -
doc/FAQ
r22bf64e re7f46c5 46 46 non-ASCII characters! 47 47 A: You probably have to change some settings. To get rid of HTML in messages, 48 see "help set strip_html". If you seem to have problems with your charset, 49 see "help set charset". 50 51 Although actually most of these problems should be gone by now. So if you 52 can't get things to work well, you might have found a bug. 48 see "help set html". If you seem to have problems with your charset, see 49 "help set charset". 53 50 54 51 Q: Is BitlBee forked from Gaim? -
doc/README
r22bf64e re7f46c5 108 108 See utils/bitlbeed.c for more information about the program. 109 109 110 Just a little note: Now that we reach version 1.0, this shouldn't be that 111 much of an issue anymore. However, on a public server, especially if you 112 also use it for other things, it can't hurt to protect yourself against 113 possible problems. 110 Just a little note: We run our public server im.bitlbee.org for a couple of 111 months now, and so far we haven't experienced this problem yet. The only 112 BitlBee processes killed because of CPU-time overuse were running for a long 113 time already, they were usually killed during the MSN login process (which 114 is quite CPU-time consuming). 114 115 115 116 … … 144 145 You can find new releases of BitlBee at: 145 146 http://www.bitlbee.org/ 146 147 The bug tracking system:148 http://bugs.bitlbee.org/149 150 Our version control system is Bazaar-NG. Our repository is at:151 http://code.bitlbee.org/152 147 153 148 … … 192 187 BitlBee - An IRC to other chat networks gateway 193 188 <http://www.bitlbee.org/> 194 Copyright (C) 2002-200 5Wilmer van der Gaast <wilmer@gaast.net>189 Copyright (C) 2002-2004 Wilmer van der Gaast <wilmer@gaast.net> 195 190 and others -
doc/user-guide/user-guide.xml
r22bf64e re7f46c5 24 24 25 25 <releaseinfo> 26 This is the BitlBee User Guide. For now, the on-line help is 27 the most up-to-date documentation. Although this document shares 28 some parts with the on-line help system, other parts might be 29 very outdated. 26 This is the initial release of the BitlBee User Guide. 30 27 </releaseinfo> 31 28 -
irc.c
r22bf64e re7f46c5 31 31 32 32 GSList *irc_connection_list = NULL; 33 34 static char *passchange (irc_t *irc, void *set, char *value)35 {36 irc_setpass (irc, value);37 return (NULL);38 }39 33 40 34 irc_t *irc_new( int fd ) … … 135 129 set_add( irc, "to_char", ": ", set_eval_to_char ); 136 130 set_add( irc, "typing_notice", "false", set_eval_bool ); 137 set_add( irc, "password", NULL, passchange);138 131 139 132 conf_loaddefaults( irc ); … … 161 154 162 155 if( irc->status >= USTATUS_IDENTIFIED && set_getint( irc, "save_on_quit" ) ) 163 if( storage_save( irc, TRUE ) != STORAGE_OK)156 if( !bitlbee_save( irc ) ) 164 157 irc_usermsg( irc, "Error while saving settings!" ); 165 158 … … 266 259 if( global.conf->runmode == RUNMODE_INETD ) 267 260 g_main_quit( global.loop ); 268 }269 270 /* USE WITH CAUTION!271 Sets pass without checking */272 void irc_setpass (irc_t *irc, const char *pass)273 {274 if (irc->password) g_free (irc->password);275 276 if (pass) {277 irc->password = g_strdup (pass);278 irc_usermsg (irc, "Password successfully changed");279 } else {280 irc->password = NULL;281 }282 261 } 283 262 -
irc.h
r22bf64e re7f46c5 137 137 void irc_whois( irc_t *irc, char *nick ); 138 138 int irc_away( irc_t *irc, char *away ); 139 void irc_setpass( irc_t *irc, const char *pass ); /* USE WITH CAUTION! */140 139 141 140 int irc_send( irc_t *irc, char *nick, char *s, int flags ); -
nick.c
r22bf64e re7f46c5 27 27 #include "bitlbee.h" 28 28 29 void nick_set( irc_t *irc, c onst char *handle, int proto, constchar *nick )29 void nick_set( irc_t *irc, char *handle, int proto, char *nick ) 30 30 { 31 31 nick_t *m = NULL, *n = irc->nicks; … … 56 56 } 57 57 58 char *nick_get( irc_t *irc, c onst char *handle, int proto, const char *realname )58 char *nick_get( irc_t *irc, char *handle, int proto, const char *realname ) 59 59 { 60 60 static char nick[MAX_NICK_LENGTH+1]; … … 129 129 } 130 130 131 void nick_del( irc_t *irc, c onst char *nick )131 void nick_del( irc_t *irc, char *nick ) 132 132 { 133 133 nick_t *l = NULL, *n = irc->nicks; … … 176 176 } 177 177 178 int nick_ok( c onst char *nick )179 { 180 c onst char *s;178 int nick_ok( char *nick ) 179 { 180 char *s; 181 181 182 182 /* Empty/long nicks are not allowed */ … … 237 237 } 238 238 239 int nick_cmp( c onst char *a, constchar *b )239 int nick_cmp( char *a, char *b ) 240 240 { 241 241 char aa[1024] = "", bb[1024] = ""; … … 253 253 } 254 254 255 char *nick_dup( const char *nick ) 256 { 257 return g_strndup( nick, MAX_NICK_LENGTH ); 258 } 255 char *nick_dup( char *nick ) 256 { 257 char *cp; 258 259 cp = g_new0 ( char, MAX_NICK_LENGTH + 1 ); 260 strncpy( cp, nick, MAX_NICK_LENGTH ); 261 262 return( cp ); 263 } -
nick.h
r22bf64e re7f46c5 32 32 } nick_t; 33 33 34 void nick_set( irc_t *irc, c onst char *handle, int proto, constchar *nick );35 char *nick_get( irc_t *irc, c onst char *handle, int proto, const char *realname );36 void nick_del( irc_t *irc, c onst char *nick );34 void nick_set( irc_t *irc, char *handle, int proto, char *nick ); 35 char *nick_get( irc_t *irc, char *handle, int proto, const char *realname ); 36 void nick_del( irc_t *irc, char *nick ); 37 37 void nick_strip( char *nick ); 38 38 39 int nick_ok( c onst char *nick );39 int nick_ok( char *nick ); 40 40 int nick_lc( char *nick ); 41 41 int nick_uc( char *nick ); 42 int nick_cmp( c onst char *a, constchar *b );43 char *nick_dup( c onst char *nick );42 int nick_cmp( char *a, char *b ); 43 char *nick_dup( char *nick ); -
protocols/oscar/aim.h
r22bf64e re7f46c5 466 466 int aim_addtlvtochain_caps(aim_tlvlist_t **list, const guint16 t, const guint32 caps); 467 467 int aim_addtlvtochain_noval(aim_tlvlist_t **list, const guint16 type); 468 int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance);469 468 int aim_addtlvtochain_userinfo(aim_tlvlist_t **list, guint16 type, aim_userinfo_t *ui); 470 469 int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, guint16 type, aim_tlvlist_t **tl); … … 573 572 }; 574 573 575 struct aim_chat_invitation {576 struct gaim_connection * gc;577 char * name;578 guint8 exchange;579 };580 574 581 575 #define AIM_VISIBILITYCHANGE_PERMITADD 0x05 -
protocols/oscar/chat.c
r22bf64e re7f46c5 180 180 181 181 aim_tx_enqueue(sess, fr); 182 183 return 0; 184 } 185 186 static int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance) 187 { 188 guint8 *buf; 189 int buflen; 190 aim_bstream_t bs; 191 192 buflen = 2 + 1 + strlen(roomname) + 2; 193 194 if (!(buf = g_malloc(buflen))) 195 return 0; 196 197 aim_bstream_init(&bs, buf, buflen); 198 199 aimbs_put16(&bs, exchange); 200 aimbs_put8(&bs, strlen(roomname)); 201 aimbs_putraw(&bs, (guint8 *)roomname, strlen(roomname)); 202 aimbs_put16(&bs, instance); 203 204 aim_addtlvtochain_raw(list, type, aim_bstream_curpos(&bs), buf); 205 206 g_free(buf); 182 207 183 208 return 0; -
protocols/oscar/im.c
r22bf64e re7f46c5 1369 1369 } 1370 1370 1371 1372 static void incomingim_ch2_chat_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args)1373 {1374 1375 /* XXX aim_chat_roominfo_free() */1376 g_free(args->info.chat.roominfo.name);1377 1378 return;1379 }1380 1381 static void incomingim_ch2_chat(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args, aim_bstream_t *servdata)1382 {1383 1384 /*1385 * Chat room info.1386 */1387 if (servdata)1388 aim_chat_readroominfo(servdata, &args->info.chat.roominfo);1389 1390 args->destructor = (void *)incomingim_ch2_chat_free;1391 1392 return;1393 }1394 1395 1371 static void incomingim_ch2_icqserverrelay_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args) 1396 1372 { … … 1641 1617 if (args.reqclass & AIM_CAPS_ICQSERVERRELAY) 1642 1618 incomingim_ch2_icqserverrelay(sess, mod, rx, snac, userinfo, &args, sdbsptr); 1643 else if (args.reqclass & AIM_CAPS_CHAT)1644 incomingim_ch2_chat(sess, mod, rx, snac, userinfo, &args, sdbsptr);1645 1619 1646 1620 -
protocols/oscar/oscar.c
r22bf64e re7f46c5 62 62 static int gaim_caps = AIM_CAPS_UTF8; */ 63 63 64 static int gaim_caps = AIM_CAPS_INTEROP | AIM_CAPS_ICHAT | AIM_CAPS_ICQSERVERRELAY | AIM_CAPS_CHAT;64 static int gaim_caps = AIM_CAPS_INTEROP | AIM_CAPS_ICHAT | AIM_CAPS_ICQSERVERRELAY; 65 65 static guint8 gaim_features[] = {0x01, 0x01, 0x01, 0x02}; 66 66 … … 156 156 } 157 157 158 #if 0 158 159 static struct chat_connection *find_oscar_chat(struct gaim_connection *gc, int id) { 159 160 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; … … 170 171 return c; 171 172 } 172 173 #endif 173 174 174 175 static struct chat_connection *find_oscar_chat_by_conn(struct gaim_connection *gc, … … 1075 1076 } 1076 1077 1077 void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv);1078 void oscar_reject_chat(gpointer w, struct aim_chat_invitation * inv);1079 1080 1078 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { 1079 #if 0 1081 1080 struct gaim_connection *gc = sess->aux_data; 1081 #endif 1082 1082 1083 1083 if (args->status != AIM_RENDEZVOUS_PROPOSE) 1084 1084 return 1; 1085 1085 #if 0 1086 1086 if (args->reqclass & AIM_CAPS_CHAT) { 1087 1087 char *name = extract_name(args->info.chat.roominfo.name); … … 1091 1091 *exch = args->info.chat.roominfo.exchange; 1092 1092 m = g_list_append(m, exch); 1093 1094 char txt[1024]; 1095 1096 g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", name, userinfo->sn, args->msg ); 1097 1098 struct aim_chat_invitation * inv = g_new0(struct aim_chat_invitation, 1); 1099 1100 inv->gc = gc; 1101 inv->exchange = *exch; 1102 inv->name = g_strdup(name); 1103 1104 do_ask_dialog( gc, txt, inv, oscar_accept_chat, oscar_reject_chat); 1105 1093 serv_got_chat_invite(gc, 1094 name ? name : args->info.chat.roominfo.name, 1095 userinfo->sn, 1096 (char *)args->msg, 1097 m); 1106 1098 if (name) 1107 1099 g_free(name); 1108 1100 } 1109 1101 #endif 1110 1102 return 1; 1111 1103 } … … 2502 2494 } 2503 2495 2504 int oscar_chat_send(struct gaim_connection * gc, int id, char *message)2505 {2506 struct oscar_data * od = (struct oscar_data*)gc->proto_data;2507 struct chat_connection * ccon;2508 2509 if(!(ccon = find_oscar_chat(gc, id)))2510 return -1;2511 2512 int ret;2513 guint8 len = strlen(message);2514 char *s;2515 2516 for (s = message; *s; s++)2517 if (*s & 128)2518 break;2519 2520 /* Message contains high ASCII chars, time for some translation! */2521 if (*s) {2522 s = g_malloc(BUF_LONG);2523 /* Try if we can put it in an ISO8859-1 string first.2524 If we can't, fall back to UTF16. */2525 if ((ret = do_iconv("UTF-8", "ISO8859-1", message, s, len, BUF_LONG)) >= 0) {2526 len = ret;2527 } else if ((ret = do_iconv("UTF-8", "UNICODEBIG", message, s, len, BUF_LONG)) >= 0) {2528 len = ret;2529 } else {2530 /* OOF, translation failed... Oh well.. */2531 g_free( s );2532 s = message;2533 }2534 } else {2535 s = message;2536 }2537 2538 ret = aim_chat_send_im(od->sess, ccon->conn, AIM_CHATFLAGS_NOREFLECT, s, len);2539 2540 if (s != message) {2541 g_free(s);2542 }2543 2544 return (ret >= 0);2545 }2546 2547 void oscar_chat_invite(struct gaim_connection * gc, int id, char *message, char *who)2548 {2549 struct oscar_data * od = (struct oscar_data *)gc->proto_data;2550 struct chat_connection *ccon = find_oscar_chat(gc, id);2551 2552 if (ccon == NULL)2553 return;2554 2555 aim_chat_invite(od->sess, od->conn, who, message ? message : "",2556 ccon->exchange, ccon->name, 0x0);2557 }2558 2559 void oscar_chat_kill(struct gaim_connection *gc, struct chat_connection *cc)2560 {2561 struct oscar_data *od = (struct oscar_data *)gc->proto_data;2562 2563 /* Notify the conversation window that we've left the chat */2564 serv_got_chat_left(gc, cc->id);2565 2566 /* Destroy the chat_connection */2567 od->oscar_chats = g_slist_remove(od->oscar_chats, cc);2568 if (cc->inpa > 0)2569 gaim_input_remove(cc->inpa);2570 aim_conn_kill(od->sess, &cc->conn);2571 g_free(cc->name);2572 g_free(cc->show);2573 g_free(cc);2574 }2575 2576 void oscar_chat_leave(struct gaim_connection * gc, int id)2577 {2578 struct chat_connection * ccon = find_oscar_chat(gc, id);2579 2580 if(ccon == NULL)2581 return;2582 2583 oscar_chat_kill(gc, ccon);2584 }2585 2586 int oscar_chat_join(struct gaim_connection * gc, char * name)2587 {2588 struct oscar_data * od = (struct oscar_data *)gc->proto_data;2589 2590 aim_conn_t * cur;2591 2592 if((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) {2593 2594 return (aim_chatnav_createroom(od->sess, cur, name, 4) == 0);2595 2596 } else {2597 struct create_room * cr = g_new0(struct create_room, 1);2598 cr->exchange = 4;2599 cr->name = g_strdup(name);2600 od->create_rooms = g_slist_append(od->create_rooms, cr);2601 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV);2602 return 1;2603 }2604 }2605 2606 int oscar_chat_open(struct gaim_connection * gc, char *who)2607 {2608 struct oscar_data * od = (struct oscar_data *)gc->proto_data;2609 2610 static int chat_id = 0;2611 char * chatname = g_new0(char, strlen(gc->username)+4);2612 g_snprintf(chatname, strlen(gc->username) + 4, "%s%d", gc->username, chat_id++);2613 2614 int ret = oscar_chat_join(gc, chatname);2615 2616 aim_chat_invite(od->sess, od->conn, who, "", 4, chatname, 0x0);2617 2618 g_free(chatname);2619 2620 return ret;2621 }2622 2623 void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv)2624 {2625 oscar_chat_join(inv->gc, inv->name);2626 g_free(inv->name);2627 g_free(inv);2628 }2629 2630 void oscar_reject_chat(gpointer w, struct aim_chat_invitation * inv)2631 {2632 g_free(inv->name);2633 g_free(inv);2634 }2635 2636 2496 static struct prpl *my_protocol = NULL; 2637 2497 … … 2647 2507 ret->add_buddy = oscar_add_buddy; 2648 2508 ret->remove_buddy = oscar_remove_buddy; 2649 ret->chat_send = oscar_chat_send;2650 ret->chat_invite = oscar_chat_invite;2651 ret->chat_leave = oscar_chat_leave;2652 ret->chat_open = oscar_chat_open;2653 2509 ret->add_permit = oscar_add_permit; 2654 2510 ret->add_deny = oscar_add_deny; -
protocols/oscar/tlv.c
r22bf64e re7f46c5 340 340 } 341 341 342 int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance)343 {344 guint8 *buf;345 int buflen;346 aim_bstream_t bs;347 348 buflen = 2 + 1 + strlen(roomname) + 2;349 350 if (!(buf = g_malloc(buflen)))351 return 0;352 353 aim_bstream_init(&bs, buf, buflen);354 355 aimbs_put16(&bs, exchange);356 aimbs_put8(&bs, strlen(roomname));357 aimbs_putraw(&bs, (guint8 *)roomname, strlen(roomname));358 aimbs_put16(&bs, instance);359 360 aim_addtlvtochain_raw(list, type, aim_bstream_curpos(&bs), buf);361 362 g_free(buf);363 364 return 0;365 }366 367 342 /** 368 343 * aim_writetlvchain - Write a TLV chain into a data buffer. -
protocols/proxy.c
r22bf64e re7f46c5 50 50 #define GAIM_ERR_COND (G_IO_HUP | G_IO_ERR | G_IO_NVAL) 51 51 52 /*FIXME* 53 #ifndef _WIN32 54 if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { 55 closesocket(fd); 56 g_free(phb); 57 return -1; 58 } 59 fcntl(fd, F_SETFL, 0); 60 #endif*/ 61 52 62 char proxyhost[128] = ""; 53 63 int proxyport = 0; … … 73 83 74 84 75 static struct sockaddr_in *gaim_gethostbyname(c onst char *host, int port)85 static struct sockaddr_in *gaim_gethostbyname(char *host, int port) 76 86 { 77 87 static struct sockaddr_in sin; … … 144 154 } 145 155 146 static int proxy_connect_none(c onst char *host, unsigned short port, struct PHB *phb)156 static int proxy_connect_none(char *host, unsigned short port, struct PHB *phb) 147 157 { 148 158 struct sockaddr_in *sin; … … 271 281 } 272 282 273 static int proxy_connect_http(c onst char *host, unsigned short port, struct PHB *phb)283 static int proxy_connect_http(char *host, unsigned short port, struct PHB *phb) 274 284 { 275 285 phb->host = g_strdup(host); … … 355 365 } 356 366 357 static int proxy_connect_socks4(c onst char *host, unsigned short port, struct PHB *phb)367 static int proxy_connect_socks4(char *host, unsigned short port, struct PHB *phb) 358 368 { 359 369 phb->host = g_strdup(host); … … 537 547 } 538 548 539 static int proxy_connect_socks5(c onst char *host, unsigned short port, struct PHB *phb)549 static int proxy_connect_socks5(char *host, unsigned short port, struct PHB *phb) 540 550 { 541 551 phb->host = g_strdup(host); … … 578 588 } 579 589 580 int proxy_connect(c onst char *host, int port, GaimInputFunction func, gpointer data)590 int proxy_connect(char *host, int port, GaimInputFunction func, gpointer data) 581 591 { 582 592 struct PHB *phb; -
protocols/proxy.h
r22bf64e re7f46c5 56 56 G_MODULE_EXPORT void gaim_input_remove(gint); 57 57 58 G_MODULE_EXPORT int proxy_connect(c onst char *host, int port, GaimInputFunction func, gpointer data);58 G_MODULE_EXPORT int proxy_connect(char *host, int port, GaimInputFunction func, gpointer data); 59 59 60 60 #endif /* _PROXY_H_ */ -
unix.c
r22bf64e re7f46c5 52 52 53 53 global.helpfile = g_strdup( HELP_FILE ); 54 54 55 55 global.conf = conf_load( argc, argv ); 56 56 if( global.conf == NULL ) 57 57 return( 1 ); 58 59 58 60 59 if( global.conf->runmode == RUNMODE_INETD ) 61 60 { … … 71 70 if( i != 0 ) 72 71 return( i ); 73 74 global.storage = storage_init( global.conf->primary_storage,75 global.conf->migrate_storage );76 if ( global.storage == NULL) {77 log_message( LOGLVL_ERROR, "Unable to load storage backend '%s'", global.conf->primary_storage );78 return( 1 );79 }80 81 72 82 73 /* Catch some signals to tell the user what's happening before quitting */ … … 96 87 if( !getuid() || !geteuid() ) 97 88 log_message( LOGLVL_WARNING, "BitlBee is running with root privileges. Why?" ); 89 if( access( global.conf->configdir, F_OK ) != 0 ) 90 log_message( LOGLVL_WARNING, "The configuration directory %s does not exist. Configuration won't be saved.", CONFIG ); 91 else if( access( global.conf->configdir, R_OK ) != 0 || access( global.conf->configdir, W_OK ) != 0 ) 92 log_message( LOGLVL_WARNING, "Permission problem: Can't read/write from/to %s.", global.conf->configdir ); 98 93 if( help_init( &(global.help) ) == NULL ) 99 94 log_message( LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE );
Note: See TracChangeset
for help on using the changeset viewer.