Changes in / [ca60550:4eb4c0f]
- Files:
-
- 3 added
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
rca60550 r4eb4c0f 10 10 11 11 # Program variables 12 objects = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o $(STORAGE_OBJS) unix.o user.o13 headers = account.h bitlbee.h commands.h conf.h config.h crypting.h help.h ipc.h irc.h log.h nick.h query.h set.h sock.h storage.h user.h lib/events.h lib/http_client.h lib/ini.h lib/md5.h lib/misc.h lib/proxy.h lib/sha1.h lib/ssl_client.h lib/url.h protocols/nogaim.h12 objects = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o otr.o query.o root_commands.o set.o storage.o $(STORAGE_OBJS) unix.o user.o 13 headers = account.h bitlbee.h commands.h conf.h config.h crypting.h help.h ipc.h irc.h log.h nick.h otr.h query.h set.h sock.h storage.h user.h lib/events.h lib/http_client.h lib/ini.h lib/md5.h lib/misc.h lib/proxy.h lib/sha1.h lib/ssl_client.h lib/url.h protocols/nogaim.h 14 14 subdirs = lib protocols 15 15 … … 84 84 mkdir -p $(DESTDIR)$(ETCDIR) 85 85 install -m 0644 motd.txt $(DESTDIR)$(ETCDIR)/motd.txt 86 install -m 0644 welcome.txt $(DESTDIR)$(ETCDIR)/welcome.txt 86 87 install -m 0644 bitlbee.conf $(DESTDIR)$(ETCDIR)/bitlbee.conf 87 88 88 89 uninstall-etc: 89 90 rm -f $(DESTDIR)$(ETCDIR)/motd.txt 91 rm -f $(DESTDIR)$(ETCDIR)/welcome.txt 90 92 rm -f $(DESTDIR)$(ETCDIR)/bitlbee.conf 91 93 -rmdir $(DESTDIR)$(ETCDIR) -
bitlbee.c
rca60550 r4eb4c0f 143 143 log_link( LOGLVL_ERROR, LOGOUTPUT_IRC ); 144 144 log_link( LOGLVL_WARNING, LOGOUTPUT_IRC ); 145 /* TODO: Remove debugging log_link's */ 146 log_link( LOGLVL_INFO, LOGOUTPUT_IRC ); 147 log_link( LOGLVL_DEBUG, LOGOUTPUT_IRC ); 145 148 146 149 return( 0 ); -
bitlbee.conf
rca60550 r4eb4c0f 73 73 # MotdFile = /etc/bitlbee/motd.txt 74 74 75 ## WelcomeFile 76 ## 77 ## Specify an alternative file for the welcome message displayed when joining the 78 ## control channel. Default value depends on the --etcdir argument to configure. 79 ## 80 # WelcomeFile = /etc/bitlbee/welcome.txt 81 75 82 ## ConfigDir 76 83 ## -
bitlbee.h
rca60550 r4eb4c0f 137 137 #include "misc.h" 138 138 #include "proxy.h" 139 #include "otr.h" 139 140 140 141 typedef struct global { … … 148 149 char *helpfile; 149 150 int restart; 151 OtrlMessageAppOps otr_ops; /* collects interface functions required by OTR */ 150 152 } global_t; 151 153 -
conf.c
rca60550 r4eb4c0f 59 59 conf->pidfile = g_strdup( PIDFILE ); 60 60 conf->motdfile = g_strdup( ETCDIR "/motd.txt" ); 61 conf->welcomefile = g_strdup( ETCDIR "/welcome.txt" ); 61 62 conf->ping_interval = 180; 62 63 conf->ping_timeout = 300; … … 243 244 g_free( conf->motdfile ); 244 245 conf->motdfile = g_strdup( ini->value ); 246 } 247 else if( g_strcasecmp( ini->key, "welcomefile" ) == 0 ) 248 { 249 g_free( conf->welcomefile ); 250 conf->welcomefile = g_strdup( ini->value ); 245 251 } 246 252 else if( g_strcasecmp( ini->key, "account_storage" ) == 0 ) -
conf.h
rca60550 r4eb4c0f 45 45 char *pidfile; 46 46 char *motdfile; 47 char *welcomefile; 47 48 char *primary_storage; 48 49 char **migrate_storage; -
configure
rca60550 r4eb4c0f 30 30 gcov=0 31 31 plugins=1 32 otr=auto 32 33 33 34 events=glib … … 70 71 --gcov=0/1 Disable/enable test coverage reporting $gcov 71 72 --plugins=0/1 Disable/enable plugins support $plugins 73 --otr=0/1/auto Disable/enable OTR encryption support $otr 72 74 73 75 --events=... Event handler (glib, libevent) $events … … 174 176 if $PKG_CONFIG glib-2.0 --atleast-version=$GLIB_MIN_VERSION; then 175 177 cat<<EOF>>Makefile.settings 176 EFLAGS+=`$PKG_CONFIG --libs glib-2.0 gmodule-2.0 `177 CFLAGS+=`$PKG_CONFIG --cflags glib-2.0 gmodule-2.0 `178 EFLAGS+=`$PKG_CONFIG --libs glib-2.0 gmodule-2.0 gthread-2.0` 179 CFLAGS+=`$PKG_CONFIG --cflags glib-2.0 gmodule-2.0 gthread-2.0` 178 180 EOF 179 181 else … … 385 387 fi 386 388 389 if [ "$otr" = "auto" ]; then 390 for i in /lib /usr/lib /usr/local/lib; do 391 if [ -f $i/libotr.a ]; then 392 otr=1 393 break 394 fi 395 done 396 fi 397 if [ "$otr" = 0 ]; then 398 echo '#undef WITH_OTR' >> config.h 399 else 400 echo '#define WITH_OTR' >> config.h 401 echo "EFLAGS+=-lotr" >> Makefile.settings 402 fi 403 387 404 echo 388 405 if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then … … 504 521 fi 505 522 523 if [ "$otr" = "1" ]; then 524 echo ' Off-the-Record (OTR) Messaging enabled.' 525 else 526 echo ' Off-the-Record (OTR) Messaging disabled.' 527 fi 528 506 529 echo ' Using event handler: '$events 507 530 echo ' Using SSL library: '$ssl -
doc/README
rca60550 r4eb4c0f 49 49 platform. Any recent version of GLib (2.4 or higher) will work. 50 50 51 Off-the-Record encryption support will be included by default if the 52 configure script finds libotr in one of the usual places. You can pass 53 --otr=1 or --otr=0 to force it on or off, respectively. 54 51 55 These days, MSN Messenger clients have to connect to the MS Passport servers 52 56 through HTTPS. BitlBee can use several SSL libraries for this: GnuTLS, NSS … … 152 156 153 157 154 A NOTE ON ENCRYPTION155 ==================== 158 A NOTE ON PASSWORD ENCRYPTION 159 ============================= 156 160 157 161 There used to be a note here about the simple obfuscation method used to -
doc/user-guide/commands.xml
rca60550 r4eb4c0f 244 244 </description> 245 245 </bitlbee-command> 246 247 <bitlbee-command name="otr"> 248 <short-description>Off-the-Record encryption control</short-description> 249 <syntax>otr <subcommand> [<arguments>]</syntax> 250 251 <description> 252 253 <para> 254 Available subcommands: connect, disconnect, smp, trust, info, keygen, and forget. See <emphasis>help otr <subcommand></emphasis> for more information. 255 </para> 256 257 </description> 258 259 <bitlbee-command name="connect"> 260 <syntax>otr connect <nick></syntax> 261 262 <description> 263 264 <para> 265 Attempts to establish an encrypted connection with the specified user by sending a magic string. 266 </para> 267 268 </description> 269 270 </bitlbee-command> 271 272 <bitlbee-command name="disconnect"> 273 <syntax>otr disconnect <nick></syntax> 274 275 <description> 276 277 <para> 278 Resets the connection with the specified user to cleartext. 279 </para> 280 281 </description> 282 283 </bitlbee-command> 284 285 <bitlbee-command name="smp"> 286 <syntax>otr smp <nick> <secret></syntax> 287 288 <description> 289 290 <para> 291 Attempts to authenticate the given user's active fingerprint via the Socialist Millionaires' Protocol. 292 </para> 293 294 <para> 295 If an SMP challenge has already been received from the given user, responds with the specified secret. Otherwise, a challenge for the secret will be sent. If the protocol succeeds (i.e. both parties gave the same secret), the fingerprint will be trusted. 296 </para> 297 298 </description> 299 300 </bitlbee-command> 301 302 <bitlbee-command name="trust"> 303 <syntax>otr trust <nick> <fp1> <fp2> <fp3> <fp4> <fp5></syntax> 304 305 <description> 306 307 <para> 308 Manually affirms trust in the specified fingerprint, given as five blocks of precisely eight (hexadecimal) digits each. 309 </para> 310 311 </description> 312 313 </bitlbee-command> 314 315 <bitlbee-command name="info"> 316 <syntax>otr info</syntax> 317 <syntax>otr info <nick></syntax> 318 319 <description> 320 321 <para> 322 Shows information about the OTR state. The first form lists our private keys and current OTR contexts. The second form displays information about the connection with a given user, including the list of their known fingerprints. 323 </para> 324 325 </description> 326 327 </bitlbee-command> 328 329 <bitlbee-command name="keygen"> 330 <syntax>otr keygen <account-no></syntax> 331 332 <description> 333 334 <para> 335 Generates a new OTR private key for the given account. 336 </para> 337 338 </description> 339 340 </bitlbee-command> 341 342 <bitlbee-command name="forget"> 343 <syntax>otr forget <thing> <arguments></syntax> 344 345 <description> 346 347 <para> 348 Forgets some part of our OTR userstate. Available things: fingerprint and context. See <emphasis>help otr forget <thing></emphasis> for more information. 349 </para> 350 351 </description> 352 353 <bitlbee-command name="fingerprint"> 354 <syntax>otr forget fingerprint <nick> <fingerprint></syntax> 355 356 <description> 357 358 <para> 359 Drops the specified fingerprint from the given user's OTR connection context. It is allowed to specify only a (unique) prefix of the desired fingerprint. 360 </para> 361 362 </description> 363 364 </bitlbee-command> 365 366 <bitlbee-command name="context"> 367 <syntax>otr forget context <nick></syntax> 368 369 <description> 370 371 <para> 372 Forgets the entire OTR context associated with the given user. This includes current message and protocol states, as well as any fingerprints for that user. 373 </para> 374 375 </description> 376 377 </bitlbee-command> 378 379 </bitlbee-command> 380 381 </bitlbee-command> 246 382 247 383 <bitlbee-command name="set"> … … 398 534 </bitlbee-setting> 399 535 536 <bitlbee-setting name="color_encrypted" type="boolean" scope="global"> 537 <default>true</default> 538 539 <description> 540 <para> 541 If set to true, BitlBee will color incoming encrypted messages according to their fingerprint trust level: untrusted=red, trusted=green. 542 </para> 543 </description> 544 545 </bitlbee-setting> 546 400 547 <bitlbee-setting name="debug" type="boolean" scope="global"> 401 548 <default>false</default> … … 464 611 </bitlbee-setting> 465 612 613 <bitlbee-setting name="halfop_buddies" type="string" scope="global"> 614 <default>encrypted</default> 615 <possible-values>encrypted, trusted, notaway, false</possible-values> 616 617 <description> 618 <para> 619 Specifies under which circumstances BitlBee should give the "halfop" mode flag (+h) to buddies. 620 </para> 621 622 <para> 623 If "false", the flag is never set. On "notaway", the flag is removed for users marked as "away" and set for all others. On "encrypted", the flag is set for users with whom we have an encrypted connection. On "trusted", it is set only for encrypted connections using a trusted key. 624 </para> 625 </description> 626 627 </bitlbee-setting> 628 466 629 <bitlbee-setting name="lcnicks" type="boolean" scope="global"> 467 630 <default>true</default> … … 486 649 </bitlbee-setting> 487 650 488 <bitlbee-setting name="ops" type="string" scope="global"> 489 <default>both</default> 490 <possible-values>both, root, user, none</possible-values> 491 492 <description> 493 <para> 494 Some people prefer themself and root to have operator status in &bitlbee, other people don't. You can change these states using this setting. 495 </para> 496 497 <para> 498 The value "both" means both user and root get ops. "root" means, well, just root. "user" means just the user. "none" means nobody will get operator status. 651 <bitlbee-setting name="op_buddies" type="string" scope="global"> 652 <default>trusted</default> 653 <possible-values>encrypted, trusted, notaway, false</possible-values> 654 655 <description> 656 <para> 657 Specifies under which circumstances BitlBee should give the "op" mode flag (+o) to buddies. 658 </para> 659 660 <para> 661 If "false", the flag is never set. On "notaway", the flag is removed for users marked as "away" and set for all others. On "encrypted", the flag is set for users with whom we have an encrypted connection. On "trusted", it is set only for encrypted connections using a trusted key. 662 </para> 663 </description> 664 665 </bitlbee-setting> 666 667 <bitlbee-setting name="op_root" type="bool" scope="global"> 668 <default>true</default> 669 670 <description> 671 <para> 672 Some people prefer themself and root to have operator status in &bitlbee, other people don't. You can set the desired state for root using this setting. 673 </para> 674 </description> 675 </bitlbee-setting> 676 677 <bitlbee-setting name="op_user" type="bool" scope="global"> 678 <default>true</default> 679 680 <description> 681 <para> 682 Some people prefer themself and root to have operator status in &bitlbee, other people don't. You can set the desired state for yourself using this setting. 683 </para> 684 </description> 685 </bitlbee-setting> 686 687 <bitlbee-setting name="otr_policy" type="string" scope="global"> 688 <default>opportunistic</default> 689 <possible-values>never, opportunistic, manual, always</possible-values> 690 691 <description> 692 <para> 693 This setting controls the policy for establishing Off-the-Record connections. 694 </para> 695 <para> 696 A value of "never" effectively disables the OTR subsystem. In "opportunistic" mode, a magic whitespace pattern will be appended to the first message sent to any user. If the peer is also running opportunistic OTR, an encrypted connection will be set up automatically. On "manual", on the other hand, OTR connections must be established explicitly using <emphasis>otr connect</emphasis>. Finally, the setting "always" enforces encrypted communication by causing BitlBee to refuse to send any cleartext messages at all. 499 697 </para> 500 698 </description> … … 680 878 </para> 681 879 </description> 880 </bitlbee-setting> 881 882 <bitlbee-setting name="voice_buddies" type="string" scope="global"> 883 <default>trusted</default> 884 <possible-values>encrypted, trusted, notaway, false</possible-values> 885 886 <description> 887 <para> 888 Specifies under which circumstances BitlBee should give the "voice" mode flag (+v) to buddies. 889 </para> 890 891 <para> 892 If "false", the flag is never set. On "notaway", the flag is removed for users marked as "away" and set for all others. On "encrypted", the flag is set for users with whom we have an encrypted connection. On "trusted", it is set only for encrypted connections using a trusted key. 893 </para> 894 </description> 895 682 896 </bitlbee-setting> 683 897 -
irc.c
rca60550 r4eb4c0f 28 28 #include "crypting.h" 29 29 #include "ipc.h" 30 #include <sys/types.h> 31 #include <sys/wait.h> 30 32 31 33 static gboolean irc_userping( gpointer _irc, int fd, b_input_condition cond ); 34 static void irc_welcome( irc_t *irc ); 32 35 33 36 GSList *irc_connection_list = NULL; … … 102 105 103 106 irc_connection_list = g_slist_append( irc_connection_list, irc ); 104 105 set_add( &irc->set, "away_devoice", "true", set_eval_away_devoice, irc ); 107 106 108 set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc ); 107 109 set_add( &irc->set, "auto_reconnect", "false", set_eval_bool, irc ); … … 110 112 set_add( &irc->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc ); 111 113 set_add( &irc->set, "charset", "utf-8", set_eval_charset, irc ); 114 set_add( &irc->set, "color_encrypted", "true", set_eval_bool, irc ); 112 115 set_add( &irc->set, "debug", "false", set_eval_bool, irc ); 113 116 set_add( &irc->set, "default_target", "root", NULL, irc ); 114 117 set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc ); 115 118 set_add( &irc->set, "handle_unknown", "root", NULL, irc ); 119 set_add( &irc->set, "halfop_buddies", "encrypted", set_eval_halfop_buddies, irc ); 116 120 set_add( &irc->set, "lcnicks", "true", set_eval_bool, irc ); 117 set_add( &irc->set, "ops", "both", set_eval_ops, irc ); 121 set_add( &irc->set, "op_buddies", "trusted", set_eval_op_buddies, irc ); 122 set_add( &irc->set, "op_root", "true", set_eval_op_root, irc ); 123 set_add( &irc->set, "op_user", "true", set_eval_op_user, irc ); 124 set_add( &irc->set, "otr_policy", "opportunistic", set_eval_otr_policy, irc ); 118 125 set_add( &irc->set, "password", NULL, passchange, irc ); 119 126 set_add( &irc->set, "private", "true", set_eval_bool, irc ); … … 124 131 set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc ); 125 132 set_add( &irc->set, "typing_notice", "false", set_eval_bool, irc ); 133 set_add( &irc->set, "voice_buddies", "notaway", set_eval_voice_buddies, irc ); 126 134 127 135 conf_loaddefaults( irc ); 136 137 irc->otr = otr_new(); 128 138 129 139 return( irc ); … … 264 274 g_hash_table_foreach_remove(irc->watches, irc_free_hashkey, NULL); 265 275 g_hash_table_destroy(irc->watches); 276 277 otr_free(irc->otr); 266 278 267 279 g_free(irc); … … 620 632 } 621 633 634 const char *user_mode_prefix( irc_t *irc, user_t *u ) 635 { 636 static char op[] = "@"; 637 static char halfop[] = "%"; 638 static char voice[] = "+"; 639 static char none[] = ""; 640 641 int or = set_getbool(&irc->set, "op_root"); 642 int ou = set_getbool(&irc->set, "op_user"); 643 char *ob = set_getstr(&irc->set, "op_buddies"); 644 char *hb = set_getstr(&irc->set, "halfop_buddies"); 645 char *vb = set_getstr(&irc->set, "voice_buddies"); 646 647 if( (!strcmp(u->nick, irc->mynick) && or) || 648 (!strcmp(u->nick, irc->nick) && ou) || 649 (!u->away && !strcmp(ob, "notaway")) || 650 (u->encrypted && !strcmp(ob, "encrypted")) || 651 (u->encrypted>1 && !strcmp(ob, "trusted")) 652 ) 653 return op; 654 else if( (!u->away && !strcmp(hb, "notaway")) || 655 (u->encrypted && !strcmp(hb, "encrypted")) || 656 (u->encrypted>1 && !strcmp(hb, "trusted")) 657 ) 658 return halfop; 659 else if( (!u->away && !strcmp(vb, "notaway")) || 660 (u->encrypted && !strcmp(vb, "encrypted")) || 661 (u->encrypted>1 && !strcmp(vb, "trusted")) 662 ) 663 return voice; 664 else 665 return none; 666 } 667 622 668 void irc_names( irc_t *irc, char *channel ) 623 669 { … … 625 671 char namelist[385] = ""; 626 672 struct groupchat *c = NULL; 627 char *ops = set_getstr( &irc->set, "ops" );628 673 629 674 /* RFCs say there is no error reply allowed on NAMES, so when the … … 640 685 } 641 686 642 if( u->ic && !u->away && set_getbool( &irc->set, "away_devoice" ) ) 643 strcat( namelist, "+" ); 644 else if( ( strcmp( u->nick, irc->mynick ) == 0 && ( strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) == 0 ) ) || 645 ( strcmp( u->nick, irc->nick ) == 0 && ( strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) == 0 ) ) ) 646 strcat( namelist, "@" ); 647 687 strcat( namelist, user_mode_prefix(irc, u) ); 648 688 strcat( namelist, u->nick ); 649 689 strcat( namelist, " " ); … … 656 696 /* root and the user aren't in the channel userlist but should 657 697 show up in /NAMES, so list them first: */ 658 sprintf( namelist, "%s%s %s%s ", s trcmp( ops, "root" ) == 0 || strcmp( ops, "both") ? "@" : "", irc->mynick,659 s trcmp( ops, "user" ) == 0 || strcmp( ops, "both") ? "@" : "", irc->nick );698 sprintf( namelist, "%s%s %s%s ", set_getbool(&irc->set, "op_root") ? "@" : "", irc->mynick, 699 set_getbool(&irc->set, "op_user") ? "@" : "", irc->nick ); 660 700 661 701 for( l = c->in_room; l; l = l->next ) if( ( u = user_findhandle( c->ic, l->data ) ) ) … … 667 707 } 668 708 709 strcat( namelist, user_mode_prefix(irc, u) ); 669 710 strcat( namelist, u->nick ); 670 711 strcat( namelist, " " ); … … 708 749 irc_reply( irc, 3, ":%s", IRCD_INFO ); 709 750 irc_reply( irc, 4, "%s %s %s %s", irc->myhost, BITLBEE_VERSION, UMODES UMODES_PRIV, CMODES ); 710 irc_reply( irc, 5, "PREFIX=(o v)@+ CHANTYPES=#& CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee CASEMAPPING=rfc1459 MAXTARGETS=1 WATCH=128 :are supported by this server", CMODES, MAX_NICK_LENGTH - 1 );751 irc_reply( irc, 5, "PREFIX=(ohv)@%%+ CHANTYPES=#& CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee CASEMAPPING=rfc1459 MAXTARGETS=1 WATCH=128 :are supported by this server", CMODES, MAX_NICK_LENGTH - 1 ); 711 752 irc_motd( irc ); 712 753 irc->umode[0] = '\0'; … … 735 776 irc_spawn( irc, u ); 736 777 737 irc_ usermsg( irc, "Welcome to the BitlBee gateway!\n\nIf you've never used BitlBee before, please do read the help information using the \x02help\x02 command. Lots of FAQs are answered there.");778 irc_welcome( irc ); 738 779 739 780 if( global.conf->runmode == RUNMODE_FORKDAEMON || global.conf->runmode == RUNMODE_DAEMON ) … … 741 782 742 783 irc->status |= USTATUS_LOGGED_IN; 784 } 785 786 static void irc_welcome( irc_t *irc ) 787 { 788 FILE *f; 789 790 f = fopen( global.conf->welcomefile, "r" ); 791 if( !f ) 792 { 793 irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\nIf you've never used BitlBee before, please do read the help information using the \x02help\x02 command. Lots of FAQs are answered there.\n\nOTR users please note: Private key files are owned by the user BitlBee is running as." ); 794 } 795 else 796 { 797 char linebuf[380]; 798 799 while( fgets( linebuf, 380, f ) ) 800 { 801 irc_usermsg( irc, linebuf ); 802 } 803 804 fclose( f ); 805 } 743 806 } 744 807 -
irc.h
rca60550 r4eb4c0f 27 27 #define _IRC_H 28 28 29 #include "otr.h" 30 29 31 #define IRC_MAX_LINE 512 30 #define IRC_MAX_ARGS 832 #define IRC_MAX_ARGS 16 31 33 32 34 #define IRC_LOGIN_TIMEOUT 60 … … 94 96 gint w_watch_source_id; 95 97 gint ping_source_id; 98 99 otr_t *otr; /* OTR state and book keeping */ 96 100 } irc_t; 97 101 -
lib/misc.c
rca60550 r4eb4c0f 112 112 { "gt", ">" }, 113 113 { "amp", "&" }, 114 { "apos", "'" }, 114 115 { "quot", "\"" }, 115 116 { "aacute", "á" }, … … 143 144 char *s = out, *cs; 144 145 int i, matched; 146 int taglen; 145 147 146 148 memset( out, 0, strlen( in ) + 1 ); … … 159 161 in ++; 160 162 163 taglen = in-cs-1; /* not <0 because the above loop runs at least once */ 161 164 if( *in ) 162 165 { 163 if( g_strncasecmp( cs+1, "br", 2) == 0 ) 166 if( g_strncasecmp( cs+1, "b", taglen) == 0 ) 167 *(s++) = '\x02'; 168 else if( g_strncasecmp( cs+1, "/b", taglen) == 0 ) 169 *(s++) = '\x02'; 170 else if( g_strncasecmp( cs+1, "i", taglen) == 0 ) 171 *(s++) = '\x1f'; 172 else if( g_strncasecmp( cs+1, "/i", taglen) == 0 ) 173 *(s++) = '\x1f'; 174 else if( g_strncasecmp( cs+1, "br", 2) == 0 ) 164 175 *(s++) = '\n'; 165 176 in ++; -
log.c
rca60550 r4eb4c0f 30 30 static log_t logoutput; 31 31 32 static void log_null(int level, c har *logmessage);33 static void log_irc(int level, c har *logmessage);34 static void log_syslog(int level, c har *logmessage);35 static void log_console(int level, c har *logmessage);32 static void log_null(int level, const char *logmessage); 33 static void log_irc(int level, const char *logmessage); 34 static void log_syslog(int level, const char *logmessage); 35 static void log_console(int level, const char *logmessage); 36 36 37 37 void log_init(void) { … … 97 97 } 98 98 99 void log_message(int level, c har *message, ... ) {99 void log_message(int level, const char *message, ... ) { 100 100 101 101 va_list ap; … … 122 122 } 123 123 124 void log_error(c har *functionname) {124 void log_error(const char *functionname) { 125 125 log_message(LOGLVL_ERROR, "%s: %s", functionname, strerror(errno)); 126 126 … … 128 128 } 129 129 130 static void log_null(int level, c har *message) {130 static void log_null(int level, const char *message) { 131 131 return; 132 132 } 133 133 134 static void log_irc(int level, c har *message) {134 static void log_irc(int level, const char *message) { 135 135 if(level == LOGLVL_ERROR) 136 136 irc_write_all(1, "ERROR :Error: %s", message); … … 147 147 } 148 148 149 static void log_syslog(int level, c har *message) {149 static void log_syslog(int level, const char *message) { 150 150 if(level == LOGLVL_ERROR) 151 151 syslog(LOG_ERR, "%s", message); … … 161 161 } 162 162 163 static void log_console(int level, c har *message) {163 static void log_console(int level, const char *message) { 164 164 if(level == LOGLVL_ERROR) 165 165 fprintf(stderr, "Error: %s\n", message); -
log.h
rca60550 r4eb4c0f 44 44 45 45 typedef struct log_t { 46 void (*error)(int level, c har *logmessage);47 void (*warning)(int level, c har *logmessage);48 void (*informational)(int level, c har *logmessage);46 void (*error)(int level, const char *logmessage); 47 void (*warning)(int level, const char *logmessage); 48 void (*informational)(int level, const char *logmessage); 49 49 #ifdef DEBUG 50 void (*debug)(int level, c har *logmessage);50 void (*debug)(int level, const char *logmessage); 51 51 #endif 52 52 } log_t; … … 54 54 void log_init(void); 55 55 void log_link(int level, int output); 56 void log_message(int level, c har *message, ...) G_GNUC_PRINTF( 2, 3 );57 void log_error(c har *functionname);56 void log_message(int level, const char *message, ...) G_GNUC_PRINTF( 2, 3 ); 57 void log_error(const char *functionname); 58 58 59 59 #endif -
protocols/jabber/jabber.c
rca60550 r4eb4c0f 511 511 512 512 ret->name = "jabber"; 513 ret->mms = 0; /* no limit */ 513 514 ret->login = jabber_login; 514 515 ret->init = jabber_init; -
protocols/msn/msn.c
rca60550 r4eb4c0f 372 372 373 373 ret->name = "msn"; 374 ret->mms = 1409; /* this guess taken from libotr UPGRADING file */ 374 375 ret->login = msn_login; 375 376 ret->init = msn_init; -
protocols/nogaim.c
rca60550 r4eb4c0f 603 603 604 604 /* LISPy... */ 605 if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ 606 ( u->online ) && /* Don't touch offline people */ 607 ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ 608 ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ 605 if( ( u->online ) && /* Don't touch offline people */ 606 ( ( ( u->online != oo ) && !u->away ) || /* Do joining people */ 607 ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* Do people changing state */ 609 608 { 610 609 char *from; … … 619 618 ic->irc->myhost ); 620 619 } 621 irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel, 622 u->away?'-':'+', u->nick ); 620 if(!strcmp(set_getstr(&ic->irc->set, "voice_buddies"), "notaway")) { 621 irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel, 622 u->away?'-':'+', u->nick ); 623 } 624 if(!strcmp(set_getstr(&ic->irc->set, "halfop_buddies"), "notaway")) { 625 irc_write( ic->irc, ":%s MODE %s %ch %s", from, ic->irc->channel, 626 u->away?'-':'+', u->nick ); 627 } 628 if(!strcmp(set_getstr(&ic->irc->set, "op_buddies"), "notaway")) { 629 irc_write( ic->irc, ":%s MODE %s %co %s", from, ic->irc->channel, 630 u->away?'-':'+', u->nick ); 631 } 623 632 g_free( from ); 624 633 } … … 630 639 char *wrapped; 631 640 user_t *u; 632 641 642 /* pass the message through OTR */ 643 msg = otr_handle_message(ic, handle, msg); 644 if(!msg) { 645 /* this was an internal OTR protocol message */ 646 return; 647 } 648 633 649 u = user_findhandle( ic, handle ); 634 635 650 if( !u ) 636 651 { … … 642 657 imcb_log( ic, "Ignoring message from unknown handle %s", handle ); 643 658 659 g_free(msg); 644 660 return; 645 661 } … … 674 690 irc_msgfrom( irc, u->nick, wrapped ); 675 691 g_free( wrapped ); 692 g_free( msg ); 676 693 } 677 694 … … 914 931 915 932 916 /* Misc. BitlBee stuff which shouldn't really be here */917 918 char *set_eval_away_devoice( set_t *set, char *value )919 {920 irc_t *irc = set->data;921 int st;922 923 if( ( g_strcasecmp( value, "true" ) == 0 ) || ( g_strcasecmp( value, "yes" ) == 0 ) || ( g_strcasecmp( value, "on" ) == 0 ) )924 st = 1;925 else if( ( g_strcasecmp( value, "false" ) == 0 ) || ( g_strcasecmp( value, "no" ) == 0 ) || ( g_strcasecmp( value, "off" ) == 0 ) )926 st = 0;927 else if( sscanf( value, "%d", &st ) != 1 )928 return( NULL );929 930 st = st != 0;931 932 /* Horror.... */933 934 if( st != set_getbool( &irc->set, "away_devoice" ) )935 {936 char list[80] = "";937 user_t *u = irc->users;938 int i = 0, count = 0;939 char pm;940 char v[80];941 942 if( st )943 pm = '+';944 else945 pm = '-';946 947 while( u )948 {949 if( u->ic && u->online && !u->away )950 {951 if( ( strlen( list ) + strlen( u->nick ) ) >= 79 )952 {953 for( i = 0; i < count; v[i++] = 'v' ); v[i] = 0;954 irc_write( irc, ":%s MODE %s %c%s%s",955 irc->myhost,956 irc->channel, pm, v, list );957 958 *list = 0;959 count = 0;960 }961 962 sprintf( list + strlen( list ), " %s", u->nick );963 count ++;964 }965 u = u->next;966 }967 968 /* $v = 'v' x $i */969 for( i = 0; i < count; v[i++] = 'v' ); v[i] = 0;970 irc_write( irc, ":%s MODE %s %c%s%s", irc->myhost,971 irc->channel, pm, v, list );972 }973 974 return( set_eval_bool( set, value ) );975 }976 977 978 979 980 933 /* The plan is to not allow straight calls to prpl functions anymore, but do 981 934 them all from some wrappers. We'll start to define some down here: */ … … 991 944 msg = buf; 992 945 } 993 994 st = ic->acc->prpl->buddy_msg( ic, handle, msg, flags ); 995 g_free( buf ); 996 946 947 /* if compiled without otr support, this just calls the prpl buddy_msg */ 948 st = otr_send_message(ic, handle, msg, flags); 949 950 g_free(buf); 997 951 return st; 998 952 } -
protocols/nogaim.h
rca60550 r4eb4c0f 136 136 * - The user sees this name ie. when imcb_log() is used. */ 137 137 const char *name; 138 /* Maximum Message Size of this protocol. 139 * - Introduced for OTR, in order to fragment large protocol messages. 140 * - 0 means "unlimited". */ 141 unsigned int mms; 138 142 139 143 /* Added this one to be able to add per-account settings, don't think … … 317 321 318 322 /* Misc. stuff */ 319 char *set_eval_away_devoice( set_t *set, char *value );320 323 gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ); 321 324 void cancel_auto_reconnect( struct account *a ); -
protocols/oscar/oscar.c
rca60550 r4eb4c0f 2605 2605 struct prpl *ret = g_new0(struct prpl, 1); 2606 2606 ret->name = "oscar"; 2607 ret->mms = 2343; /* this guess taken from libotr UPGRADING file */ 2607 2608 ret->away_states = oscar_away_states; 2608 2609 ret->init = oscar_init; -
protocols/yahoo/yahoo.c
rca60550 r4eb4c0f 354 354 struct prpl *ret = g_new0(struct prpl, 1); 355 355 ret->name = "yahoo"; 356 ret->mms = 832; /* this guess taken from libotr UPGRADING file */ 356 357 ret->init = byahoo_init; 357 358 -
query.c
rca60550 r4eb4c0f 102 102 int count = 0; 103 103 104 if(!ic) 105 return; 106 104 107 q = irc->queries; 105 108 def = query_default( irc ); … … 140 143 if( ans ) 141 144 { 142 imcb_log( q->ic, "Accepted: %s", q->question ); 143 q->yes( NULL, q->data ); 145 if(q->ic) 146 imcb_log( q->ic, "Accepted: %s", q->question ); 147 else 148 irc_usermsg( irc, "Accepted: %s", q->question ); 149 if(q->yes) 150 q->yes( q->ic ? (gpointer)q->ic : (gpointer)irc, q->data ); 144 151 } 145 152 else 146 153 { 147 imcb_log( q->ic, "Rejected: %s", q->question ); 148 q->no( NULL, q->data ); 154 if(q->ic) 155 imcb_log( q->ic, "Rejected: %s", q->question ); 156 else 157 irc_usermsg( irc, "Rejected: %s", q->question ); 158 if(q->no) 159 q->no( q->ic ? (gpointer)q->ic : (gpointer)irc, q->data ); 149 160 } 150 161 q->data = NULL; -
root_commands.c
rca60550 r4eb4c0f 29 29 #include "bitlbee.h" 30 30 #include "help.h" 31 #include "otr.h" 31 32 32 33 #include <string.h> … … 241 242 242 243 irc_usermsg( irc, "Account successfully added" ); 244 245 if(otr_check_for_key(a)) { 246 irc_usermsg(irc, "otr: you will be notified when it completes"); 247 } 243 248 } 244 249 else if( g_strcasecmp( cmd[1], "del" ) == 0 ) … … 992 997 { "qlist", 0, cmd_qlist, 0 }, 993 998 { "join_chat", 2, cmd_join_chat, 0 }, 999 { "otr", 1, cmd_otr, 0 }, 994 1000 { NULL } 995 1001 }; -
set.c
rca60550 r4eb4c0f 209 209 } 210 210 211 char *set_eval_op s( set_t *set, char *value )211 char *set_eval_op_root( set_t *set, char *value ) 212 212 { 213 213 irc_t *irc = set->data; 214 215 if( g_strcasecmp( value, "user" ) == 0 ) 216 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 217 irc->channel, "+o-o", irc->nick, irc->mynick ); 218 else if( g_strcasecmp( value, "root" ) == 0 ) 219 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 220 irc->channel, "-o+o", irc->nick, irc->mynick ); 221 else if( g_strcasecmp( value, "both" ) == 0 ) 222 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 223 irc->channel, "+oo", irc->nick, irc->mynick ); 224 else if( g_strcasecmp( value, "none" ) == 0 ) 225 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 226 irc->channel, "-oo", irc->nick, irc->mynick ); 214 char *ret = set_eval_bool(set, value); 215 int b = bool2int(ret); 216 217 irc_write( irc, ":%s!%s@%s MODE %s %s %s", irc->mynick, irc->mynick, irc->myhost, 218 irc->channel, b?"+o":"-o", irc->mynick ); 219 return ret; 220 } 221 222 char *set_eval_op_user( set_t *set, char *value ) 223 { 224 irc_t *irc = set->data; 225 char *ret = set_eval_bool(set, value); 226 int b = bool2int(ret); 227 228 irc_write( irc, ":%s!%s@%s MODE %s %s %s", irc->mynick, irc->mynick, irc->myhost, 229 irc->channel, b?"+o":"-o", irc->nick ); 230 return ret; 231 } 232 233 /* generalized version of set_eval_op/voice_buddies */ 234 char *set_eval_mode_buddies( set_t *set, char *value, char modeflag ) 235 { 236 irc_t *irc = set->data; 237 char op[64], deop[64]; 238 int nop=0, ndeop=0; 239 user_t *u; 240 int mode; 241 242 if(!strcmp(value, "false")) 243 mode=0; 244 else if(!strcmp(value, "encrypted")) 245 mode=1; 246 else if(!strcmp(value, "trusted")) 247 mode=2; 248 else if(!strcmp(value, "notaway")) 249 mode=3; 227 250 else 228 251 return NULL; 229 252 253 /* sorry for calling them op/deop - too lazy for search+replace :P */ 254 op[0]='\0'; 255 deop[0]='\0'; 256 for(u=irc->users; u; u=u->next) { 257 /* we're only concerned with online buddies */ 258 if(!u->ic || !u->online) 259 continue; 260 261 /* just in case... */ 262 if(strlen(u->nick) >= 64) 263 continue; 264 265 /* dump out ops/deops when the corresponding name list fills up */ 266 if(strlen(op)+strlen(u->nick)+2 > 64) { 267 char *flags = g_strnfill(nop, modeflag); 268 irc_write( irc, ":%s!%s@%s MODE %s +%s%s", irc->mynick, irc->mynick, irc->myhost, 269 irc->channel, flags, op ); 270 op[0]='\0'; 271 nop=0; 272 g_free(flags); 273 } 274 if(strlen(deop)+strlen(u->nick)+2 > 64) { 275 char *flags = g_strnfill(ndeop, modeflag); 276 irc_write( irc, ":%s!%s@%s MODE %s -%s%s", irc->mynick, irc->mynick, irc->myhost, 277 irc->channel, flags, deop ); 278 deop[0]='\0'; 279 ndeop=0; 280 g_free(flags); 281 } 282 283 switch(mode) { 284 /* "false" */ 285 case 0: 286 g_strlcat(deop, " ", 64); 287 g_strlcat(deop, u->nick, 64); 288 ndeop++; 289 break; 290 /* "encrypted" */ 291 case 1: 292 if(u->encrypted) { 293 g_strlcat(op, " ", 64); 294 g_strlcat(op, u->nick, 64); 295 nop++; 296 } else { 297 g_strlcat(deop, " ", 64); 298 g_strlcat(deop, u->nick, 64); 299 ndeop++; 300 } 301 break; 302 /* "trusted" */ 303 case 2: 304 if(u->encrypted > 1) { 305 g_strlcat(op, " ", 64); 306 g_strlcat(op, u->nick, 64); 307 nop++; 308 } else { 309 g_strlcat(deop, " ", 64); 310 g_strlcat(deop, u->nick, 64); 311 ndeop++; 312 } 313 break; 314 /* "notaway" */ 315 case 3: 316 if(u->away) { 317 g_strlcat(deop, " ", 64); 318 g_strlcat(deop, u->nick, 64); 319 ndeop++; 320 } else { 321 g_strlcat(op, " ", 64); 322 g_strlcat(op, u->nick, 64); 323 nop++; 324 } 325 } 326 } 327 /* dump anything left in op/deop lists */ 328 if(*op) { 329 char *flags = g_strnfill(nop, modeflag); 330 irc_write( irc, ":%s!%s@%s MODE %s +%s%s", irc->mynick, irc->mynick, irc->myhost, 331 irc->channel, flags, op ); 332 g_free(flags); 333 } 334 if(*deop) { 335 char *flags = g_strnfill(ndeop, modeflag); 336 irc_write( irc, ":%s!%s@%s MODE %s -%s%s", irc->mynick, irc->mynick, irc->myhost, 337 irc->channel, flags, deop ); 338 g_free(flags); 339 } 340 230 341 return value; 342 } 343 344 char *set_eval_op_buddies( set_t *set, char *value ) 345 { 346 return set_eval_mode_buddies(set, value, 'o'); 347 } 348 349 char *set_eval_halfop_buddies( set_t *set, char *value ) 350 { 351 return set_eval_mode_buddies(set, value, 'h'); 352 } 353 354 char *set_eval_voice_buddies( set_t *set, char *value ) 355 { 356 return set_eval_mode_buddies(set, value, 'v'); 231 357 } 232 358 … … 245 371 return value; 246 372 } 373 374 /* possible values: never, opportunistic, manual, always */ 375 char *set_eval_otr_policy( set_t *set, char *value ) 376 { 377 if ( !strcmp(value, "never") ) 378 return value; 379 if ( !strcmp(value, "opportunistic") ) 380 return value; 381 if ( !strcmp(value, "manual") ) 382 return value; 383 if ( !strcmp(value, "always") ) 384 return value; 385 return NULL; 386 } -
set.h
rca60550 r4eb4c0f 96 96 /* Some not very generic evaluators that really shouldn't be here... */ 97 97 char *set_eval_to_char( set_t *set, char *value ); 98 char *set_eval_ops( set_t *set, char *value ); 98 char *set_eval_op_root( set_t *set, char *value ); 99 char *set_eval_op_user( set_t *set, char *value ); 100 char *set_eval_op_buddies( set_t *set, char *value ); 101 char *set_eval_halfop_buddies( set_t *set, char *value ); 102 char *set_eval_voice_buddies( set_t *set, char *value ); 99 103 char *set_eval_charset( set_t *set, char *value ); 104 char *set_eval_otr_policy( set_t *set, char *value ); 100 105 101 106 #endif /* __SET_H__ */ -
storage.c
rca60550 r4eb4c0f 29 29 #include "bitlbee.h" 30 30 #include "crypting.h" 31 #include "otr.h" 31 32 32 33 extern storage_t storage_text; … … 115 116 if (status == STORAGE_OK) { 116 117 irc_setpass(irc, password); 118 otr_load(irc); /* load our OTR userstate */ 117 119 return status; 118 120 } 119 121 120 if (status != STORAGE_NO_SUCH_USER) 122 if (status != STORAGE_NO_SUCH_USER) { 121 123 return status; 124 } 122 125 } 123 126 … … 127 130 storage_status_t storage_save (irc_t *irc, int overwrite) 128 131 { 129 return ((storage_t *)global.storage->data)->save(irc, overwrite); 132 storage_status_t st; 133 134 otr_save(irc); 135 st = ((storage_t *)global.storage->data)->save(irc, overwrite); 136 return st; 130 137 } 131 138 … … 147 154 ret = status; 148 155 } 156 if (ret == STORAGE_OK) { 157 otr_remove(nick); 158 } 149 159 150 160 return ret; … … 157 167 storage_t *primary_storage = gl->data; 158 168 irc_t *irc; 159 169 160 170 /* First, try to rename in the current write backend, assuming onick 161 171 * is stored there */ 162 172 status = primary_storage->rename(onick, nnick, password); 163 if (status != STORAGE_NO_SUCH_USER) 173 if (status != STORAGE_NO_SUCH_USER) { 174 otr_rename(onick, nnick); 164 175 return status; 176 } 165 177 166 178 /* Try to load from a migration backend and save to the current backend. … … 186 198 187 199 storage_remove(onick, password); 200 otr_rename(onick, nnick); 188 201 189 202 return STORAGE_OK; -
unix.c
rca60550 r4eb4c0f 27 27 #include "commands.h" 28 28 #include "crypting.h" 29 #include "otr.h" 29 30 #include "protocols/nogaim.h" 30 31 #include "help.h" … … 54 55 b_main_init(); 55 56 nogaim_init(); 57 otr_init(); 56 58 57 59 srand( time( NULL ) ^ getpid() ); -
user.c
rca60550 r4eb4c0f 141 141 } 142 142 143 user_t *user_findhandle( struct im_connection *ic, c har *handle )143 user_t *user_findhandle( struct im_connection *ic, const char *handle ) 144 144 { 145 145 user_t *u; -
user.h
rca60550 r4eb4c0f 37 37 char is_private; 38 38 char online; 39 char encrypted; 39 40 40 41 char *handle; … … 56 57 int user_del( irc_t *irc, char *nick ); 57 58 G_MODULE_EXPORT user_t *user_find( irc_t *irc, char *nick ); 58 G_MODULE_EXPORT user_t *user_findhandle( struct im_connection *ic, c har *handle );59 G_MODULE_EXPORT user_t *user_findhandle( struct im_connection *ic, const char *handle ); 59 60 void user_rename( irc_t *irc, char *oldnick, char *newnick ); 60 61
Note: See TracChangeset
for help on using the changeset viewer.