Changes in / [e7f46c5:22bf64e]
- Files:
-
- 3 added
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
.bzrignore
re7f46c5 r22bf64e 8 8 build-arch-stamp 9 9 tags 10 decode 11 encode -
Makefile
re7f46c5 r22bf64e 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 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.o 13 13 subdirs = protocols 14 14 -
bitlbee.c
re7f46c5 r22bf64e 27 27 #include "bitlbee.h" 28 28 #include "commands.h" 29 #include "crypting.h"30 29 #include "protocols/nogaim.h" 31 30 #include "help.h" … … 165 164 return FALSE; 166 165 } 167 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 168 175 return TRUE; 169 176 } … … 236 243 } 237 244 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, the262 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 the307 * password is not set if it was wrong, or if one is not identified308 * yet. This means that a malicious user could easily overwrite309 * files owned by someone else:310 * a Bad Thing, methinks311 \*/312 313 /* [WVG] No? Really? */314 315 /*\316 * [SH] Okay, okay, it wasn't really Wilmer who said that, it was317 * 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 else380 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 456 245 void bitlbee_shutdown( gpointer data ) 457 246 { -
bitlbee.h
re7f46c5 r22bf64e 30 30 31 31 #define PACKAGE "BitlBee" 32 #define BITLBEE_VERSION " 1.0pre"32 #define BITLBEE_VERSION "BZR" 33 33 #define VERSION BITLBEE_VERSION 34 34 … … 100 100 101 101 #include "irc.h" 102 #include "storage.h" 102 103 #include "set.h" 103 104 #include "protocols/nogaim.h" … … 115 116 help_t *help; 116 117 conf_t *conf; 118 GList *storage; /* The first backend in the list will be used for saving */ 117 119 char *helpfile; 118 120 GMainLoop *loop; … … 127 129 int root_command_string( irc_t *irc, user_t *u, char *command, int flags ); 128 130 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
re7f46c5 r22bf64e 86 86 int cmd_identify( irc_t *irc, char **cmd ) 87 87 { 88 int checkie = bitlbee_load( irc, cmd[1]);89 90 if( checkie == -1 )91 {88 storage_status_t status = storage_load( irc->nick, cmd[1], irc ); 89 90 switch (status) { 91 case STORAGE_INVALID_PASSWORD: 92 92 irc_usermsg( irc, "Incorrect password" ); 93 } 94 else if( checkie == 0 ) 95 { 93 break; 94 case STORAGE_NO_SUCH_USER: 96 95 irc_usermsg( irc, "The nick is (probably) not registered" ); 97 } 98 else if( checkie == 1 ) 99 { 96 break; 97 case STORAGE_OK: 100 98 irc_usermsg( irc, "Password accepted" ); 101 } 102 else 103 { 99 break; 100 default: 104 101 irc_usermsg( irc, "Something very weird happened" ); 105 } 106 102 break; 103 } 104 107 105 return( 0 ); 108 106 } … … 110 108 int cmd_register( irc_t *irc, char **cmd ) 111 109 { 112 int checkie;113 char path[512];114 115 110 if( global.conf->authmode == AUTHMODE_REGISTERED ) 116 111 { … … 118 113 return( 0 ); 119 114 } 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" ); 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; 136 129 } 137 130 … … 141 134 int cmd_drop( irc_t *irc, char **cmd ) 142 135 { 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 { 136 storage_status_t status; 137 138 status = storage_remove (irc->nick, cmd[1]); 139 switch (status) { 140 case STORAGE_NO_SUCH_USER: 150 141 irc_usermsg( irc, "That account does not exist" ); 151 142 return( 0 ); 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 ); 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 } 172 154 } 173 155 … … 634 616 int cmd_save( irc_t *irc, char **cmd ) 635 617 { 636 if( bitlbee_save( irc ))618 if( storage_save( irc, TRUE ) == STORAGE_OK ) 637 619 irc_usermsg( irc, "Configuration saved" ); 638 620 else -
conf.c
re7f46c5 r22bf64e 50 50 conf->nofork = 0; 51 51 conf->verbose = 0; 52 conf->primary_storage = "text"; 52 53 conf->runmode = RUNMODE_INETD; 53 54 conf->authmode = AUTHMODE_OPEN; … … 198 199 conf->motdfile = g_strdup( ini->value ); 199 200 } 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 } 200 211 else if( g_strcasecmp( ini->key, "pinginterval" ) == 0 ) 201 212 { -
conf.h
re7f46c5 r22bf64e 42 42 char *configdir; 43 43 char *motdfile; 44 char *primary_storage; 45 char **migrate_storage; 44 46 int ping_interval; 45 47 int ping_timeout; -
configure
re7f46c5 r22bf64e 343 343 case "$arch" in 344 344 Linux ) 345 echo 'Linux.'346 345 ;; 347 346 GNU/* ) 348 echo 'Debian with non-Linux kernel?'349 347 ;; 350 348 *BSD ) 351 echo '*BSD.'352 349 echo 'EFLAGS+=-liconv' >> Makefile.settings; 353 350 ;; 354 351 SunOS ) 355 echo 'Solaris.'356 352 echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings 357 353 echo 'STRIP=\# skip strip' >> Makefile.settings … … 359 355 ;; 360 356 Darwin ) 361 echo 'Darwin/Mac OS X.'362 357 echo 'EFLAGS+=-liconv' >> Makefile.settings; 363 358 ;; 364 359 IRIX ) 365 echo 'IRIX.'366 360 ;; 367 361 CYGWIN* ) … … 369 363 ;; 370 364 * ) 371 echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV. Please report any problems to <wilmer@gaast.net>.' 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/.' 372 367 ;; 373 368 esac -
crypting.c
re7f46c5 r22bf64e 29 29 the programs will be built. */ 30 30 31 #ifndef CRYPTING_MAIN32 #define BITLBEE_CORE33 #include "bitlbee.h"34 #include "irc.h"35 31 #include "md5.h" 36 32 #include "crypting.h" … … 38 34 #include <stdio.h> 39 35 #include <stdlib.h> 40 41 #else42 43 typedef struct irc44 {45 char *password;46 } irc_t;47 48 #define set_add( a, b, c, d )49 #define set_find( a, b ) NULL50 51 #include "md5.h"52 #include "crypting.h"53 #include <string.h>54 #include <stdio.h>55 #include <stdlib.h>56 57 #define irc_usermsg58 59 #endif60 36 61 37 /*\ … … 65 41 \*/ 66 42 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) { 43 int checkpass (const char *pass, const char *md5sum) 44 { 89 45 md5_state_t md5state; 90 46 md5_byte_t digest[16]; … … 103 59 if (digits[1] != md5sum[j + 1]) return (-1); 104 60 } 105 106 /* If pass is correct, we end up here and we set the pass */ 107 setpassnc (irc, pass); 108 109 return (0); 61 62 return( 0 ); 110 63 } 111 64 112 char *hashpass (irc_t *irc) { 65 66 char *hashpass (const char *password) 67 { 113 68 md5_state_t md5state; 114 69 md5_byte_t digest[16]; … … 117 72 char *rv; 118 73 119 if ( irc->password == NULL) return (NULL);74 if (password == NULL) return (NULL); 120 75 121 rv = (char *)g_malloc (33); 122 memset (rv, 0, 33); 76 rv = g_new0 (char, 33); 123 77 124 78 md5_init (&md5state); 125 md5_append (&md5state, ( unsigned char *)irc->password, strlen (irc->password));79 md5_append (&md5state, (const unsigned char *)password, strlen (password)); 126 80 md5_finish (&md5state, digest); 127 81 … … 135 89 } 136 90 137 char *obfucrypt (irc_t *irc, char *line) { 91 char *obfucrypt (char *line, const char *password) 92 { 138 93 int i, j; 139 94 char *rv; 140 95 141 if ( irc->password == NULL) return (NULL);96 if (password == NULL) return (NULL); 142 97 143 rv = (char *)g_malloc (strlen (line) + 1); 144 memset (rv, '\0', strlen (line) + 1); 98 rv = g_new0 (char, strlen (line) + 1); 145 99 146 100 i = j = 0; … … 148 102 /* Encrypt/obfuscate the line, using the password */ 149 103 if (*(signed char*)line < 0) *line = - (*line); 150 if (((signed char*)irc->password)[i] < 0) irc->password[i] = - irc->password[i];151 104 152 rv[j] = *line + irc->password[i]; /* Overflow intended */105 rv[j] = *line + password[i]; /* Overflow intended */ 153 106 154 107 line++; 155 if (! irc->password[++i]) i = 0;108 if (!password[++i]) i = 0; 156 109 j++; 157 110 } … … 160 113 } 161 114 162 char *deobfucrypt (irc_t *irc, char *line) { 115 char *deobfucrypt (char *line, const char *password) 116 { 163 117 int i, j; 164 118 char *rv; 165 119 166 if ( irc->password == NULL) return (NULL);120 if (password == NULL) return (NULL); 167 121 168 rv = (char *)g_malloc (strlen (line) + 1); 169 memset (rv, '\0', strlen (line) + 1); 122 rv = g_new0 (char, strlen (line) + 1); 170 123 171 124 i = j = 0; 172 125 while (*line) { 173 126 /* Decrypt/deobfuscate the line, using the pass */ 174 rv[j] = *line - irc->password[i]; /* Overflow intended */127 rv[j] = *line - password[i]; /* Overflow intended */ 175 128 176 129 line++; 177 if (! irc->password[++i]) i = 0;130 if (!password[++i]) i = 0; 178 131 j++; 179 132 } … … 189 142 int main( int argc, char *argv[] ) 190 143 { 191 irc_t *irc = g_malloc( sizeof( irc_t ) );192 144 char *hash, *action, line[256]; 193 char* (*func)( irc_t *,char * );145 char* (*func)( char *, const char * ); 194 146 195 147 if( argc < 2 ) … … 201 153 } 202 154 203 memset( irc, 0, sizeof( irc_t ) ); 204 irc->password = g_strdup( argv[1] ); 205 206 hash = hashpass( irc ); 155 hash = hashpass( argv[1] ); 207 156 action = argv[0] + strlen( argv[0] ) - strlen( "encode" ); 208 157 … … 236 185 fgetc( stdin ); 237 186 238 out = func( irc, line);187 out = func( line, argv[1] ); 239 188 printf( "%s\n", out ); 240 189 g_free( out ); -
crypting.h
re7f46c5 r22bf64e 24 24 */ 25 25 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); 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); -
doc/AUTHORS
re7f46c5 r22bf64e 4 4 Main developer 5 5 6 Jelmer 'ctrlsoft' Vernooij <jelmer@ nl.linux.org>6 Jelmer 'ctrlsoft' Vernooij <jelmer@samba.org> 7 7 Documentation, general hacking, Win32 port 8 8 -
doc/CHANGES
re7f46c5 r22bf64e 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 25 Finished ... 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 26 33 27 34 Version 0.99: -
doc/FAQ
re7f46c5 r22bf64e 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 html". If you seem to have problems with your charset, see 49 "help set charset". 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. 50 53 51 54 Q: Is BitlBee forked from Gaim? -
doc/README
re7f46c5 r22bf64e 108 108 See utils/bitlbeed.c for more information about the program. 109 109 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). 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. 115 114 116 115 … … 145 144 You can find new releases of BitlBee at: 146 145 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/ 147 152 148 153 … … 187 192 BitlBee - An IRC to other chat networks gateway 188 193 <http://www.bitlbee.org/> 189 Copyright (C) 2002-200 4Wilmer van der Gaast <wilmer@gaast.net>194 Copyright (C) 2002-2005 Wilmer van der Gaast <wilmer@gaast.net> 190 195 and others -
doc/user-guide/user-guide.xml
re7f46c5 r22bf64e 24 24 25 25 <releaseinfo> 26 This is the initial release of the BitlBee User Guide. 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. 27 30 </releaseinfo> 28 31 -
irc.c
re7f46c5 r22bf64e 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 } 33 39 34 40 irc_t *irc_new( int fd ) … … 129 135 set_add( irc, "to_char", ": ", set_eval_to_char ); 130 136 set_add( irc, "typing_notice", "false", set_eval_bool ); 137 set_add( irc, "password", NULL, passchange); 131 138 132 139 conf_loaddefaults( irc ); … … 154 161 155 162 if( irc->status >= USTATUS_IDENTIFIED && set_getint( irc, "save_on_quit" ) ) 156 if( !bitlbee_save( irc ))163 if( storage_save( irc, TRUE ) != STORAGE_OK ) 157 164 irc_usermsg( irc, "Error while saving settings!" ); 158 165 … … 259 266 if( global.conf->runmode == RUNMODE_INETD ) 260 267 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 } 261 282 } 262 283 -
irc.h
re7f46c5 r22bf64e 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! */ 139 140 140 141 int irc_send( irc_t *irc, char *nick, char *s, int flags ); -
nick.c
re7f46c5 r22bf64e 27 27 #include "bitlbee.h" 28 28 29 void nick_set( irc_t *irc, c har *handle, int proto,char *nick )29 void nick_set( irc_t *irc, const char *handle, int proto, const 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 har *handle, int proto, const char *realname )58 char *nick_get( irc_t *irc, const 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 har *nick )131 void nick_del( irc_t *irc, const char *nick ) 132 132 { 133 133 nick_t *l = NULL, *n = irc->nicks; … … 176 176 } 177 177 178 int nick_ok( c har *nick )179 { 180 c har *s;178 int nick_ok( const char *nick ) 179 { 180 const char *s; 181 181 182 182 /* Empty/long nicks are not allowed */ … … 237 237 } 238 238 239 int nick_cmp( c har *a,char *b )239 int nick_cmp( const char *a, const char *b ) 240 240 { 241 241 char aa[1024] = "", bb[1024] = ""; … … 253 253 } 254 254 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 } 255 char *nick_dup( const char *nick ) 256 { 257 return g_strndup( nick, MAX_NICK_LENGTH ); 258 } -
nick.h
re7f46c5 r22bf64e 32 32 } nick_t; 33 33 34 void nick_set( irc_t *irc, c har *handle, int proto,char *nick );35 char *nick_get( irc_t *irc, c har *handle, int proto, const char *realname );36 void nick_del( irc_t *irc, c har *nick );34 void nick_set( irc_t *irc, const char *handle, int proto, const char *nick ); 35 char *nick_get( irc_t *irc, const char *handle, int proto, const char *realname ); 36 void nick_del( irc_t *irc, const char *nick ); 37 37 void nick_strip( char *nick ); 38 38 39 int nick_ok( c har *nick );39 int nick_ok( const char *nick ); 40 40 int nick_lc( char *nick ); 41 41 int nick_uc( char *nick ); 42 int nick_cmp( c har *a,char *b );43 char *nick_dup( c har *nick );42 int nick_cmp( const char *a, const char *b ); 43 char *nick_dup( const char *nick ); -
protocols/oscar/aim.h
re7f46c5 r22bf64e 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); 468 469 int aim_addtlvtochain_userinfo(aim_tlvlist_t **list, guint16 type, aim_userinfo_t *ui); 469 470 int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, guint16 type, aim_tlvlist_t **tl); … … 572 573 }; 573 574 575 struct aim_chat_invitation { 576 struct gaim_connection * gc; 577 char * name; 578 guint8 exchange; 579 }; 574 580 575 581 #define AIM_VISIBILITYCHANGE_PERMITADD 0x05 -
protocols/oscar/chat.c
re7f46c5 r22bf64e 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);207 182 208 183 return 0; -
protocols/oscar/im.c
re7f46c5 r22bf64e 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 1371 1395 static void incomingim_ch2_icqserverrelay_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args) 1372 1396 { … … 1617 1641 if (args.reqclass & AIM_CAPS_ICQSERVERRELAY) 1618 1642 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); 1619 1645 1620 1646 -
protocols/oscar/oscar.c
re7f46c5 r22bf64e 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 ;64 static int gaim_caps = AIM_CAPS_INTEROP | AIM_CAPS_ICHAT | AIM_CAPS_ICQSERVERRELAY | AIM_CAPS_CHAT; 65 65 static guint8 gaim_features[] = {0x01, 0x01, 0x01, 0x02}; 66 66 … … 156 156 } 157 157 158 #if 0159 158 static struct chat_connection *find_oscar_chat(struct gaim_connection *gc, int id) { 160 159 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; … … 171 170 return c; 172 171 } 173 #endif 172 174 173 175 174 static struct chat_connection *find_oscar_chat_by_conn(struct gaim_connection *gc, … … 1076 1075 } 1077 1076 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 1078 1080 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { 1079 #if 01080 1081 struct gaim_connection *gc = sess->aux_data; 1081 #endif1082 1082 1083 1083 if (args->status != AIM_RENDEZVOUS_PROPOSE) 1084 1084 return 1; 1085 #if 0 1085 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 serv_got_chat_invite(gc, 1094 name ? name : args->info.chat.roominfo.name, 1095 userinfo->sn, 1096 (char *)args->msg, 1097 m); 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 1098 1106 if (name) 1099 1107 g_free(name); 1100 1108 } 1101 #endif 1109 1102 1110 return 1; 1103 1111 } … … 2494 2502 } 2495 2503 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 2496 2636 static struct prpl *my_protocol = NULL; 2497 2637 … … 2507 2647 ret->add_buddy = oscar_add_buddy; 2508 2648 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; 2509 2653 ret->add_permit = oscar_add_permit; 2510 2654 ret->add_deny = oscar_add_deny; -
protocols/oscar/tlv.c
re7f46c5 r22bf64e 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 342 367 /** 343 368 * aim_writetlvchain - Write a TLV chain into a data buffer. -
protocols/proxy.c
re7f46c5 r22bf64e 50 50 #define GAIM_ERR_COND (G_IO_HUP | G_IO_ERR | G_IO_NVAL) 51 51 52 /*FIXME*53 #ifndef _WIN3254 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 62 52 char proxyhost[128] = ""; 63 53 int proxyport = 0; … … 83 73 84 74 85 static struct sockaddr_in *gaim_gethostbyname(c har *host, int port)75 static struct sockaddr_in *gaim_gethostbyname(const char *host, int port) 86 76 { 87 77 static struct sockaddr_in sin; … … 154 144 } 155 145 156 static int proxy_connect_none(c har *host, unsigned short port, struct PHB *phb)146 static int proxy_connect_none(const char *host, unsigned short port, struct PHB *phb) 157 147 { 158 148 struct sockaddr_in *sin; … … 281 271 } 282 272 283 static int proxy_connect_http(c har *host, unsigned short port, struct PHB *phb)273 static int proxy_connect_http(const char *host, unsigned short port, struct PHB *phb) 284 274 { 285 275 phb->host = g_strdup(host); … … 365 355 } 366 356 367 static int proxy_connect_socks4(c har *host, unsigned short port, struct PHB *phb)357 static int proxy_connect_socks4(const char *host, unsigned short port, struct PHB *phb) 368 358 { 369 359 phb->host = g_strdup(host); … … 547 537 } 548 538 549 static int proxy_connect_socks5(c har *host, unsigned short port, struct PHB *phb)539 static int proxy_connect_socks5(const char *host, unsigned short port, struct PHB *phb) 550 540 { 551 541 phb->host = g_strdup(host); … … 588 578 } 589 579 590 int proxy_connect(c har *host, int port, GaimInputFunction func, gpointer data)580 int proxy_connect(const char *host, int port, GaimInputFunction func, gpointer data) 591 581 { 592 582 struct PHB *phb; -
protocols/proxy.h
re7f46c5 r22bf64e 56 56 G_MODULE_EXPORT void gaim_input_remove(gint); 57 57 58 G_MODULE_EXPORT int proxy_connect(c har *host, int port, GaimInputFunction func, gpointer data);58 G_MODULE_EXPORT int proxy_connect(const char *host, int port, GaimInputFunction func, gpointer data); 59 59 60 60 #endif /* _PROXY_H_ */ -
unix.c
re7f46c5 r22bf64e 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 58 59 59 60 if( global.conf->runmode == RUNMODE_INETD ) 60 61 { … … 70 71 if( i != 0 ) 71 72 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 72 81 73 82 /* Catch some signals to tell the user what's happening before quitting */ … … 87 96 if( !getuid() || !geteuid() ) 88 97 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 );93 98 if( help_init( &(global.help) ) == NULL ) 94 99 log_message( LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE );
Note: See TracChangeset
for help on using the changeset viewer.