Changes in / [22bf64e:e7f46c5]


Ignore:
Files:
3 deleted
27 edited

Legend:

Unmodified
Added
Removed
  • .bzrignore

    r22bf64e re7f46c5  
    88build-arch-stamp
    99tags
    10 decode
    11 encode
  • Makefile

    r22bf64e re7f46c5  
    1010
    1111# 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.o
     12objects = 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
    1313subdirs = protocols
    1414
  • bitlbee.c

    r22bf64e re7f46c5  
    2727#include "bitlbee.h"
    2828#include "commands.h"
     29#include "crypting.h"
    2930#include "protocols/nogaim.h"
    3031#include "help.h"
     
    164165                return FALSE;
    165166        }
    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               
    175168        return TRUE;
    176169}
     
    243236}
    244237
     238int 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
     293int 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
    245456void bitlbee_shutdown( gpointer data )
    246457{
  • bitlbee.h

    r22bf64e re7f46c5  
    3030
    3131#define PACKAGE "BitlBee"
    32 #define BITLBEE_VERSION "BZR"
     32#define BITLBEE_VERSION "1.0pre"
    3333#define VERSION BITLBEE_VERSION
    3434
     
    100100
    101101#include "irc.h"
    102 #include "storage.h"
    103102#include "set.h"
    104103#include "protocols/nogaim.h"
     
    116115        help_t *help;
    117116        conf_t *conf;
    118         GList *storage; /* The first backend in the list will be used for saving */
    119117        char *helpfile;
    120118        GMainLoop *loop;
     
    129127int root_command_string( irc_t *irc, user_t *u, char *command, int flags );
    130128int root_command( irc_t *irc, char *command[] );
     129int bitlbee_load( irc_t *irc, char *password );
     130int bitlbee_save( irc_t *irc );
    131131void bitlbee_shutdown( gpointer data );
    132132double gettime( void );
  • commands.c

    r22bf64e re7f46c5  
    8686int cmd_identify( irc_t *irc, char **cmd )
    8787{
    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        {
    9292                irc_usermsg( irc, "Incorrect password" );
    93                 break;
    94         case STORAGE_NO_SUCH_USER:
     93        }
     94        else if( checkie == 0 )
     95        {
    9596                irc_usermsg( irc, "The nick is (probably) not registered" );
    96                 break;
    97         case STORAGE_OK:
     97        }
     98        else if( checkie == 1 )
     99        {
    98100                irc_usermsg( irc, "Password accepted" );
    99                 break;
    100         default:
     101        }
     102        else
     103        {
    101104                irc_usermsg( irc, "Something very weird happened" );
    102                 break;
    103         }
    104 
     105        }
     106       
    105107        return( 0 );
    106108}
     
    108110int cmd_register( irc_t *irc, char **cmd )
    109111{
     112        int checkie;
     113        char path[512];
     114       
    110115        if( global.conf->authmode == AUTHMODE_REGISTERED )
    111116        {
     
    113118                return( 0 );
    114119        }
    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" );
    129136        }
    130137       
     
    134141int cmd_drop( irc_t *irc, char **cmd )
    135142{
    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        {
    141150                irc_usermsg( irc, "That account does not exist" );
    142151                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 );
    154172}
    155173
     
    616634int cmd_save( irc_t *irc, char **cmd )
    617635{
    618         if( storage_save( irc, TRUE ) == STORAGE_OK )
     636        if( bitlbee_save( irc ) )
    619637                irc_usermsg( irc, "Configuration saved" );
    620638        else
  • conf.c

    r22bf64e re7f46c5  
    5050        conf->nofork = 0;
    5151        conf->verbose = 0;
    52         conf->primary_storage = "text";
    5352        conf->runmode = RUNMODE_INETD;
    5453        conf->authmode = AUTHMODE_OPEN;
     
    199198                                conf->motdfile = g_strdup( ini->value );
    200199                        }
    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                         }
    211200                        else if( g_strcasecmp( ini->key, "pinginterval" ) == 0 )
    212201                        {
  • conf.h

    r22bf64e re7f46c5  
    4242        char *configdir;
    4343        char *motdfile;
    44         char *primary_storage;
    45         char **migrate_storage;
    4644        int ping_interval;
    4745        int ping_timeout;
  • configure

    r22bf64e re7f46c5  
    343343case "$arch" in
    344344Linux )
     345        echo 'Linux.'
    345346;;
    346347GNU/* )
     348        echo 'Debian with non-Linux kernel?'
    347349;;
    348350*BSD )
     351        echo '*BSD.'
    349352        echo 'EFLAGS+=-liconv' >> Makefile.settings;
    350353;;
    351354SunOS )
     355        echo 'Solaris.'
    352356        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
    353357        echo 'STRIP=\# skip strip' >> Makefile.settings
     
    355359;;
    356360Darwin )
     361        echo 'Darwin/Mac OS X.'
    357362        echo 'EFLAGS+=-liconv' >> Makefile.settings;
    358363;;
    359364IRIX )
     365        echo 'IRIX.'
    360366;;
    361367CYGWIN* )
     
    363369;;
    364370* )
    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>.'
    367372;;
    368373esac
  • crypting.c

    r22bf64e re7f46c5  
    2929   the programs will be built. */
    3030
     31#ifndef CRYPTING_MAIN
     32#define BITLBEE_CORE
     33#include "bitlbee.h"
     34#include "irc.h"
    3135#include "md5.h"
    3236#include "crypting.h"
     
    3539#include <stdlib.h>
    3640
     41#else
     42
     43typedef 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
    3761/*\
    3862 * [SH] Do _not_ call this if it's not entirely sure that it will not cause
     
    4165\*/
    4266
    43 int checkpass (const char *pass, const char *md5sum)
    44 {
     67/* USE WITH CAUTION!
     68   Sets pass without checking */
     69void 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
     83char *passchange (irc_t *irc, void *set, char *value) {
     84        setpassnc (irc, value);
     85        return (NULL);
     86}
     87
     88int setpass (irc_t *irc, char *pass, char* md5sum) {
    4589        md5_state_t md5state;
    4690        md5_byte_t digest[16];
     
    59103                if (digits[1] != md5sum[j + 1]) return (-1);
    60104        }
    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
     112char *hashpass (irc_t *irc) {
    68113        md5_state_t md5state;
    69114        md5_byte_t digest[16];
     
    72117        char *rv;
    73118       
    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);
    77123       
    78124        md5_init (&md5state);
    79         md5_append (&md5state, (const unsigned char *)password, strlen (password));
     125        md5_append (&md5state, (unsigned char *)irc->password, strlen (irc->password));
    80126        md5_finish (&md5state, digest);
    81127       
     
    89135}
    90136
    91 char *obfucrypt (char *line, const char *password)
    92 {
     137char *obfucrypt (irc_t *irc, char *line) {
    93138        int i, j;
    94139        char *rv;
    95140       
    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);
    99145       
    100146        i = j = 0;
     
    102148                /* Encrypt/obfuscate the line, using the password */
    103149                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 */
    106153               
    107154                line++;
    108                 if (!password[++i]) i = 0;
     155                if (!irc->password[++i]) i = 0;
    109156                j++;
    110157        }
     
    113160}
    114161
    115 char *deobfucrypt (char *line, const char *password)
    116 {
     162char *deobfucrypt (irc_t *irc, char *line) {
    117163        int i, j;
    118164        char *rv;
    119165       
    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);
    123170       
    124171        i = j = 0;
    125172        while (*line) {
    126173                /* Decrypt/deobfuscate the line, using the pass */
    127                 rv[j] = *line - password[i]; /* Overflow intended */
     174                rv[j] = *line - irc->password[i]; /* Overflow intended */
    128175               
    129176                line++;
    130                 if (!password[++i]) i = 0;
     177                if (!irc->password[++i]) i = 0;
    131178                j++;
    132179        }
     
    142189int main( int argc, char *argv[] )
    143190{
     191        irc_t *irc = g_malloc( sizeof( irc_t ) );
    144192        char *hash, *action, line[256];
    145         char* (*func)( char *, const char * );
     193        char* (*func)( irc_t *, char * );
    146194       
    147195        if( argc < 2 )
     
    153201        }
    154202       
    155         hash = hashpass( argv[1] );
     203        memset( irc, 0, sizeof( irc_t ) );
     204        irc->password = g_strdup( argv[1] );
     205       
     206        hash = hashpass( irc );
    156207        action = argv[0] + strlen( argv[0] ) - strlen( "encode" );
    157208       
     
    185236                fgetc( stdin );
    186237               
    187                 out = func( line, argv[1] );
     238                out = func( irc, line );
    188239                printf( "%s\n", out );
    189240                g_free( out );
  • crypting.h

    r22bf64e re7f46c5  
    2424*/
    2525
    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);
     26void setpassnc (irc_t *irc, char *pass); /* USE WITH CAUTION! */
     27char *passchange (irc_t *irc, void *set, char *value);
     28int setpass (irc_t *irc, char *pass, char* md5sum);
     29char *hashpass (irc_t *irc);
     30char *obfucrypt (irc_t *irc, char *line);
     31char *deobfucrypt (irc_t *irc, char *line);
  • doc/AUTHORS

    r22bf64e re7f46c5  
    44        Main developer
    55
    6 Jelmer 'ctrlsoft' Vernooij <jelmer@samba.org>
     6Jelmer 'ctrlsoft' Vernooij <jelmer@nl.linux.org>
    77        Documentation, general hacking, Win32 port
    88
  • doc/CHANGES

    r22bf64e re7f46c5  
    2222  abusing it as a port scanner. We aren't aware of any Jabber server that
    2323  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
     25Finished ...
    3326
    3427Version 0.99:
  • doc/FAQ

    r22bf64e re7f46c5  
    4646   non-ASCII characters!
    4747A: 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".
    5350
    5451Q: Is BitlBee forked from Gaim?
  • doc/README

    r22bf64e re7f46c5  
    108108See utils/bitlbeed.c for more information about the program.
    109109
    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.
     110Just a little note: We run our public server im.bitlbee.org for a couple of
     111months now, and so far we haven't experienced this problem yet. The only
     112BitlBee processes killed because of CPU-time overuse were running for a long
     113time already, they were usually killed during the MSN login process (which
     114is quite CPU-time consuming).
    114115
    115116
     
    144145You can find new releases of BitlBee at:
    145146http://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/
    152147
    153148
     
    192187        BitlBee - An IRC to other chat networks gateway
    193188                  <http://www.bitlbee.org/>
    194         Copyright (C) 2002-2005  Wilmer van der Gaast <wilmer@gaast.net>
     189        Copyright (C) 2002-2004  Wilmer van der Gaast <wilmer@gaast.net>
    195190                                 and others
  • doc/user-guide/user-guide.xml

    r22bf64e re7f46c5  
    2424
    2525   <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.
    3027   </releaseinfo>
    3128
  • irc.c

    r22bf64e re7f46c5  
    3131
    3232GSList *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 }
    3933
    4034irc_t *irc_new( int fd )
     
    135129        set_add( irc, "to_char", ": ", set_eval_to_char );
    136130        set_add( irc, "typing_notice", "false", set_eval_bool );
    137         set_add( irc, "password", NULL, passchange);
    138131       
    139132        conf_loaddefaults( irc );
     
    161154       
    162155        if( irc->status >= USTATUS_IDENTIFIED && set_getint( irc, "save_on_quit" ) )
    163                 if( storage_save( irc, TRUE ) != STORAGE_OK )
     156                if( !bitlbee_save( irc ) )
    164157                        irc_usermsg( irc, "Error while saving settings!" );
    165158       
     
    266259        if( global.conf->runmode == RUNMODE_INETD )
    267260                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         }
    282261}
    283262
  • irc.h

    r22bf64e re7f46c5  
    137137void irc_whois( irc_t *irc, char *nick );
    138138int irc_away( irc_t *irc, char *away );
    139 void irc_setpass( irc_t *irc, const char *pass ); /* USE WITH CAUTION! */
    140139
    141140int irc_send( irc_t *irc, char *nick, char *s, int flags );
  • nick.c

    r22bf64e re7f46c5  
    2727#include "bitlbee.h"
    2828
    29 void nick_set( irc_t *irc, const char *handle, int proto, const char *nick )
     29void nick_set( irc_t *irc, char *handle, int proto, char *nick )
    3030{
    3131        nick_t *m = NULL, *n = irc->nicks;
     
    5656}
    5757
    58 char *nick_get( irc_t *irc, const char *handle, int proto, const char *realname )
     58char *nick_get( irc_t *irc, char *handle, int proto, const char *realname )
    5959{
    6060        static char nick[MAX_NICK_LENGTH+1];
     
    129129}
    130130
    131 void nick_del( irc_t *irc, const char *nick )
     131void nick_del( irc_t *irc, char *nick )
    132132{
    133133        nick_t *l = NULL, *n = irc->nicks;
     
    176176}
    177177
    178 int nick_ok( const char *nick )
    179 {
    180         const char *s;
     178int nick_ok( char *nick )
     179{
     180        char *s;
    181181       
    182182        /* Empty/long nicks are not allowed */
     
    237237}
    238238
    239 int nick_cmp( const char *a, const char *b )
     239int nick_cmp( char *a, char *b )
    240240{
    241241        char aa[1024] = "", bb[1024] = "";
     
    253253}
    254254
    255 char *nick_dup( const char *nick )
    256 {
    257         return g_strndup( nick, MAX_NICK_LENGTH );
    258 }
     255char *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  
    3232} nick_t;
    3333
    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 );
     34void nick_set( irc_t *irc, char *handle, int proto, char *nick );
     35char *nick_get( irc_t *irc, char *handle, int proto, const char *realname );
     36void nick_del( irc_t *irc, char *nick );
    3737void nick_strip( char *nick );
    3838
    39 int nick_ok( const char *nick );
     39int nick_ok( char *nick );
    4040int nick_lc( char *nick );
    4141int nick_uc( char *nick );
    42 int nick_cmp( const char *a, const char *b );
    43 char *nick_dup( const char *nick );
     42int nick_cmp( char *a, char *b );
     43char *nick_dup( char *nick );
  • protocols/oscar/aim.h

    r22bf64e re7f46c5  
    466466int aim_addtlvtochain_caps(aim_tlvlist_t **list, const guint16 t, const guint32 caps);
    467467int 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);
    469468int aim_addtlvtochain_userinfo(aim_tlvlist_t **list, guint16 type, aim_userinfo_t *ui);
    470469int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, guint16 type, aim_tlvlist_t **tl);
     
    573572};
    574573
    575 struct aim_chat_invitation {
    576         struct gaim_connection * gc;
    577         char * name;
    578         guint8 exchange;
    579 };
    580574
    581575#define AIM_VISIBILITYCHANGE_PERMITADD    0x05
  • protocols/oscar/chat.c

    r22bf64e re7f46c5  
    180180       
    181181        aim_tx_enqueue(sess, fr);
     182
     183        return 0;
     184}
     185
     186static 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);
    182207
    183208        return 0;
  • protocols/oscar/im.c

    r22bf64e re7f46c5  
    13691369}
    13701370
    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 
    13951371static void incomingim_ch2_icqserverrelay_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args)
    13961372{
     
    16411617        if (args.reqclass & AIM_CAPS_ICQSERVERRELAY)
    16421618                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);
    16451619
    16461620
  • protocols/oscar/oscar.c

    r22bf64e re7f46c5  
    6262   static int gaim_caps = AIM_CAPS_UTF8; */
    6363
    64 static int gaim_caps = AIM_CAPS_INTEROP | AIM_CAPS_ICHAT | AIM_CAPS_ICQSERVERRELAY | AIM_CAPS_CHAT;
     64static int gaim_caps = AIM_CAPS_INTEROP | AIM_CAPS_ICHAT | AIM_CAPS_ICQSERVERRELAY;
    6565static guint8 gaim_features[] = {0x01, 0x01, 0x01, 0x02};
    6666
     
    156156}
    157157
     158#if 0
    158159static struct chat_connection *find_oscar_chat(struct gaim_connection *gc, int id) {
    159160        GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats;
     
    170171        return c;
    171172}
    172 
     173#endif
    173174
    174175static struct chat_connection *find_oscar_chat_by_conn(struct gaim_connection *gc,
     
    10751076}
    10761077
    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        
    10801078static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) {
     1079#if 0
    10811080        struct gaim_connection *gc = sess->aux_data;
     1081#endif
    10821082
    10831083        if (args->status != AIM_RENDEZVOUS_PROPOSE)
    10841084                return 1;
    1085 
     1085#if 0
    10861086        if (args->reqclass & AIM_CAPS_CHAT) {
    10871087                char *name = extract_name(args->info.chat.roominfo.name);
     
    10911091                *exch = args->info.chat.roominfo.exchange;
    10921092                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);
    11061098                if (name)
    11071099                        g_free(name);
    11081100        }
    1109 
     1101#endif
    11101102        return 1;
    11111103}
     
    25022494}
    25032495
    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 
    26362496static struct prpl *my_protocol = NULL;
    26372497
     
    26472507        ret->add_buddy = oscar_add_buddy;
    26482508        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;
    26532509        ret->add_permit = oscar_add_permit;
    26542510        ret->add_deny = oscar_add_deny;
  • protocols/oscar/tlv.c

    r22bf64e re7f46c5  
    340340}
    341341
    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 
    367342/**
    368343 * aim_writetlvchain - Write a TLV chain into a data buffer.
  • protocols/proxy.c

    r22bf64e re7f46c5  
    5050#define GAIM_ERR_COND   (G_IO_HUP | G_IO_ERR | G_IO_NVAL)
    5151
     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
    5262char proxyhost[128] = "";
    5363int proxyport = 0;
     
    7383
    7484
    75 static struct sockaddr_in *gaim_gethostbyname(const char *host, int port)
     85static struct sockaddr_in *gaim_gethostbyname(char *host, int port)
    7686{
    7787        static struct sockaddr_in sin;
     
    144154}
    145155
    146 static int proxy_connect_none(const char *host, unsigned short port, struct PHB *phb)
     156static int proxy_connect_none(char *host, unsigned short port, struct PHB *phb)
    147157{
    148158        struct sockaddr_in *sin;
     
    271281}
    272282
    273 static int proxy_connect_http(const char *host, unsigned short port, struct PHB *phb)
     283static int proxy_connect_http(char *host, unsigned short port, struct PHB *phb)
    274284{
    275285        phb->host = g_strdup(host);
     
    355365}
    356366
    357 static int proxy_connect_socks4(const char *host, unsigned short port, struct PHB *phb)
     367static int proxy_connect_socks4(char *host, unsigned short port, struct PHB *phb)
    358368{
    359369        phb->host = g_strdup(host);
     
    537547}
    538548
    539 static int proxy_connect_socks5(const char *host, unsigned short port, struct PHB *phb)
     549static int proxy_connect_socks5(char *host, unsigned short port, struct PHB *phb)
    540550{
    541551        phb->host = g_strdup(host);
     
    578588}
    579589
    580 int proxy_connect(const char *host, int port, GaimInputFunction func, gpointer data)
     590int proxy_connect(char *host, int port, GaimInputFunction func, gpointer data)
    581591{
    582592        struct PHB *phb;
  • protocols/proxy.h

    r22bf64e re7f46c5  
    5656G_MODULE_EXPORT void gaim_input_remove(gint);
    5757
    58 G_MODULE_EXPORT int proxy_connect(const char *host, int port, GaimInputFunction func, gpointer data);
     58G_MODULE_EXPORT int proxy_connect(char *host, int port, GaimInputFunction func, gpointer data);
    5959
    6060#endif /* _PROXY_H_ */
  • unix.c

    r22bf64e re7f46c5  
    5252       
    5353        global.helpfile = g_strdup( HELP_FILE );
    54 
     54       
    5555        global.conf = conf_load( argc, argv );
    5656        if( global.conf == NULL )
    5757                return( 1 );
    58 
    59 
     58       
    6059        if( global.conf->runmode == RUNMODE_INETD )
    6160        {
     
    7170        if( i != 0 )
    7271                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        
    8172       
    8273        /* Catch some signals to tell the user what's happening before quitting */
     
    9687        if( !getuid() || !geteuid() )
    9788                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 );
    9893        if( help_init( &(global.help) ) == NULL )
    9994                log_message( LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE );
Note: See TracChangeset for help on using the changeset viewer.