Changes in / [6a78c0e:6738a67]
- Files:
-
- 3 added
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
r6a78c0e r6738a67 11 11 # Program variables 12 12 objects = account.o bitlbee.o crypting.o help.o ipc.o irc.o irc_commands.o nick.o query.o root_commands.o set.o storage.o $(STORAGE_OBJS) 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 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.h13 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 … … 20 20 OUTFILE=bitlbee.exe 21 21 else 22 objects += unix.o conf.o log.o 22 objects += unix.o conf.o log.o otr.o 23 23 OUTFILE=bitlbee 24 24 endif … … 94 94 mkdir -p $(DESTDIR)$(ETCDIR) 95 95 install -m 0644 motd.txt $(DESTDIR)$(ETCDIR)/motd.txt 96 install -m 0644 welcome.txt $(DESTDIR)$(ETCDIR)/welcome.txt 96 97 install -m 0644 bitlbee.conf $(DESTDIR)$(ETCDIR)/bitlbee.conf 97 98 98 99 uninstall-etc: 99 100 rm -f $(DESTDIR)$(ETCDIR)/motd.txt 101 rm -f $(DESTDIR)$(ETCDIR)/welcome.txt 100 102 rm -f $(DESTDIR)$(ETCDIR)/bitlbee.conf 101 103 -rmdir $(DESTDIR)$(ETCDIR) -
bitlbee.conf
r6a78c0e r6738a67 86 86 # MotdFile = /etc/bitlbee/motd.txt 87 87 88 ## WelcomeFile 89 ## 90 ## Specify an alternative file for the welcome message displayed when joining the 91 ## control channel. Default value depends on the --etcdir argument to configure. 92 ## 93 # WelcomeFile = /etc/bitlbee/welcome.txt 94 88 95 ## ConfigDir 89 96 ## -
bitlbee.h
r6a78c0e r6738a67 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
r6a78c0e r6738a67 60 60 conf->pidfile = g_strdup( PIDFILE ); 61 61 conf->motdfile = g_strdup( ETCDIR "/motd.txt" ); 62 conf->welcomefile = g_strdup( ETCDIR "/welcome.txt" ); 62 63 conf->ping_interval = 180; 63 64 conf->ping_timeout = 300; … … 241 242 g_free( conf->motdfile ); 242 243 conf->motdfile = g_strdup( ini->value ); 244 } 245 else if( g_strcasecmp( ini->key, "welcomefile" ) == 0 ) 246 { 247 g_free( conf->welcomefile ); 248 conf->welcomefile = g_strdup( ini->value ); 243 249 } 244 250 else if( g_strcasecmp( ini->key, "account_storage" ) == 0 ) -
conf.h
r6a78c0e r6738a67 45 45 char *pidfile; 46 46 char *motdfile; 47 char *welcomefile; 47 48 char *primary_storage; 48 49 char **migrate_storage; -
configure
r6a78c0e r6738a67 31 31 gcov=0 32 32 plugins=1 33 otr=auto 33 34 34 35 events=glib … … 71 72 --gcov=0/1 Disable/enable test coverage reporting $gcov 72 73 --plugins=0/1 Disable/enable plugins support $plugins 74 --otr=0/1/auto Disable/enable OTR encryption support $otr 73 75 74 76 --events=... Event handler (glib, libevent) $events … … 411 413 fi 412 414 415 otrprefix="" 416 for i in / /usr /usr/local; do 417 if [ -f ${i}/lib/libotr.a ]; then 418 otrprefix=${i} 419 break 420 fi 421 done 422 if [ "$otr" = "auto" ]; then 423 if [ -n "$otrprefix" ]; then 424 otr=1 425 else 426 otr=0 427 fi 428 fi 429 if [ "$otr" = 1 ]; then 430 echo '#define WITH_OTR' >> config.h 431 echo "EFLAGS+=-L${otrprefix}/lib -lotr" >> Makefile.settings 432 echo "CFLAGS+=-I${otrprefix}/include" >> Makefile.settings 433 else 434 echo '#undef WITH_OTR' >> config.h 435 fi 436 413 437 echo 414 438 if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then … … 536 560 fi 537 561 562 if [ "$otr" = "1" ]; then 563 echo ' Off-the-Record (OTR) Messaging enabled.' 564 else 565 echo ' Off-the-Record (OTR) Messaging disabled.' 566 fi 567 538 568 echo ' Using event handler: '$events 539 569 echo ' Using SSL library: '$ssl -
doc/README
r6a78c0e r6738a67 67 67 BitlBee's only real dependency is GLib. This is available on virtually every 68 68 platform. Any recent version of GLib (2.4 or higher) will work. 69 70 Off-the-Record encryption support will be included by default if the 71 configure script finds libotr in one of the usual places. You can pass 72 --otr=1 or --otr=0 to force it on or off, respectively. 69 73 70 74 These days, MSN Messenger clients have to connect to the MS Passport servers … … 143 147 144 148 145 A NOTE ON ENCRYPTION146 ==================== 149 A NOTE ON PASSWORD ENCRYPTION 150 ============================= 147 151 148 152 There used to be a note here about the simple obfuscation method used to -
doc/user-guide/commands.xml
r6a78c0e r6738a67 240 240 </description> 241 241 </bitlbee-command> 242 243 <bitlbee-command name="otr"> 244 <short-description>Off-the-Record encryption control</short-description> 245 <syntax>otr <subcommand> [<arguments>]</syntax> 246 247 <description> 248 249 <para> 250 Available subcommands: connect, disconnect, smp, trust, info, keygen, and forget. See <emphasis>help otr <subcommand></emphasis> for more information. 251 </para> 252 253 </description> 254 255 <bitlbee-command name="connect"> 256 <syntax>otr connect <nick></syntax> 257 258 <description> 259 260 <para> 261 Attempts to establish an encrypted connection with the specified user by sending a magic string. 262 </para> 263 264 </description> 265 266 </bitlbee-command> 267 268 <bitlbee-command name="disconnect"> 269 <syntax>otr disconnect <nick></syntax> 270 271 <description> 272 273 <para> 274 Resets the connection with the specified user to cleartext. 275 </para> 276 277 </description> 278 279 </bitlbee-command> 280 281 <bitlbee-command name="smp"> 282 <syntax>otr smp <nick> <secret></syntax> 283 284 <description> 285 286 <para> 287 Attempts to authenticate the given user's active fingerprint via the Socialist Millionaires' Protocol. 288 </para> 289 290 <para> 291 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. 292 </para> 293 294 </description> 295 296 </bitlbee-command> 297 298 <bitlbee-command name="trust"> 299 <syntax>otr trust <nick> <fp1> <fp2> <fp3> <fp4> <fp5></syntax> 300 301 <description> 302 303 <para> 304 Manually affirms trust in the specified fingerprint, given as five blocks of precisely eight (hexadecimal) digits each. 305 </para> 306 307 </description> 308 309 </bitlbee-command> 310 311 <bitlbee-command name="info"> 312 <syntax>otr info</syntax> 313 <syntax>otr info <nick></syntax> 314 315 <description> 316 317 <para> 318 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. 319 </para> 320 321 </description> 322 323 </bitlbee-command> 324 325 <bitlbee-command name="keygen"> 326 <syntax>otr keygen <account-no></syntax> 327 328 <description> 329 330 <para> 331 Generates a new OTR private key for the given account. 332 </para> 333 334 </description> 335 336 </bitlbee-command> 337 338 <bitlbee-command name="forget"> 339 <syntax>otr forget <thing> <arguments></syntax> 340 341 <description> 342 343 <para> 344 Forgets some part of our OTR userstate. Available things: fingerprint, context, and key. See <emphasis>help otr forget <thing></emphasis> for more information. 345 </para> 346 347 </description> 348 349 <bitlbee-command name="fingerprint"> 350 <syntax>otr forget fingerprint <nick> <fingerprint></syntax> 351 352 <description> 353 354 <para> 355 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. 356 </para> 357 358 </description> 359 360 </bitlbee-command> 361 362 <bitlbee-command name="context"> 363 <syntax>otr forget context <nick></syntax> 364 365 <description> 366 367 <para> 368 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. 369 </para> 370 371 </description> 372 373 </bitlbee-command> 374 375 <bitlbee-command name="key"> 376 <syntax>otr forget key <fingerprint></syntax> 377 378 <description> 379 380 <para> 381 Forgets an OTR private key matching the specified fingerprint. It is allowed to specify only a (unique) prefix of the fingerprint. 382 </para> 383 384 </description> 385 386 </bitlbee-command> 387 388 </bitlbee-command> 389 390 </bitlbee-command> 242 391 243 392 <bitlbee-command name="set"> … … 394 543 </bitlbee-setting> 395 544 545 <bitlbee-setting name="color_encrypted" type="boolean" scope="global"> 546 <default>true</default> 547 548 <description> 549 <para> 550 If set to true, BitlBee will color incoming encrypted messages according to their fingerprint trust level: untrusted=red, trusted=green. 551 </para> 552 </description> 553 554 </bitlbee-setting> 555 396 556 <bitlbee-setting name="debug" type="boolean" scope="global"> 397 557 <default>false</default> … … 460 620 </bitlbee-setting> 461 621 622 <bitlbee-setting name="halfop_buddies" type="string" scope="global"> 623 <default>encrypted</default> 624 <possible-values>encrypted, trusted, notaway, false</possible-values> 625 626 <description> 627 <para> 628 Specifies under which circumstances BitlBee should give the "halfop" mode flag (+h) to buddies. 629 </para> 630 631 <para> 632 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. 633 </para> 634 </description> 635 636 </bitlbee-setting> 637 462 638 <bitlbee-setting name="lcnicks" type="boolean" scope="global"> 463 639 <default>true</default> … … 482 658 </bitlbee-setting> 483 659 484 <bitlbee-setting name="ops" type="string" scope="global"> 485 <default>both</default> 486 <possible-values>both, root, user, none</possible-values> 487 488 <description> 489 <para> 490 Some people prefer themself and root to have operator status in &bitlbee, other people don't. You can change these states using this setting. 491 </para> 492 493 <para> 494 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. 660 <bitlbee-setting name="op_buddies" type="string" scope="global"> 661 <default>trusted</default> 662 <possible-values>encrypted, trusted, notaway, false</possible-values> 663 664 <description> 665 <para> 666 Specifies under which circumstances BitlBee should give the "op" mode flag (+o) to buddies. 667 </para> 668 669 <para> 670 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. 671 </para> 672 </description> 673 674 </bitlbee-setting> 675 676 <bitlbee-setting name="op_root" type="bool" scope="global"> 677 <default>true</default> 678 679 <description> 680 <para> 681 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. 682 </para> 683 </description> 684 </bitlbee-setting> 685 686 <bitlbee-setting name="op_user" type="bool" scope="global"> 687 <default>true</default> 688 689 <description> 690 <para> 691 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. 692 </para> 693 </description> 694 </bitlbee-setting> 695 696 <bitlbee-setting name="otr_policy" type="string" scope="global"> 697 <default>opportunistic</default> 698 <possible-values>never, opportunistic, manual, always</possible-values> 699 700 <description> 701 <para> 702 This setting controls the policy for establishing Off-the-Record connections. 703 </para> 704 <para> 705 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. 495 706 </para> 496 707 </description> … … 686 897 </para> 687 898 </description> 899 </bitlbee-setting> 900 901 <bitlbee-setting name="voice_buddies" type="string" scope="global"> 902 <default>trusted</default> 903 <possible-values>encrypted, trusted, notaway, false</possible-values> 904 905 <description> 906 <para> 907 Specifies under which circumstances BitlBee should give the "voice" mode flag (+v) to buddies. 908 </para> 909 910 <para> 911 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. 912 </para> 913 </description> 914 688 915 </bitlbee-setting> 689 916 -
irc.c
r6a78c0e r6738a67 29 29 #include "crypting.h" 30 30 #include "ipc.h" 31 #include <sys/types.h> 32 #include <sys/wait.h> 31 33 32 34 static gboolean irc_userping( gpointer _irc, int fd, b_input_condition cond ); 35 static void irc_welcome( irc_t *irc ); 33 36 34 37 GSList *irc_connection_list = NULL; … … 135 138 136 139 irc_connection_list = g_slist_append( irc_connection_list, irc ); 137 138 set_add( &irc->set, "away_devoice", "true", set_eval_away_devoice, irc ); 140 139 141 set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc ); 140 142 set_add( &irc->set, "auto_reconnect", "false", set_eval_bool, irc ); … … 143 145 set_add( &irc->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc ); 144 146 set_add( &irc->set, "charset", "utf-8", set_eval_charset, irc ); 147 set_add( &irc->set, "color_encrypted", "true", set_eval_bool, irc ); 145 148 set_add( &irc->set, "debug", "false", set_eval_bool, irc ); 146 149 set_add( &irc->set, "default_target", "root", NULL, irc ); 147 150 set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc ); 148 151 set_add( &irc->set, "handle_unknown", "root", NULL, irc ); 152 set_add( &irc->set, "halfop_buddies", "encrypted", set_eval_halfop_buddies, irc ); 149 153 set_add( &irc->set, "lcnicks", "true", set_eval_bool, irc ); 150 set_add( &irc->set, "ops", "both", set_eval_ops, irc ); 154 set_add( &irc->set, "op_buddies", "trusted", set_eval_op_buddies, irc ); 155 set_add( &irc->set, "op_root", "true", set_eval_op_root, irc ); 156 set_add( &irc->set, "op_user", "true", set_eval_op_user, irc ); 157 set_add( &irc->set, "otr_policy", "opportunistic", set_eval_otr_policy, irc ); 151 158 set_add( &irc->set, "password", NULL, passchange, irc ); 152 159 set_add( &irc->set, "private", "true", set_eval_bool, irc ); … … 158 165 set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc ); 159 166 set_add( &irc->set, "typing_notice", "false", set_eval_bool, irc ); 167 set_add( &irc->set, "voice_buddies", "notaway", set_eval_voice_buddies, irc ); 160 168 161 169 conf_loaddefaults( irc ); 170 171 irc->otr = otr_new(); 162 172 163 173 /* Evaluator sets the iconv/oconv structures. */ … … 312 322 313 323 g_free( irc->last_target ); 324 325 otr_free(irc->otr); 314 326 315 327 g_free( irc ); … … 685 697 } 686 698 699 const char *user_mode_prefix( irc_t *irc, user_t *u ) 700 { 701 static char op[] = "@"; 702 static char halfop[] = "%"; 703 static char voice[] = "+"; 704 static char none[] = ""; 705 706 int or = set_getbool(&irc->set, "op_root"); 707 int ou = set_getbool(&irc->set, "op_user"); 708 char *ob = set_getstr(&irc->set, "op_buddies"); 709 char *hb = set_getstr(&irc->set, "halfop_buddies"); 710 char *vb = set_getstr(&irc->set, "voice_buddies"); 711 712 if( (!strcmp(u->nick, irc->mynick) && or) || 713 (!strcmp(u->nick, irc->nick) && ou) || 714 (!u->away && !strcmp(ob, "notaway")) || 715 (u->encrypted && !strcmp(ob, "encrypted")) || 716 (u->encrypted>1 && !strcmp(ob, "trusted")) 717 ) 718 return op; 719 else if( (!u->away && !strcmp(hb, "notaway")) || 720 (u->encrypted && !strcmp(hb, "encrypted")) || 721 (u->encrypted>1 && !strcmp(hb, "trusted")) 722 ) 723 return halfop; 724 else if( (!u->away && !strcmp(vb, "notaway")) || 725 (u->encrypted && !strcmp(vb, "encrypted")) || 726 (u->encrypted>1 && !strcmp(vb, "trusted")) 727 ) 728 return voice; 729 else 730 return none; 731 } 732 687 733 void irc_names( irc_t *irc, char *channel ) 688 734 { … … 690 736 char namelist[385] = ""; 691 737 struct groupchat *c = NULL; 692 char *ops = set_getstr( &irc->set, "ops" );693 738 694 739 /* RFCs say there is no error reply allowed on NAMES, so when the … … 705 750 } 706 751 707 if( u->ic && !u->away && set_getbool( &irc->set, "away_devoice" ) ) 708 strcat( namelist, "+" ); 709 else if( ( strcmp( u->nick, irc->mynick ) == 0 && ( strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) == 0 ) ) || 710 ( strcmp( u->nick, irc->nick ) == 0 && ( strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) == 0 ) ) ) 711 strcat( namelist, "@" ); 712 752 strcat( namelist, user_mode_prefix(irc, u) ); 713 753 strcat( namelist, u->nick ); 714 754 strcat( namelist, " " ); … … 721 761 /* root and the user aren't in the channel userlist but should 722 762 show up in /NAMES, so list them first: */ 723 sprintf( namelist, "%s%s %s%s ", s trcmp( ops, "root" ) == 0 || strcmp( ops, "both") ? "@" : "", irc->mynick,724 s trcmp( ops, "user" ) == 0 || strcmp( ops, "both") ? "@" : "", irc->nick );763 sprintf( namelist, "%s%s %s%s ", set_getbool(&irc->set, "op_root") ? "@" : "", irc->mynick, 764 set_getbool(&irc->set, "op_user") ? "@" : "", irc->nick ); 725 765 726 766 for( l = c->in_room; l; l = l->next ) if( ( u = user_findhandle( c->ic, l->data ) ) ) … … 732 772 } 733 773 774 strcat( namelist, user_mode_prefix(irc, u) ); 734 775 strcat( namelist, u->nick ); 735 776 strcat( namelist, " " ); … … 773 814 irc_reply( irc, 3, ":%s", IRCD_INFO ); 774 815 irc_reply( irc, 4, "%s %s %s %s", irc->myhost, BITLBEE_VERSION, UMODES UMODES_PRIV, CMODES ); 775 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 );816 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 ); 776 817 irc_motd( irc ); 777 818 irc->umode[0] = '\0'; 778 819 irc_umode_set( irc, "+" UMODE, 1 ); 779 780 u = user_add( irc, irc->mynick ); 820 u = user_add( irc, irc->mynick ); 781 821 u->host = g_strdup( irc->myhost ); 782 822 u->realname = g_strdup( ROOT_FN ); … … 800 840 irc_spawn( irc, u ); 801 841 802 irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\n" 803 "If you've never used BitlBee before, please do read the help " 804 "information using the \x02help\x02 command. Lots of FAQs are " 805 "answered there.\n" 806 "If you already have an account on this server, just use the " 807 "\x02identify\x02 command to identify yourself." ); 842 irc_welcome( irc ); 808 843 809 844 if( global.conf->runmode == RUNMODE_FORKDAEMON || global.conf->runmode == RUNMODE_DAEMON ) … … 820 855 root_command( irc, send_cmd ); 821 856 g_free( send_cmd[1] ); 857 } 858 } 859 860 static void irc_welcome( irc_t *irc ) 861 { 862 FILE *f; 863 864 f = fopen( global.conf->welcomefile, "r" ); 865 if( !f ) 866 { 867 irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\n" 868 "If you've never used BitlBee before, please do read the help " 869 "information using the \x02help\x02 command. Lots of FAQs are " 870 "answered there.\n" 871 "OTR users please note: Private key files are owned by the user " 872 "BitlBee is running as.\n" 873 "If you already have an account on this server, just use the " 874 "\x02identify\x02 command to identify yourself." ); 875 } 876 else 877 { 878 char linebuf[380]; 879 880 while( fgets( linebuf, 380, f ) ) 881 { 882 irc_usermsg( irc, linebuf ); 883 } 884 885 fclose( f ); 822 886 } 823 887 } -
irc.h
r6a78c0e r6738a67 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 … … 97 99 gint w_watch_source_id; 98 100 gint ping_source_id; 101 102 otr_t *otr; /* OTR state and book keeping */ 99 103 } irc_t; 100 104 -
lib/misc.c
r6a78c0e r6738a67 88 88 { "gt", ">" }, 89 89 { "amp", "&" }, 90 { "apos", "'" }, 90 91 { "quot", "\"" }, 91 92 { "aacute", "á" }, … … 119 120 char *s = out, *cs; 120 121 int i, matched; 122 int taglen; 121 123 122 124 memset( out, 0, strlen( in ) + 1 ); … … 135 137 in ++; 136 138 139 taglen = in-cs-1; /* not <0 because the above loop runs at least once */ 137 140 if( *in ) 138 141 { 139 if( g_strncasecmp( cs+1, "br", 2) == 0 ) 142 if( g_strncasecmp( cs+1, "b", taglen) == 0 ) 143 *(s++) = '\x02'; 144 else if( g_strncasecmp( cs+1, "/b", taglen) == 0 ) 145 *(s++) = '\x02'; 146 else if( g_strncasecmp( cs+1, "i", taglen) == 0 ) 147 *(s++) = '\x1f'; 148 else if( g_strncasecmp( cs+1, "/i", taglen) == 0 ) 149 *(s++) = '\x1f'; 150 else if( g_strncasecmp( cs+1, "br", 2) == 0 ) 140 151 *(s++) = '\n'; 141 152 in ++; -
lib/ssl_bogus.c
r6a78c0e r6738a67 27 27 28 28 int ssl_errno; 29 30 void ssl_init( void ) 31 { 32 } 29 33 30 34 void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ) -
lib/ssl_client.h
r6a78c0e r6738a67 47 47 48 48 49 /* Perform any global initialization the SSL library might need. */ 50 G_MODULE_EXPORT void ssl_init( void ); 51 49 52 /* Connect to host:port, call the given function when the connection is 50 53 ready to be used for SSL traffic. This is all done asynchronously, no -
lib/ssl_gnutls.c
r6a78c0e r6738a67 60 60 static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond ); 61 61 62 63 void ssl_init( void ) 64 { 65 gnutls_global_init(); 66 initialized = TRUE; 67 atexit( gnutls_global_deinit ); 68 } 62 69 63 70 void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ) … … 122 129 if( !initialized ) 123 130 { 124 gnutls_global_init(); 125 initialized = TRUE; 126 atexit( gnutls_global_deinit ); 131 ssl_init(); 127 132 } 128 133 -
lib/ssl_nss.c
r6a78c0e r6738a67 91 91 92 92 93 void ssl_init( void ) 94 { 95 PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1); 96 NSS_NoDB_Init(NULL); 97 NSS_SetDomesticPolicy(); 98 initialized = TRUE; 99 } 100 93 101 void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ) 94 102 { … … 107 115 if( !initialized ) 108 116 { 109 PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1); 110 NSS_NoDB_Init(NULL); 111 NSS_SetDomesticPolicy(); 117 ssl_init(); 112 118 } 113 119 -
lib/ssl_openssl.c
r6a78c0e r6738a67 56 56 static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond ); 57 57 58 59 void ssl_init( void ) 60 { 61 initialized = TRUE; 62 SSLeay_add_ssl_algorithms(); 63 } 58 64 59 65 void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ) … … 115 121 if( !initialized ) 116 122 { 117 initialized = TRUE; 118 SSLeay_add_ssl_algorithms(); 123 ssl_init(); 119 124 } 120 125 -
log.c
r6a78c0e r6738a67 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
r6a78c0e r6738a67 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
r6a78c0e r6738a67 528 528 529 529 ret->name = "jabber"; 530 ret->mms = 0; /* no limit */ 530 531 ret->login = jabber_login; 531 532 ret->init = jabber_init; -
protocols/msn/msn.c
r6a78c0e r6738a67 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
r6a78c0e r6738a67 606 606 607 607 /* LISPy... */ 608 if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ 609 ( u->online ) && /* Don't touch offline people */ 610 ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ 611 ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ 608 if( ( u->online ) && /* Don't touch offline people */ 609 ( ( ( u->online != oo ) && !u->away ) || /* Do joining people */ 610 ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* Do people changing state */ 612 611 { 613 612 char *from; … … 622 621 ic->irc->myhost ); 623 622 } 624 irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel, 625 u->away?'-':'+', u->nick ); 623 if(!strcmp(set_getstr(&ic->irc->set, "voice_buddies"), "notaway")) { 624 irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel, 625 u->away?'-':'+', u->nick ); 626 } 627 if(!strcmp(set_getstr(&ic->irc->set, "halfop_buddies"), "notaway")) { 628 irc_write( ic->irc, ":%s MODE %s %ch %s", from, ic->irc->channel, 629 u->away?'-':'+', u->nick ); 630 } 631 if(!strcmp(set_getstr(&ic->irc->set, "op_buddies"), "notaway")) { 632 irc_write( ic->irc, ":%s MODE %s %co %s", from, ic->irc->channel, 633 u->away?'-':'+', u->nick ); 634 } 626 635 g_free( from ); 627 636 } … … 633 642 char *wrapped; 634 643 user_t *u; 635 644 645 /* pass the message through OTR */ 646 msg = otr_handle_message(ic, handle, msg); 647 if(!msg) { 648 /* this was an internal OTR protocol message */ 649 return; 650 } 651 636 652 u = user_findhandle( ic, handle ); 637 638 653 if( !u ) 639 654 { … … 645 660 imcb_log( ic, "Ignoring message from unknown handle %s", handle ); 646 661 662 g_free(msg); 647 663 return; 648 664 } … … 677 693 irc_msgfrom( irc, u->nick, wrapped ); 678 694 g_free( wrapped ); 695 g_free( msg ); 679 696 } 680 697 … … 917 934 918 935 919 /* Misc. BitlBee stuff which shouldn't really be here */920 921 char *set_eval_away_devoice( set_t *set, char *value )922 {923 irc_t *irc = set->data;924 int st;925 926 if( ( g_strcasecmp( value, "true" ) == 0 ) || ( g_strcasecmp( value, "yes" ) == 0 ) || ( g_strcasecmp( value, "on" ) == 0 ) )927 st = 1;928 else if( ( g_strcasecmp( value, "false" ) == 0 ) || ( g_strcasecmp( value, "no" ) == 0 ) || ( g_strcasecmp( value, "off" ) == 0 ) )929 st = 0;930 else if( sscanf( value, "%d", &st ) != 1 )931 return( NULL );932 933 st = st != 0;934 935 /* Horror.... */936 937 if( st != set_getbool( &irc->set, "away_devoice" ) )938 {939 char list[80] = "";940 user_t *u = irc->users;941 int i = 0, count = 0;942 char pm;943 char v[80];944 945 if( st )946 pm = '+';947 else948 pm = '-';949 950 while( u )951 {952 if( u->ic && u->online && !u->away )953 {954 if( ( strlen( list ) + strlen( u->nick ) ) >= 79 )955 {956 for( i = 0; i < count; v[i++] = 'v' ); v[i] = 0;957 irc_write( irc, ":%s MODE %s %c%s%s",958 irc->myhost,959 irc->channel, pm, v, list );960 961 *list = 0;962 count = 0;963 }964 965 sprintf( list + strlen( list ), " %s", u->nick );966 count ++;967 }968 u = u->next;969 }970 971 /* $v = 'v' x $i */972 for( i = 0; i < count; v[i++] = 'v' ); v[i] = 0;973 irc_write( irc, ":%s MODE %s %c%s%s", irc->myhost,974 irc->channel, pm, v, list );975 }976 977 return( set_eval_bool( set, value ) );978 }979 980 981 982 983 936 /* The plan is to not allow straight calls to prpl functions anymore, but do 984 937 them all from some wrappers. We'll start to define some down here: */ … … 994 947 msg = buf; 995 948 } 996 997 st = ic->acc->prpl->buddy_msg( ic, handle, msg, flags ); 998 g_free( buf ); 999 949 950 /* if compiled without otr support, this just calls the prpl buddy_msg */ 951 st = otr_send_message(ic, handle, msg, flags); 952 953 g_free(buf); 1000 954 return st; 1001 955 } -
protocols/nogaim.h
r6a78c0e r6738a67 132 132 * - The user sees this name ie. when imcb_log() is used. */ 133 133 const char *name; 134 /* Maximum Message Size of this protocol. 135 * - Introduced for OTR, in order to fragment large protocol messages. 136 * - 0 means "unlimited". */ 137 unsigned int mms; 134 138 135 139 /* Added this one to be able to add per-account settings, don't think … … 313 317 314 318 /* Misc. stuff */ 315 char *set_eval_away_devoice( set_t *set, char *value );316 319 gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ); 317 320 void cancel_auto_reconnect( struct account *a ); -
protocols/oscar/oscar.c
r6a78c0e r6738a67 2643 2643 struct prpl *ret = g_new0(struct prpl, 1); 2644 2644 ret->name = "oscar"; 2645 ret->mms = 2343; /* this guess taken from libotr UPGRADING file */ 2645 2646 ret->away_states = oscar_away_states; 2646 2647 ret->init = oscar_init; -
protocols/yahoo/yahoo.c
r6a78c0e r6738a67 351 351 struct prpl *ret = g_new0(struct prpl, 1); 352 352 ret->name = "yahoo"; 353 ret->mms = 832; /* this guess taken from libotr UPGRADING file */ 353 354 ret->init = byahoo_init; 354 355 -
query.c
r6a78c0e r6738a67 103 103 int count = 0; 104 104 105 if(!ic) 106 return; 107 105 108 q = irc->queries; 106 109 def = query_default( irc ); … … 145 148 else 146 149 irc_usermsg( irc, "Accepted: %s", q->question ); 147 q->yes( q->data ); 150 if( q->yes ) 151 q->yes( q->data ); 148 152 } 149 153 else … … 153 157 else 154 158 irc_usermsg( irc, "Rejected: %s", q->question ); 155 q->no( q->data ); 159 if( q->no ) 160 q->no( q->data ); 156 161 } 157 162 q->data = NULL; -
root_commands.c
r6a78c0e r6738a67 29 29 #include "bitlbee.h" 30 30 #include "help.h" 31 #include "otr.h" 31 32 32 33 #include <string.h> … … 275 276 276 277 irc_usermsg( irc, "Account successfully added" ); 278 279 if(otr_check_for_key(a)) { 280 irc_usermsg(irc, "otr: you will be notified when it completes"); 281 } 277 282 } 278 283 else if( g_strcasecmp( cmd[1], "del" ) == 0 ) … … 1064 1069 { "qlist", 0, cmd_qlist, 0 }, 1065 1070 { "join_chat", 2, cmd_join_chat, 0 }, 1071 { "otr", 1, cmd_otr, 0 }, 1066 1072 { NULL } 1067 1073 }; -
set.c
r6a78c0e r6738a67 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; 231 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'); 357 } 358 359 /* possible values: never, opportunistic, manual, always */ 360 char *set_eval_otr_policy( set_t *set, char *value ) 361 { 362 if ( !strcmp(value, "never") ) 363 return value; 364 if ( !strcmp(value, "opportunistic") ) 365 return value; 366 if ( !strcmp(value, "manual") ) 367 return value; 368 if ( !strcmp(value, "always") ) 369 return value; 370 return NULL; 371 } -
set.h
r6a78c0e r6738a67 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 ); 103 char *set_eval_otr_policy( set_t *set, char *value ); 99 104 100 105 #endif /* __SET_H__ */ -
storage.c
r6a78c0e r6738a67 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
r6a78c0e r6738a67 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" 31 32 #include "ipc.h" 33 #include "lib/ssl_client.h" 32 34 #include <signal.h> 33 35 #include <unistd.h> … … 54 56 b_main_init(); 55 57 nogaim_init(); 58 /* Ugly Note: libotr and gnutls both use libgcrypt. libgcrypt 59 has a process-global config state whose initialization happpens 60 twice if libotr and gnutls are used together. libotr installs custom 61 memory management functions for libgcrypt while our gnutls module 62 uses the defaults. Therefore we initialize OTR after SSL. *sigh* */ 63 ssl_init(); 64 otr_init(); 56 65 57 66 srand( time( NULL ) ^ getpid() ); -
user.c
r6a78c0e r6738a67 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
r6a78c0e r6738a67 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.