Changeset 8661caa
- Timestamp:
- 2008-08-04T14:45:24Z (16 years ago)
- Branches:
- master
- Children:
- 87f525e
- Parents:
- 4ac647d (diff), 718e05f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 4 added
- 37 edited
Legend:
- Unmodified
- Added
- Removed
-
.bzrignore
r4ac647d r8661caa 17 17 *.gcno 18 18 *.o 19 coverage 20 bitlbee.info 21 bitlbee.exe -
Makefile
r4ac647d r8661caa 10 10 11 11 # Program variables 12 objects = account.o bitlbee.o c onf.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.ouser.o dcc.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 dcc.hlib/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 protocols/ft.h12 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 dcc.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.h protocols/ft.h 14 14 subdirs = lib protocols 15 16 ifeq ($(TARGET),i586-mingw32msvc) 17 objects += win32.o 18 LFLAGS+=-lws2_32 19 EFLAGS+=-lsecur32 20 OUTFILE=bitlbee.exe 21 else 22 objects += unix.o conf.o log.o 23 OUTFILE=bitlbee 24 endif 15 25 16 26 # Expansion of variables -
bitlbee.c
r4ac647d r8661caa 118 118 119 119 if( global.conf->runmode == RUNMODE_FORKDAEMON ) 120 ipc_master_load_state( );120 ipc_master_load_state( getenv( "_BITLBEE_RESTART_STATE" ) ); 121 121 122 122 if( global.conf->runmode == RUNMODE_DAEMON || global.conf->runmode == RUNMODE_FORKDAEMON ) 123 123 ipc_master_listen_socket(); 124 124 125 #ifndef _WIN32 125 126 if( ( fp = fopen( global.conf->pidfile, "w" ) ) ) 126 127 { … … 132 133 log_message( LOGLVL_WARNING, "Warning: Couldn't write PID to `%s'", global.conf->pidfile ); 133 134 } 135 #endif 134 136 135 137 return( 0 ); … … 140 142 if( !irc_new( 0 ) ) 141 143 return( 1 ); 142 143 log_link( LOGLVL_ERROR, LOGOUTPUT_IRC );144 log_link( LOGLVL_WARNING, LOGOUTPUT_IRC );145 144 146 145 return( 0 ); … … 254 253 struct sockaddr_in conn_info; 255 254 int new_socket = accept( global.listen_socket, (struct sockaddr *) &conn_info, &size ); 256 pid_t client_pid = 0;257 255 258 256 if( new_socket == -1 ) … … 262 260 } 263 261 262 #ifndef _WIN32 264 263 if( global.conf->runmode == RUNMODE_FORKDAEMON ) 265 264 { 265 pid_t client_pid = 0; 266 266 int fds[2]; 267 267 … … 320 320 } 321 321 else 322 #endif 322 323 { 323 324 log_message( LOGLVL_INFO, "Creating new connection with fd %d.", new_socket ); -
bitlbee.h
r4ac647d r8661caa 29 29 #define _GNU_SOURCE /* Stupid GNU :-P */ 30 30 31 /* Depend on Windows 2000 for now since we need getaddrinfo() */ 32 #define _WIN32_WINNT 0x0501 33 31 34 #define PACKAGE "BitlBee" 32 #define BITLBEE_VERSION "1.2 "35 #define BITLBEE_VERSION "1.2.1" 33 36 #define VERSION BITLBEE_VERSION 34 37 … … 48 51 #include <stdio.h> 49 52 #include <ctype.h> 53 #include <errno.h> 54 50 55 #ifndef _WIN32 51 56 #include <syslog.h> 52 #include <errno.h>53 57 #endif 54 58 … … 94 98 #undef g_main_quit 95 99 #define g_main_quit __PLEASE_USE_B_MAIN_QUIT__ 96 97 #ifndef F_OK98 #define F_OK 099 #endif100 100 101 101 #ifndef G_GNUC_MALLOC -
conf.c
r4ac647d r8661caa 79 79 } 80 80 81 while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:h R:u:" ) ) >= 0 )81 while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hu:" ) ) >= 0 ) 82 82 /* ^^^^ Just to make sure we skip this step from the REHASH handler. */ 83 83 { … … 146 146 " -h Show this help page.\n" ); 147 147 return NULL; 148 }149 else if( opt == 'R' )150 {151 /* We can't load the statefile yet (and should make very sure we do this152 only once), so set the filename here and load the state information153 when initializing ForkDaemon. (This option only makes sense in that154 mode anyway!) */155 ipc_master_set_statefile( optarg );156 148 } 157 149 else if( opt == 'u' ) -
configure
r4ac647d r8661caa 20 20 ipcsocket='/var/run/bitlbee.sock' 21 21 pcdir='$prefix/lib/pkgconfig' 22 systemlibdirs="/lib /usr/lib /usr/local/lib" 22 23 23 24 msn=1 … … 74 75 --ssl=... SSL library to use (gnutls, nss, openssl, bogus, auto) 75 76 $ssl 77 78 --target=... Cross compilation target same as host 76 79 EOF 77 80 exit; … … 107 110 PCDIR=$pcdir 108 111 112 TARGET=$target 109 113 ARCH=$arch 110 114 CPU=$cpu 111 OUTFILE=bitlbee112 115 113 116 DESTDIR= … … 132 135 EOF 133 136 137 138 139 if [ -n "$target" ]; then 140 PKG_CONFIG_LIBDIR=/usr/$target/lib/pkgconfig 141 export PKG_CONFIG_LIBDIR 142 PATH=/usr/$target/bin:$PATH 143 CC=$target-cc 144 LD=$target-ld 145 systemlibdirs="/usr/$target/lib" 146 fi 147 148 134 149 if [ "$debug" = "1" ]; then 135 150 [ -z "$CFLAGS" ] && CFLAGS=-g … … 158 173 echo "CC=$CC" >> Makefile.settings; 159 174 160 if [ -n "$LD" ]; then 161 echo "LD=$LD" >> Makefile.settings; 162 elif type ld > /dev/null 2> /dev/null; then 163 echo "LD=ld" >> Makefile.settings; 164 else 165 echo 'Cannot find ld, aborting.' 166 exit 1; 167 fi 175 if [ -z "$LD" ]; then 176 if type ld > /dev/null 2> /dev/null; then 177 LD=ld 178 else 179 echo 'Cannot find ld, aborting.' 180 exit 1; 181 fi 182 fi 183 184 echo "LD=$LD" >> Makefile.settings 168 185 169 186 if [ -z "$PKG_CONFIG" ]; then … … 213 230 detect_gnutls() 214 231 { 215 if libgnutls-config --version > /dev/null 2> /dev/null; then 232 if $PKG_CONFIG --exists gnutls; then 233 cat <<EOF>>Makefile.settings 234 EFLAGS+=`$PKG_CONFIG --libs gnutls` 235 CFLAGS+=`$PKG_CONFIG --cflags gnutls` 236 EOF 237 ssl=gnutls 238 ret=1 239 elif libgnutls-config --version > /dev/null 2> /dev/null; then 216 240 cat <<EOF>>Makefile.settings 217 241 EFLAGS+=`libgnutls-config --libs` … … 267 291 elif [ "$ssl" = "nss" ]; then 268 292 detect_nss 293 elif [ "$ssl" = "sspi" ]; then 294 echo 269 295 elif [ "$ssl" = "openssl" ]; then 270 296 echo … … 323 349 echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings 324 350 325 for i in /lib /usr/lib /usr/local/lib; do351 for i in $systemlibdirs; do 326 352 if [ -f $i/libresolv.a ]; then 327 353 echo '#define HAVE_RESOLV_A' >> config.h … … 375 401 376 402 if [ "$gcov" = "1" ]; then 377 echo "CFLAGS+=- ftest-coverage -fprofile-arcs" >> Makefile.settings378 echo "EFLAGS+=- lgcov" >> Makefile.settings403 echo "CFLAGS+=--coverage" >> Makefile.settings 404 echo "EFLAGS+=--coverage" >> Makefile.settings 379 405 fi 380 406 … … 483 509 echo 'Cygwin is not officially supported.' 484 510 ;; 511 Windows ) 512 ;; 485 513 * ) 486 514 echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.' … … 489 517 esac 490 518 519 if [ -n "$target" ]; then 520 echo "Cross-compiling for: $target" 521 fi 522 491 523 echo 492 524 echo 'Configuration done:' -
debian/bitlbee.init
r4ac647d r8661caa 44 44 45 45 start-stop-daemon --start --quiet --pidfile $PIDFILE \ 46 -c bitlbee: \47 46 --exec $DAEMON -- -p $BITLBEE_PORT -P $PIDFILE $BITLBEE_OPTS 48 47 } -
debian/changelog
r4ac647d r8661caa 1 bitlbee (1.2-6) UNRELEASED; urgency=low 2 3 * Add Homepage and Vcs-Bzr fields. 4 5 -- Jelmer Vernooij <jelmer@samba.org> Sun, 11 May 2008 14:18:16 +0200 6 7 bitlbee (1.2-5) unstable; urgency=low 8 9 * Add myself to uploaders. 10 * Bump standards version to 3.8.0. 11 * Fix FSF address. 12 * Avoid changing uid from init script. (Closes: #474589) 13 14 -- Jelmer Vernooij <jelmer@samba.org> Mon, 16 Jun 2008 00:53:20 +0200 15 1 16 bitlbee (1.2-4) unstable; urgency=low 2 17 -
debian/control
r4ac647d r8661caa 3 3 Priority: optional 4 4 Maintainer: Wilmer van der Gaast <wilmer@gaast.net> 5 Standards-Version: 3.5.9 5 Uploaders: Jelmer Vernooij <jelmer@samba.org> 6 Standards-Version: 3.8.0 6 7 Build-Depends: libglib2.0-dev (>= 2.4), libevent-dev, libgnutls-dev | libnss-dev (>= 1.6), debconf-2.0, po-debconf 8 Homepage: http://www.bitlbee.org/ 9 Vcs-Bzr: http://code.bitlbee.org/bitlbee/ 10 DM-Upload-Allowed: yes 7 11 8 12 Package: bitlbee -
debian/copyright
r4ac647d r8661caa 26 26 You should have received a copy of the GNU General Public License with 27 27 the Debian GNU/Linux distribution in file /usr/share/common-licenses/GPL; 28 if not, write to the Free Software Foundation, Inc., 5 9 Temple Place,29 Suite 330, Boston, MA 02111-1307 USA28 if not, write to the Free Software Foundation, Inc., 51 Franklin St, 29 Fifth Floor, Boston, MA 02110-1301, USA. 30 30 ============================================================================ 31 31 … … 40 40 41 41 Copyright (C) 2000 Free Software Foundation, Inc. 42 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA42 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 43 43 Everyone is permitted to copy and distribute verbatim copies 44 44 of this license document, but changing it is not allowed. -
debian/rules
r4ac647d r8661caa 22 22 [ "`whoami`" = "root" -a -d debian ] 23 23 rm -rf build-arch-stamp debian/bitlbee debian/*.substvars debian/files debian/bitlbee-dev 24 -$(MAKE) distclean24 $(MAKE) distclean 25 25 # -$(MAKE) -C doc/ clean 26 26 -
doc/CHANGES
r4ac647d r8661caa 1 This ChangeLog mostly lists changes relevant to users. A full log can be 2 found in the bzr commit logs, for example you can try: 3 4 http://bugs.bitlbee.org/bitlbee/timeline?daysback=90&changeset=on 5 1 6 Version 1.2.1: 2 7 - Fixed proxy support. … … 10 15 password in your IRC client. 11 16 - Compatible with all crazy kinds of line endings that clients can send. 12 13 Finished ... 17 - Changed root nicknames are now saved. 18 - Added ClientInterface setting to bind() outgoing connections to a specific 19 network interface. 20 - Support for receiving Jabber chatroom invitations. 21 - Relaxed port restriction of the Jabber module: added ports 80 and 443. 22 - Preserving case in Jabber resources of buddies, since these should 23 officially be treated as case sensitive. 24 - Fully stripping spaces from AIM screennames, this didn't happen completely 25 which severly breaks the IRC protocol. 26 - Removed all the yellow tape around daemon mode, it's pretty mature by now: 27 testing.bitlbee.org serves all (~30) SSL users from one daemon mode 28 process without any serious stability issues. 29 - Fixed GLib <2.6 compatibility issue. 30 - Misc. memory leak/crash fixes. 31 32 Finished 24 Jun 2008 14 33 15 34 Version 1.2: -
ipc.c
r4ac647d r8661caa 33 33 34 34 GSList *child_list = NULL; 35 static char *statefile = NULL;36 35 37 36 static void ipc_master_cmd_client( irc_t *data, char **cmd ) … … 63 62 } 64 63 64 static void ipc_master_cmd_deaf( irc_t *data, char **cmd ) 65 { 66 if( global.conf->runmode == RUNMODE_DAEMON ) 67 { 68 b_event_remove( global.listen_watch_source_id ); 69 close( global.listen_socket ); 70 71 global.listen_socket = global.listen_watch_source_id = -1; 72 73 ipc_to_children_str( "OPERMSG :Closed listening socket, waiting " 74 "for all users to disconnect." ); 75 } 76 else 77 { 78 ipc_to_children_str( "OPERMSG :The DEAF command only works in " 79 "normal daemon mode. Try DIE instead." ); 80 } 81 } 82 65 83 void ipc_master_cmd_rehash( irc_t *data, char **cmd ) 66 84 { … … 98 116 { "hello", 0, ipc_master_cmd_client, 0 }, 99 117 { "die", 0, ipc_master_cmd_die, 0 }, 118 { "deaf", 0, ipc_master_cmd_deaf, 0 }, 100 119 { "wallops", 1, NULL, IPC_CMD_TO_CHILDREN }, 101 120 { "wall", 1, NULL, IPC_CMD_TO_CHILDREN }, … … 209 228 } 210 229 230 /* Return just one line. Returns NULL if something broke, an empty string 231 on temporary "errors" (EAGAIN and friends). */ 211 232 static char *ipc_readline( int fd ) 212 233 { 213 char *buf, *eol;234 char buf[513], *eol; 214 235 int size; 215 216 buf = g_new0( char, 513 );217 236 218 237 /* Because this is internal communication, it should be pretty safe … … 221 240 sockets and limites message length, messages should always be 222 241 complete. Saves us quite a lot of code and buffering. */ 223 size = recv( fd, buf, 512, MSG_PEEK );242 size = recv( fd, buf, sizeof( buf ) - 1, MSG_PEEK ); 224 243 if( size == 0 || ( size < 0 && !sockerr_again() ) ) 225 244 return NULL; … … 229 248 buf[size] = 0; 230 249 231 eol = strstr( buf, "\r\n" ); 232 if( eol == NULL ) 250 if( ( eol = strstr( buf, "\r\n" ) ) == NULL ) 233 251 return NULL; 234 252 else 235 253 size = eol - buf + 2; 236 237 g_free( buf );238 buf = g_new0( char, size + 1 );239 254 240 255 if( recv( fd, buf, size, 0 ) != size ) 241 256 return NULL; 242 257 else 243 buf[size-2] = 0; 244 245 return buf; 258 return g_strndup( buf, size - 2 ); 246 259 } 247 260 … … 254 267 cmd = irc_parse_line( buf ); 255 268 if( cmd ) 269 { 256 270 ipc_command_exec( data, cmd, ipc_master_commands ); 271 g_free( cmd ); 272 } 273 g_free( buf ); 257 274 } 258 275 else … … 272 289 cmd = irc_parse_line( buf ); 273 290 if( cmd ) 291 { 274 292 ipc_command_exec( data, cmd, ipc_child_commands ); 293 g_free( cmd ); 294 } 295 g_free( buf ); 275 296 } 276 297 else … … 439 460 } 440 461 462 #ifndef _WIN32 441 463 char *ipc_master_save_state() 442 464 { … … 479 501 } 480 502 481 void ipc_master_set_statefile( char *fn )482 {483 statefile = g_strdup( fn );484 }485 486 503 487 504 static gboolean new_ipc_client( gpointer data, gint serversock, b_input_condition cond ) … … 504 521 } 505 522 506 #ifndef _WIN32507 523 int ipc_master_listen_socket() 508 524 { … … 541 557 } 542 558 #else 559 int ipc_master_listen_socket() 560 { 543 561 /* FIXME: Open named pipe \\.\BITLBEE */ 562 return 0; 563 } 544 564 #endif 545 565 546 int ipc_master_load_state( )566 int ipc_master_load_state( char *statefile ) 547 567 { 548 568 struct bitlbee_child *child; … … 552 572 if( statefile == NULL ) 553 573 return 0; 574 554 575 fp = fopen( statefile, "r" ); 555 576 unlink( statefile ); /* Why do it later? :-) */ -
ipc.h
r4ac647d r8661caa 58 58 59 59 char *ipc_master_save_state(); 60 void ipc_master_set_statefile( char *fn ); 61 int ipc_master_load_state(); 60 int ipc_master_load_state( char *statefile ); 62 61 int ipc_master_listen_socket(); 63 62 -
irc.c
r4ac647d r8661caa 26 26 #define BITLBEE_CORE 27 27 #include "bitlbee.h" 28 #include "sock.h" 28 29 #include "crypting.h" 29 30 #include "ipc.h" … … 315 316 g_free( irc ); 316 317 317 if( global.conf->runmode == RUNMODE_INETD || global.conf->runmode == RUNMODE_FORKDAEMON ) 318 if( global.conf->runmode == RUNMODE_INETD || 319 global.conf->runmode == RUNMODE_FORKDAEMON || 320 ( global.conf->runmode == RUNMODE_DAEMON && 321 global.listen_socket == -1 && 322 irc_connection_list == NULL ) ) 318 323 b_main_quit(); 319 324 } -
irc_commands.c
r4ac647d r8661caa 626 626 { "completions", 0, irc_cmd_completions, IRC_CMD_LOGGED_IN }, 627 627 { "die", 0, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, 628 { "deaf", 0, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, 628 629 { "wallops", 1, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, 629 630 { "wall", 1, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, -
lib/misc.c
r4ac647d r8661caa 60 60 strcpy(text, text2); 61 61 g_free(text2); 62 }63 64 char *normalize(const char *s)65 {66 static char buf[BUF_LEN];67 char *t, *u;68 int x = 0;69 70 g_return_val_if_fail((s != NULL), NULL);71 72 u = t = g_strdup(s);73 74 strcpy(t, s);75 g_strdown(t);76 77 while (*t && (x < BUF_LEN - 1)) {78 if (*t != ' ') {79 buf[x] = *t;80 x++;81 }82 t++;83 }84 buf[x] = '\0';85 g_free(u);86 return buf;87 62 } 88 63 … … 398 373 void random_bytes( unsigned char *buf, int count ) 399 374 { 375 #ifndef _WIN32 400 376 static int use_dev = -1; 401 377 … … 447 423 448 424 if( !use_dev ) 425 #endif 449 426 { 450 427 int i; … … 607 584 md5_byte_t pass_md5[16]; 608 585 md5_state_t md5_state; 609 int ret, i; 610 611 if( base64_decode( hash, &pass_dec ) != 21 ) 612 { 613 ret = -1; 614 } 615 else 586 int ret = -1, i; 587 588 if( base64_decode( hash, &pass_dec ) == 21 ) 616 589 { 617 590 md5_init( &md5_state ); -
lib/misc.h
r4ac647d r8661caa 41 41 G_MODULE_EXPORT char *add_cr( char *text ); 42 42 G_MODULE_EXPORT char *strip_newlines(char *source); 43 G_MODULE_EXPORT char *normalize( const char *s );44 43 45 44 G_MODULE_EXPORT time_t get_time( int year, int month, int day, int hour, int min, int sec ); -
lib/ssl_bogus.c
r4ac647d r8661caa 61 61 return GAIM_INPUT_READ; 62 62 } 63 64 int ssl_pending( void *conn ) 65 { 66 return 0; 67 } -
nick.c
r4ac647d r8661caa 47 47 48 48 store_handle = clean_handle( handle ); 49 store_nick[MAX_NICK_LENGTH] = 0; 49 50 strncpy( store_nick, nick, MAX_NICK_LENGTH ); 50 51 nick_strip( store_nick ); -
protocols/jabber/jabber.c
r4ac647d r8661caa 33 33 #include "jabber.h" 34 34 #include "md5.h" 35 #include "base64.h"36 35 37 36 GSList *jabber_connections; 38 37 38 /* First enty is the default */ 39 static const int jabber_port_list[] = { 40 5222, 41 5223, 42 5220, 43 5221, 44 5224, 45 5225, 46 5226, 47 5227, 48 5228, 49 5229, 50 80, 51 443, 52 0 53 }; 54 39 55 static void jabber_init( account_t *acc ) 40 56 { 41 57 set_t *s; 42 43 s = set_add( &acc->set, "port", JABBER_PORT_DEFAULT, set_eval_int, acc ); 58 char str[16]; 59 60 g_snprintf( str, sizeof( str ), "%d", jabber_port_list[0] ); 61 s = set_add( &acc->set, "port", str, set_eval_int, acc ); 44 62 s->flags |= ACC_SET_OFFLINE_ONLY; 45 63 … … 74 92 struct ns_srv_reply *srv = NULL; 75 93 char *connect_to, *s; 94 int i; 76 95 77 96 /* For now this is needed in the _connected() handlers if using … … 179 198 imcb_log( ic, "Connecting" ); 180 199 181 if( set_getint( &acc->set, "port" ) < JABBER_PORT_MIN || 182 set_getint( &acc->set, "port" ) > JABBER_PORT_MAX ) 183 { 184 imcb_log( ic, "Incorrect port number, must be in the %d-%d range", 185 JABBER_PORT_MIN, JABBER_PORT_MAX ); 200 for( i = 0; jabber_port_list[i] > 0; i ++ ) 201 if( set_getint( &acc->set, "port" ) == jabber_port_list[i] ) 202 break; 203 204 if( jabber_port_list[i] == 0 ) 205 { 206 imcb_log( ic, "Illegal port number" ); 186 207 imc_logout( ic, FALSE ); 187 208 return; … … 221 242 } 222 243 244 /* This generates an unfinished md5_state_t variable. Every time we generate 245 an ID, we finish the state by adding a sequence number and take the hash. */ 223 246 static void jabber_generate_id_hash( struct jabber_data *jd ) 224 247 { 225 md5_state_t id_hash; 226 md5_byte_t binbuf[16]; 248 md5_byte_t binbuf[4]; 227 249 char *s; 228 250 229 md5_init( & id_hash);230 md5_append( & id_hash, (unsigned char *) jd->username, strlen( jd->username ) );231 md5_append( & id_hash, (unsigned char *) jd->server, strlen( jd->server ) );251 md5_init( &jd->cached_id_prefix ); 252 md5_append( &jd->cached_id_prefix, (unsigned char *) jd->username, strlen( jd->username ) ); 253 md5_append( &jd->cached_id_prefix, (unsigned char *) jd->server, strlen( jd->server ) ); 232 254 s = set_getstr( &jd->ic->acc->set, "resource" ); 233 md5_append( &id_hash, (unsigned char *) s, strlen( s ) ); 234 random_bytes( binbuf, 16 ); 235 md5_append( &id_hash, binbuf, 16 ); 236 md5_finish( &id_hash, binbuf ); 237 238 s = base64_encode( binbuf, 9 ); 239 jd->cached_id_prefix = g_strdup_printf( "%s%s", JABBER_CACHED_ID, s ); 240 g_free( s ); 255 md5_append( &jd->cached_id_prefix, (unsigned char *) s, strlen( s ) ); 256 random_bytes( binbuf, 4 ); 257 md5_append( &jd->cached_id_prefix, binbuf, 4 ); 241 258 } 242 259 … … 281 298 xt_free( jd->xt ); 282 299 283 g_free( jd->cached_id_prefix );284 300 g_free( jd->away_message ); 285 301 g_free( jd->username ); -
protocols/jabber/jabber.h
r4ac647d r8661caa 94 94 char *away_message; 95 95 96 char *cached_id_prefix;96 md5_state_t cached_id_prefix; 97 97 GHashTable *node_cache; 98 98 GHashTable *buddies; … … 177 177 178 178 #define JABBER_XMLCONSOLE_HANDLE "xmlconsole" 179 180 #define JABBER_PORT_DEFAULT "5222"181 #define JABBER_PORT_MIN 5220182 #define JABBER_PORT_MAX 5229183 179 184 180 /* Prefixes to use for packet IDs (mainly for IQ packets ATM). Usually the -
protocols/jabber/jabber_util.c
r4ac647d r8661caa 23 23 24 24 #include "jabber.h" 25 #include "md5.h" 26 #include "base64.h" 25 27 26 28 static unsigned int next_id = 1; … … 138 140 struct jabber_data *jd = ic->proto_data; 139 141 struct jabber_cache_entry *entry = g_new0( struct jabber_cache_entry, 1 ); 140 char *id; 141 142 id = g_strdup_printf( "%s%05x", jd->cached_id_prefix, ( next_id++ ) & 0xfffff ); 142 md5_state_t id_hash; 143 md5_byte_t id_sum[16]; 144 char *id, *asc_hash; 145 146 next_id ++; 147 148 id_hash = jd->cached_id_prefix; 149 md5_append( &id_hash, (md5_byte_t*) &next_id, sizeof( next_id ) ); 150 md5_finish( &id_hash, id_sum ); 151 asc_hash = base64_encode( id_sum, 12 ); 152 153 id = g_strdup_printf( "%s%s", JABBER_CACHED_ID, asc_hash ); 143 154 xt_add_attr( node, "id", id ); 144 155 g_free( id ); 156 g_free( asc_hash ); 145 157 146 158 entry->node = node; … … 188 200 189 201 if( ( s = xt_find_attr( node, "id" ) ) == NULL || 190 strncmp( s, jd->cached_id_prefix, strlen( jd->cached_id_prefix) ) != 0 )202 strncmp( s, JABBER_CACHED_ID, strlen( JABBER_CACHED_ID ) ) != 0 ) 191 203 { 192 204 /* Silently ignore it, without an ID (or a non-cache … … 200 212 if( entry == NULL ) 201 213 { 214 /* 215 There's no longer an easy way to see if we generated this 216 one or someone else, and there's a ten-minute timeout anyway, 217 so meh. 218 202 219 imcb_log( ic, "Warning: Received %s-%s packet with unknown/expired ID %s!", 203 220 node->name, xt_find_attr( node, "type" ) ? : "(no type)", s ); 221 */ 204 222 } 205 223 else if( entry->func ) … … 294 312 len = strlen( orig ); 295 313 new = g_new( char, len + 1 ); 296 for( i = 0; i < len; i ++ ) 297 { 298 /* don't normalize the resource */ 299 if( orig[i] == '/' ) 300 break; 314 315 /* So it turns out the /resource part is case sensitive. Yeah, and 316 it's Unicode but feck Unicode. :-P So stop once we see a slash. */ 317 for( i = 0; i < len && orig[i] != '/' ; i ++ ) 301 318 new[i] = tolower( orig[i] ); 302 } 303 for( ; i < len; i ++ ) 319 for( ; orig[i]; i ++ ) 304 320 new[i] = orig[i]; 305 321 … … 345 361 { 346 362 /* Check for dupes. */ 347 if( g_strcasecmp( bi->resource, s + 1 ) == 0 )363 if( strcmp( bi->resource, s + 1 ) == 0 ) 348 364 { 349 365 *s = '/'; … … 398 414 if( ( s = strchr( jid, '/' ) ) ) 399 415 { 400 int none_found= 0;416 int bare_exists = 0; 401 417 402 418 *s = 0; … … 421 437 /* See if there's an exact match. */ 422 438 for( ; bud; bud = bud->next ) 423 if( g_strcasecmp( bud->resource, s + 1 ) == 0 )439 if( strcmp( bud->resource, s + 1 ) == 0 ) 424 440 break; 425 441 } 426 442 else 427 443 { 428 /* This hack is there to make sure that O_CREAT will 429 work if there's already another resouce present 430 for this JID, even if it's an unknown buddy. This 431 is done to handle conferences properly. */ 432 none_found = 1; 433 /* TODO(wilmer): Find out what I was thinking when I 434 wrote this??? And then fix it. This makes me sad... */ 435 } 436 437 if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && ( imcb_find_buddy( ic, jid ) || !none_found ) ) 444 /* This variable tells the if down here that the bare 445 JID already exists and we should feel free to add 446 more resources, if the caller asked for that. */ 447 bare_exists = 1; 448 } 449 450 if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && 451 ( !bare_exists || imcb_find_buddy( ic, jid ) ) ) 438 452 { 439 453 *s = '/'; … … 460 474 /* We want an exact match, so in thise case there shouldn't be a /resource. */ 461 475 return NULL; 462 else if( ( bud->resource == NULL || bud->next == NULL ))476 else if( bud->resource == NULL || bud->next == NULL ) 463 477 /* No need for selection if there's only one option. */ 464 478 return bud; … … 536 550 matches), removing it is simple. (And the hash reference 537 551 should be removed too!) */ 538 if( bud->next == NULL && ( ( s == NULL || bud->resource == NULL ) || g_strcasecmp( bud->resource, s + 1 ) == 0 ) ) 552 if( bud->next == NULL && 553 ( ( s == NULL && bud->resource == NULL ) || 554 ( bud->resource && s && strcmp( bud->resource, s + 1 ) == 0 ) ) ) 539 555 { 540 556 g_hash_table_remove( jd->buddies, bud->bare_jid ); … … 559 575 { 560 576 for( bi = bud, prev = NULL; bi; bi = (prev=bi)->next ) 561 if( g_strcasecmp( bi->resource, s + 1 ) == 0 )577 if( strcmp( bi->resource, s + 1 ) == 0 ) 562 578 break; 563 579 -
protocols/jabber/message.c
r4ac647d r8661caa 49 49 { 50 50 GString *fullmsg = g_string_new( "" ); 51 52 for( c = node->children; ( c = xt_find_node( c, "x" ) ); c = c->next ) 53 { 54 char *ns = xt_find_attr( c, "xmlns" ), *room; 55 struct xt_node *inv, *reason; 56 57 if( strcmp( ns, XMLNS_MUC_USER ) == 0 && 58 ( inv = xt_find_node( c->children, "invite" ) ) ) 59 { 60 room = from; 61 from = xt_find_attr( inv, "from" ) ? : from; 62 63 g_string_append_printf( fullmsg, "<< \002BitlBee\002 - Invitation to chatroom %s >>\n", room ); 64 if( ( reason = xt_find_node( inv->children, "reason" ) ) && reason->text_len > 0 ) 65 g_string_append( fullmsg, reason->text ); 66 } 67 } 51 68 52 69 if( ( s = strchr( from, '/' ) ) ) -
protocols/msn/ns.c
r4ac647d r8661caa 278 278 if( num_parts == 5 ) 279 279 { 280 int i, groupcount; 281 282 groupcount = atoi( cmd[4] ); 283 if( groupcount > 0 ) 284 { 285 /* valgrind says this is leaking memory, I'm guessing 286 that this happens during server redirects. */ 287 if( md->grouplist ) 288 { 289 for( i = 0; i < md->groupcount; i ++ ) 290 g_free( md->grouplist[i] ); 291 g_free( md->grouplist ); 292 } 293 294 md->groupcount = groupcount; 295 md->grouplist = g_new0( char *, md->groupcount ); 296 } 297 280 298 md->buddycount = atoi( cmd[3] ); 281 md->groupcount = atoi( cmd[4] );282 if( md->groupcount > 0 )283 md->grouplist = g_new0( char *, md->groupcount );284 285 299 if( !*cmd[3] || md->buddycount == 0 ) 286 300 msn_logged_in( ic ); … … 665 679 imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); 666 680 } 681 682 g_free( inbox ); 683 g_free( folders ); 667 684 } 668 685 else if( g_strncasecmp( ct, "text/x-msmsgsemailnotification", 30 ) == 0 ) -
protocols/nogaim.h
r4ac647d r8661caa 45 45 #include "md5.h" 46 46 #include "ft.h" 47 48 #define BUF_LEN MSG_LEN49 #define BUF_LONG ( BUF_LEN * 2 )50 #define MSG_LEN 204851 #define BUF_LEN MSG_LEN52 47 53 48 #define BUDDY_ALIAS_MAXLEN 388 /* because MSN names can be 387 characters */ -
protocols/oscar/oscar.c
r4ac647d r8661caa 60 60 61 61 #define OSCAR_GROUP "Friends" 62 63 #define BUF_LEN 2048 64 #define BUF_LONG ( BUF_LEN * 2 ) 62 65 63 66 /* Don't know if support for UTF8 is really working. For now it's UTF16 here. … … 240 243 }; 241 244 static int msgerrreasonlen = 25; 245 246 /* Hurray, this function is NOT thread-safe \o/ */ 247 static char *normalize(const char *s) 248 { 249 static char buf[BUF_LEN]; 250 char *t, *u; 251 int x = 0; 252 253 g_return_val_if_fail((s != NULL), NULL); 254 255 u = t = g_strdup(s); 256 257 strcpy(t, s); 258 g_strdown(t); 259 260 while (*t && (x < BUF_LEN - 1)) { 261 if (*t != ' ' && *t != '!') { 262 buf[x] = *t; 263 x++; 264 } 265 t++; 266 } 267 buf[x] = '\0'; 268 g_free(u); 269 return buf; 270 } 242 271 243 272 static gboolean oscar_callback(gpointer data, gint source, … … 1002 1031 } 1003 1032 1004 tmp = g_strdup(normalize(ic->acc->user)); 1005 if (!strcmp(tmp, normalize(info->sn))) 1033 if (!aim_sncmp(ic->acc->user, info->sn)) 1006 1034 g_snprintf(ic->displayname, sizeof(ic->displayname), "%s", info->sn); 1007 g_free(tmp); 1008 1009 imcb_buddy_status(ic, info->sn, flags, state_string, NULL); 1010 /* imcb_buddy_times(ic, info->sn, signon, time_idle); */ 1035 1036 tmp = normalize(info->sn); 1037 imcb_buddy_status(ic, tmp, flags, state_string, NULL); 1038 /* imcb_buddy_times(ic, tmp, signon, time_idle); */ 1039 1011 1040 1012 1041 return 1; … … 1022 1051 va_end(ap); 1023 1052 1024 imcb_buddy_status(ic, info->sn, 0, NULL, NULL );1053 imcb_buddy_status(ic, normalize(info->sn), 0, NULL, NULL ); 1025 1054 1026 1055 return 1; … … 1078 1107 1079 1108 strip_linefeed(tmp); 1080 imcb_buddy_msg(ic, userinfo->sn, tmp, flags, 0);1109 imcb_buddy_msg(ic, normalize(userinfo->sn), tmp, flags, 0); 1081 1110 g_free(tmp); 1082 1111 … … 1177 1206 message = g_strdup(args->msg); 1178 1207 strip_linefeed(message); 1179 imcb_buddy_msg(ic, uin, message, 0, 0);1208 imcb_buddy_msg(ic, normalize(uin), message, 0, 0); 1180 1209 g_free(uin); 1181 1210 g_free(message); … … 1196 1225 1197 1226 strip_linefeed(message); 1198 imcb_buddy_msg(ic, uin, message, 0, 0);1227 imcb_buddy_msg(ic, normalize(uin), message, 0, 0); 1199 1228 g_free(uin); 1200 1229 g_free(m); … … 1471 1500 1472 1501 for (i = 0; i < count; i++) 1473 imcb_chat_add_buddy(c->cnv, info[i].sn);1502 imcb_chat_add_buddy(c->cnv, normalize(info[i].sn)); 1474 1503 1475 1504 return 1; … … 1494 1523 1495 1524 for (i = 0; i < count; i++) 1496 imcb_chat_remove_buddy(c->cnv, info[i].sn, NULL);1525 imcb_chat_remove_buddy(c->cnv, normalize(info[i].sn), NULL); 1497 1526 1498 1527 return 1; … … 1545 1574 tmp = g_malloc(BUF_LONG); 1546 1575 g_snprintf(tmp, BUF_LONG, "%s", msg); 1547 imcb_chat_msg(ccon->cnv, info->sn, tmp, 0, 0);1576 imcb_chat_msg(ccon->cnv, normalize(info->sn), tmp, 0, 0); 1548 1577 g_free(tmp); 1549 1578 … … 1758 1787 g_snprintf(sender, sizeof(sender), "%u", msg->sender); 1759 1788 strip_linefeed(dialog_msg); 1760 imcb_buddy_msg(ic, sender, dialog_msg, 0, t);1789 imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t); 1761 1790 g_free(dialog_msg); 1762 1791 } break; … … 1779 1808 1780 1809 strip_linefeed(dialog_msg); 1781 imcb_buddy_msg(ic, sender, dialog_msg, 0, t);1810 imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t); 1782 1811 g_free(dialog_msg); 1783 1812 g_free(m); … … 2017 2046 struct aim_ssi_item *curitem; 2018 2047 int tmp; 2048 char *nrm; 2019 2049 2020 2050 /* Add from server list to local list */ 2021 2051 tmp = 0; 2022 2052 for (curitem=sess->ssi.items; curitem; curitem=curitem->next) { 2053 nrm = curitem->name ? normalize(curitem->name) : NULL; 2054 2023 2055 switch (curitem->type) { 2024 2056 case 0x0000: /* Buddy */ 2025 if ((curitem->name) && (!imcb_find_buddy(ic, curitem->name))) {2057 if ((curitem->name) && (!imcb_find_buddy(ic, nrm))) { 2026 2058 char *realname = NULL; 2027 2059 … … 2029 2061 realname = aim_gettlv_str(curitem->data, 0x0131, 1); 2030 2062 2031 imcb_add_buddy(ic, curitem->name, NULL);2063 imcb_add_buddy(ic, nrm, NULL); 2032 2064 2033 2065 if (realname) { 2034 imcb_buddy_nick_hint(ic, curitem->name, realname);2035 imcb_rename_buddy(ic, curitem->name, realname);2066 imcb_buddy_nick_hint(ic, nrm, realname); 2067 imcb_rename_buddy(ic, nrm, realname); 2036 2068 g_free(realname); 2037 2069 } … … 2045 2077 if (!list) { 2046 2078 char *name; 2047 name = g_strdup(n ormalize(curitem->name));2079 name = g_strdup(nrm); 2048 2080 ic->permit = g_slist_append(ic->permit, name); 2049 2081 tmp++; … … 2058 2090 if (!list) { 2059 2091 char *name; 2060 name = g_strdup(n ormalize(curitem->name));2092 name = g_strdup(nrm); 2061 2093 ic->deny = g_slist_append(ic->deny, name); 2062 2094 tmp++; … … 2120 2152 if( st == 0x00 ) 2121 2153 { 2122 imcb_add_buddy( sess->aux_data, list, NULL );2154 imcb_add_buddy( sess->aux_data, normalize(list), NULL ); 2123 2155 } 2124 2156 else if( st == 0x0E ) … … 2450 2482 if(type2 == 0x0002) { 2451 2483 /* User is typing */ 2452 imcb_buddy_typing(ic, sn, OPT_TYPING);2484 imcb_buddy_typing(ic, normalize(sn), OPT_TYPING); 2453 2485 } 2454 2486 else if (type2 == 0x0001) { 2455 2487 /* User has typed something, but is not actively typing (stale) */ 2456 imcb_buddy_typing(ic, sn, OPT_THINKING);2488 imcb_buddy_typing(ic, normalize(sn), OPT_THINKING); 2457 2489 } 2458 2490 else { 2459 2491 /* User has stopped typing */ 2460 imcb_buddy_typing(ic, sn, 0);2492 imcb_buddy_typing(ic, normalize(sn), 0); 2461 2493 } 2462 2494 -
protocols/yahoo/libyahoo2.c
r4ac647d r8661caa 69 69 #ifdef __MINGW32__ 70 70 # include <winsock2.h> 71 # define write(a,b,c) send(a,b,c,0)72 # define read(a,b,c) recv(a,b,c,0)73 71 #endif 74 72 … … 381 379 382 380 /* call repeatedly to get the next one */ 383 /*384 381 static struct yahoo_input_data * find_input_by_id(int id) 385 382 { … … 392 389 return NULL; 393 390 } 394 */395 391 396 392 static struct yahoo_input_data * find_input_by_id_and_webcam_user(int id, const char * who) … … 797 793 { 798 794 struct yahoo_data *yd = find_conn_by_id(id); 795 799 796 if(!yd) 800 797 return; … … 3166 3163 3167 3164 LOG(("write callback: id=%d fd=%d data=%p", id, fd, data)); 3168 if(!yid || !yid->txqueues )3165 if(!yid || !yid->txqueues || !find_conn_by_id(id)) 3169 3166 return -2; 3170 3167 … … 3842 3839 } 3843 3840 3844 3845 /* do { 3841 do { 3846 3842 yahoo_input_close(yid); 3847 } while((yid = find_input_by_id(id)));*/ 3848 3843 } while((yid = find_input_by_id(id))); 3849 3844 } 3850 3845 -
protocols/yahoo/yahoo.c
r4ac647d r8661caa 163 163 g_slist_free( yd->buddygroups ); 164 164 165 if( yd->logged_in ) 166 yahoo_logoff( yd->y2_id ); 167 else 168 yahoo_close( yd->y2_id ); 165 yahoo_logoff( yd->y2_id ); 169 166 170 167 g_free( yd ); … … 454 451 struct byahoo_write_ready_data *d = data; 455 452 456 if( !byahoo_get_ic_by_id( d->id ) )457 /* WTF doesn't libyahoo clean this up? */458 return FALSE;459 460 453 yahoo_write_ready( d->id, d->fd, d->data ); 461 454 … … 672 665 673 666 imcb_error( ic, "%s", err ); 674 675 if( fatal )676 imc_logout( ic, TRUE );677 667 } 678 668 -
protocols/yahoo/yahoo_httplib.c
r4ac647d r8661caa 51 51 #ifdef __MINGW32__ 52 52 # include <winsock2.h> 53 # define write(a,b,c) send(a,b,c,0)54 # define read(a,b,c) recv(a,b,c,0)55 53 # define snprintf _snprintf 56 54 #endif -
sock.h
r4ac647d r8661caa 16 16 #else 17 17 # include <winsock2.h> 18 # ifndef _MSC_VER 19 # include <ws2tcpip.h> 20 # endif 18 # include <ws2tcpip.h> 21 19 # if !defined(BITLBEE_CORE) && defined(_MSC_VER) 22 20 # pragma comment(lib,"bitlbee.lib") 23 21 # endif 24 22 # include <io.h> 25 # define read(a,b,c) recv(a,b,c,0)26 # define write(a,b,c) send(a,b,c,0)27 # define umask _umask28 # define mode_t int29 23 # define sock_make_nonblocking(fd) { int non_block = 1; ioctlsocket(fd, FIONBIO, &non_block); } 30 24 # define sock_make_blocking(fd) { int non_block = 0; ioctlsocket(fd, FIONBIO, &non_block); } -
storage_text.c
r4ac647d r8661caa 27 27 #include "bitlbee.h" 28 28 #include "crypting.h" 29 #ifdef _WIN32 30 # define umask _umask 31 # define mode_t int 32 #endif 33 34 #ifndef F_OK 35 #define F_OK 0 36 #endif 29 37 30 38 static void text_init (void) -
storage_xml.c
r4ac647d r8661caa 29 29 #include "arc.h" 30 30 #include "md5.h" 31 #include <glib/gstdio.h> 32 33 #if !GLIB_CHECK_VERSION(2,8,0) 34 /* GLib < 2.8.0 doesn't have g_access, so just use the system access(). */ 35 #define g_access access 36 #endif 31 37 32 38 typedef enum … … 243 249 static void xml_init( void ) 244 250 { 245 if( access( global.conf->configdir, F_OK ) != 0 )251 if( g_access( global.conf->configdir, F_OK ) != 0 ) 246 252 log_message( LOGLVL_WARNING, "The configuration directory `%s' does not exist. Configuration won't be saved.", global.conf->configdir ); 247 else if( access( global.conf->configdir, R_OK ) != 0 || access( global.conf->configdir, W_OK ) != 0 ) 253 else if( g_access( global.conf->configdir, F_OK ) != 0 || 254 g_access( global.conf->configdir, W_OK ) != 0 ) 248 255 log_message( LOGLVL_WARNING, "Permission problem: Can't read/write from/to `%s'.", global.conf->configdir ); 249 256 } … … 372 379 g_free( path2 ); 373 380 374 if( !overwrite && access( path, F_OK ) != -1)381 if( !overwrite && g_access( path, F_OK ) == 0 ) 375 382 return STORAGE_ALREADY_EXISTS; 376 383 … … 480 487 static storage_status_t xml_remove( const char *nick, const char *password ) 481 488 { 482 char s[512] ;489 char s[512], *lc; 483 490 storage_status_t status; 484 491 … … 487 494 return status; 488 495 489 g_snprintf( s, 511, "%s%s%s", global.conf->configdir, nick, ".xml" ); 496 lc = g_strdup( nick ); 497 nick_lc( lc ); 498 g_snprintf( s, 511, "%s%s%s", global.conf->configdir, lc, ".xml" ); 499 g_free( lc ); 500 490 501 if( unlink( s ) == -1 ) 491 502 return STORAGE_OTHER_ERROR; -
tests/Makefile
r4ac647d r8661caa 13 13 main_objs = 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_xml.o storage_text.o user.o 14 14 15 test_objs = check.o check_util.o check_nick.o check_md5.o check_arc.o check_irc.o check_help.o check_user.o check_crypting.o check_set.o check_jabber_sasl.o 15 test_objs = check.o check_util.o check_nick.o check_md5.o check_arc.o check_irc.o check_help.o check_user.o check_crypting.o check_set.o check_jabber_sasl.o check_jabber_util.o 16 16 17 17 check: $(test_objs) $(addprefix ../, $(main_objs)) ../protocols/protocols.o ../lib/lib.o -
tests/check.c
r4ac647d r8661caa 69 69 Suite *jabber_sasl_suite(void); 70 70 71 /* From check_jabber_sasl.c */ 72 Suite *jabber_util_suite(void); 73 71 74 int main (int argc, char **argv) 72 75 { … … 115 118 srunner_add_suite(sr, set_suite()); 116 119 srunner_add_suite(sr, jabber_sasl_suite()); 120 srunner_add_suite(sr, jabber_util_suite()); 117 121 if (no_fork) 118 122 srunner_set_fork_status(sr, CK_NOFORK); -
tests/check_jabber_sasl.c
r4ac647d r8661caa 5 5 #include <string.h> 6 6 #include <stdio.h> 7 #include "arc.h"8 7 9 8 char *sasl_get_part( char *data, char *field ); -
unix.c
r4ac647d r8661caa 40 40 static void sighandler( int signal ); 41 41 42 int main( int argc, char *argv[] , char **envp)42 int main( int argc, char *argv[] ) 43 43 { 44 44 int i = 0; … … 60 60 if( global.conf->runmode == RUNMODE_INETD ) 61 61 { 62 log_link( LOGLVL_ERROR, LOGOUTPUT_IRC ); 63 log_link( LOGLVL_WARNING, LOGOUTPUT_IRC ); 64 62 65 i = bitlbee_inetd_init(); 63 66 log_message( LOGLVL_INFO, "Bitlbee %s starting in inetd mode.", BITLBEE_VERSION ); … … 66 69 else if( global.conf->runmode == RUNMODE_DAEMON ) 67 70 { 71 log_link( LOGLVL_ERROR, LOGOUTPUT_SYSLOG ); 72 log_link( LOGLVL_WARNING, LOGOUTPUT_SYSLOG ); 73 68 74 i = bitlbee_daemon_init(); 69 75 log_message( LOGLVL_INFO, "Bitlbee %s starting in daemon mode.", BITLBEE_VERSION ); … … 135 141 { 136 142 char *fn = ipc_master_save_state(); 137 char **args;138 int n, i;139 143 140 144 chdir( old_cwd ); 141 145 142 n = 0; 143 args = g_new0( char *, argc + 3 ); 144 args[n++] = argv[0]; 145 if( fn ) 146 { 147 args[n++] = "-R"; 148 args[n++] = fn; 149 } 150 for( i = 1; argv[i] && i < argc; i ++ ) 151 { 152 if( strcmp( argv[i], "-R" ) == 0 ) 153 i += 2; 154 155 args[n++] = argv[i]; 156 } 146 setenv( "_BITLBEE_RESTART_STATE", fn, 1 ); 147 g_free( fn ); 157 148 158 149 close( global.listen_socket ); 159 150 160 execve( args[0], args, envp ); 151 if( execv( argv[0], argv ) == -1 ) 152 /* Apparently the execve() failed, so let's just 153 jump back into our own/current main(). */ 154 /* Need more cleanup code to make this work. */ 155 return 1; /* main( argc, argv ); */ 161 156 } 162 157 … … 219 214 return( (double) time->tv_sec + (double) time->tv_usec / 1000000 ); 220 215 } 216 217
Note: See TracChangeset
for help on using the changeset viewer.