Changeset ebb95b6


Ignore:
Timestamp:
2007-11-14T23:42:07Z (16 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
50e1776
Parents:
a6df0b5 (diff), 1bf1ae6 (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.
Message:

Merging from devel/Jelmer.

Files:
18 edited

Legend:

Unmodified
Added
Removed
  • bitlbee.c

    ra6df0b5 rebb95b6  
    3838int bitlbee_daemon_init()
    3939{
    40 #ifdef IPV6
    41         int use_ipv6 = 1;
    42         struct sockaddr_in6 listen_addr6;
    43 #endif
    44         struct sockaddr_in listen_addr;
     40        struct addrinfo *res, hints, *addrinfo_bind;
    4541        int i;
    4642        FILE *fp;
     
    4945        log_link( LOGLVL_WARNING, LOGOUTPUT_SYSLOG );
    5046       
    51 #ifdef IPV6
    52         if( ( global.listen_socket = socket( AF_INET6, SOCK_STREAM, 0 ) ) == -1 )
    53         {
    54                 use_ipv6 = 0;
    55 #endif
    56                 global.listen_socket = socket( AF_INET, SOCK_STREAM, 0 );
    57 #ifdef IPV6
    58         }
    59 #endif
    60         if( global.listen_socket == -1 )
    61         {
    62                 log_error( "socket" );
    63                 return( -1 );
    64         }
    65        
    66         /* TIME_WAIT (?) sucks.. */
    67         i = 1;
    68         setsockopt( global.listen_socket, SOL_SOCKET, SO_REUSEADDR, &i, sizeof( i ) );
    69        
    70 #ifdef IPV6
    71         memset( &listen_addr6, 0, sizeof( listen_addr6 ) );
    72         memset( &listen_addr, 0, sizeof( listen_addr ) );
    73         listen_addr6.sin6_family = AF_INET6;
    74         listen_addr6.sin6_port = htons( global.conf->port );
    75         if( ( i = inet_pton( AF_INET6, ipv6_wrap( global.conf->iface ), &listen_addr6.sin6_addr ) ) != 1 )
    76         {
    77                 /* Forget about IPv6 in this function. */
    78                 use_ipv6 = 0;
    79 #endif
    80                 listen_addr.sin_family = AF_INET;
    81                 listen_addr.sin_port = htons( global.conf->port );
    82                 if( strcmp( global.conf->iface, "::" ) == 0 )
    83                         i = inet_pton( AF_INET, "0.0.0.0", &listen_addr.sin_addr );
    84                 else
    85                         i = inet_pton( AF_INET, global.conf->iface, &listen_addr.sin_addr );
    86 #ifdef IPV6
    87         }
    88 #endif
    89        
    90         if( i != 1 )
    91         {
    92                 log_message( LOGLVL_ERROR, "Couldn't parse address `%s'", global.conf->iface );
    93                 return( -1 );
    94         }
    95        
    96 #ifdef IPV6
    97         if( !use_ipv6 || ( i = bind( global.listen_socket, (struct sockaddr *) &listen_addr6, sizeof( listen_addr6 ) ) ) == -1 )
    98 #endif
    99                 i = bind( global.listen_socket, (struct sockaddr *) &listen_addr, sizeof( listen_addr ) );
    100         if( i == -1 )
    101         {
    102                 log_error( "bind" );
    103                 return( -1 );
    104         }
    105        
     47        memset( &hints, 0, sizeof( hints ) );
     48        hints.ai_family = PF_UNSPEC;
     49        hints.ai_socktype = SOCK_STREAM;
     50        hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE;
     51
     52        i = getaddrinfo( global.conf->iface, global.conf->port, &hints,
     53                                                &addrinfo_bind );
     54        if( i )
     55        {
     56                log_message( LOGLVL_ERROR, "Couldn't parse address `%s': %s",
     57                                         global.conf->iface, gai_strerror(i) );
     58                return -1;
     59        }
     60
     61        global.listen_socket = -1;
     62
     63        for( res = addrinfo_bind; res; res = res->ai_next )
     64        {
     65                global.listen_socket = socket( res->ai_family, res->ai_socktype,
     66                                                                           res->ai_protocol );
     67                if( global.listen_socket < 0 )
     68                        continue;
     69
     70                /* TIME_WAIT (?) sucks.. */
     71                i = 1;
     72                setsockopt( global.listen_socket, SOL_SOCKET, SO_REUSEADDR, &i,
     73                                        sizeof( i ) );
     74
     75                i = bind( global.listen_socket, res->ai_addr, res->ai_addrlen );
     76                if( i == -1 )
     77                {
     78                        log_error( "bind" );
     79                        return( -1 );
     80                }
     81
     82                break;
     83        }
     84
     85        freeaddrinfo( addrinfo_bind );
     86
    10687        i = listen( global.listen_socket, 10 );
    10788        if( i == -1 )
     
    125106                        exit( 0 );
    126107               
    127 //              chdir( "/" );
     108                chdir( "/" );
    128109               
    129110                /* Sometimes std* are already closed (for example when we're in a RESTARTed
  • conf.c

    ra6df0b5 rebb95b6  
    4747        conf = g_new0( conf_t, 1 );
    4848       
    49 #ifdef IPV6
    50         conf->iface = "::";
    51 #else
    52         conf->iface = "0.0.0.0";
    53 #endif
    54         conf->port = 6667;
     49        conf->iface = NULL;
     50        conf->port = "6667";
    5551        conf->nofork = 0;
    5652        conf->verbose = 0;
     
    8985                else if( opt == 'p' )
    9086                {
    91                         if( ( sscanf( optarg, "%d", &i ) != 1 ) || ( i <= 0 ) || ( i > 65535 ) )
    92                         {
    93                                 fprintf( stderr, "Invalid port number: %s\n", optarg );
    94                                 return( NULL );
    95                         }
    96                         conf->port = i;
     87                        g_free( conf->port );
     88                        conf->port = g_strdup( optarg );
    9789                }
    9890                else if( opt == 'P' )
     
    204196                        else if( g_strcasecmp( ini->key, "daemonport" ) == 0 )
    205197                        {
    206                                 if( ( sscanf( ini->value, "%d", &i ) != 1 ) || ( i <= 0 ) || ( i > 65535 ) )
    207                                 {
    208                                         fprintf( stderr, "Invalid port number: %s\n", ini->value );
    209                                         return( 0 );
    210                                 }
    211                                 conf->port = i;
     198                                conf->port = g_strdup( ini->value );
    212199                        }
    213200                        else if( g_strcasecmp( ini->key, "authmode" ) == 0 )
  • conf.h

    ra6df0b5 rebb95b6  
    3333{
    3434        char *iface;
    35         signed int port;
     35        char *port;
    3636        int nofork;
    3737        int verbose;
     
    5151} conf_t;
    5252
    53 conf_t *conf_load( int argc, char *argv[] );
     53G_GNUC_MALLOC conf_t *conf_load( int argc, char *argv[] );
    5454void conf_loaddefaults( irc_t *irc );
    5555
  • configure

    ra6df0b5 rebb95b6  
    3030gcov=0
    3131plugins=1
    32 ipv6=1
    3332
    3433events=glib
     
    7170--gcov=0/1      Disable/enable test coverage reporting  $gcov
    7271--plugins=0/1   Disable/enable plugins support          $plugins
    73 
    74 --ipv6=0/1      IPv6 socket support                     $ipv6
    7572
    7673--events=...    Event handler (glib, libevent)          $events
     
    134131#define CPU "$cpu"
    135132EOF
    136 
    137 if [ "$ipv6" = "1" ]; then
    138         echo '#define IPV6' >> config.h
    139 fi
    140133
    141134if [ "$debug" = "1" ]; then
  • crypting.h

    ra6df0b5 rebb95b6  
    2525
    2626int checkpass (const char *password, const char *md5sum);
    27 char *hashpass (const char *password);
    28 char *obfucrypt (char *line, const char *password);
    29 char *deobfucrypt (char *line, const char *password);
     27G_GNUC_MALLOC char *hashpass (const char *password);
     28G_GNUC_MALLOC char *obfucrypt (char *line, const char *password);
     29G_GNUC_MALLOC char *deobfucrypt (char *line, const char *password);
  • debian/postinst

    ra6df0b5 rebb95b6  
    4646db_stop
    4747
     48## Restore the helpfile in case we weren't upgrading but just reconfiguring:
     49if [ -e /usr/share/bitlbee/help.upgrading ]; then
     50        if [ -e /usr/share/bitlbee/help.txt ]; then
     51                rm -f /usr/share/bitlbee/help.upgrading
     52        else
     53                mv /usr/share/bitlbee/help.upgrading /usr/share/bitlbee/help.txt
     54        fi
     55fi
     56
    4857if [ -n "$2" -a "$BITLBEE_UPGRADE_DONT_RESTART" != "1" ]; then
    4958        /etc/init.d/bitlbee restart
  • debian/prerm

    ra6df0b5 rebb95b6  
    22
    33if [ "$1" = "upgrade" ]; then
    4         ## To prevent the help function from breaking in currently running BitlBee processes
    5         rm -f /usr/share/bitlbee/help.txt
     4        ## To prevent the help function from breaking in currently running
     5        ## BitlBee processes. Have to do it like this because dpkg-reconfigure
     6        ## looks a lot like an upgrade and we don't want to lose help.txt...
     7        if [ -e /usr/share/bitlbee/help.txt ]; then
     8                rm -f /usr/share/bitlbee/help.upgrading
     9                mv /usr/share/bitlbee/help.txt /usr/share/bitlbee/help.upgrading
     10        fi
    611else
    712        /etc/init.d/bitlbee stop || exit 0
  • doc/user-guide/commands.xml

    ra6df0b5 rebb95b6  
    836836        <bitlbee-command name="join_chat">
    837837                <short-description>Join a named groupchat/conference room</short-description>
    838                 <syntax>import_buddies &lt;connection&gt; &lt;room name&gt; [&lt;channel name&gt;] [&lt;room nickname&gt;] [&lt;password&gt;]</syntax>
     838                <syntax>join_chat &lt;connection&gt; &lt;room name&gt; [&lt;channel name&gt;] [&lt;room nickname&gt;] [&lt;password&gt;]</syntax>
    839839
    840840                <description>
  • help.h

    ra6df0b5 rebb95b6  
    4343} help_t;
    4444
    45 help_t *help_init( help_t **help, const char *helpfile );
     45G_GNUC_MALLOC help_t *help_init( help_t **help, const char *helpfile );
    4646char *help_get( help_t **help, char *string );
    4747
  • irc.c

    ra6df0b5 rebb95b6  
    4545{
    4646        irc_t *irc;
    47         struct hostent *peer;
    48         unsigned int i;
    49         char buf[128];
    50 #ifdef IPV6
    51         struct sockaddr_in6 sock6[1];
    52         unsigned int i6;
    53 #endif
    54         struct sockaddr_in sock[1];
     47        struct sockaddr_storage sock;
     48        socklen_t socklen = sizeof( sock );
    5549       
    5650        irc = g_new0( irc_t, 1 );
     
    7165        irc->channel = g_strdup( ROOT_CHAN );
    7266       
    73         i = sizeof( *sock );
    74 #ifdef IPV6
    75         i6 = sizeof( *sock6 );
    76 #endif
    77        
    7867        if( global.conf->hostname )
     68        {
    7969                irc->myhost = g_strdup( global.conf->hostname );
    80 #ifdef IPV6
    81         else if( getsockname( irc->fd, (struct sockaddr*) sock6, &i6 ) == 0 && sock6->sin6_family == AF_INET6 )
    82         {
    83                 if( ( peer = gethostbyaddr( (char*) &sock6->sin6_addr, sizeof( sock6->sin6_addr ), AF_INET6 ) ) )
    84                         irc->myhost = g_strdup( peer->h_name );
    85                 else if( inet_ntop( AF_INET6, &sock6->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL )
     70        }
     71        else if( getsockname( irc->fd, (struct sockaddr*) &sock, &socklen ) == 0 )
     72        {
     73                char buf[NI_MAXHOST+1];
     74
     75                if( getnameinfo( (struct sockaddr *) &sock, socklen, buf,
     76                                 NI_MAXHOST, NULL, -1, 0 ) == 0 )
     77                {
    8678                        irc->myhost = g_strdup( ipv6_unwrap( buf ) );
    87         }
    88 #endif
    89         else if( getsockname( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INET )
    90         {
    91                 if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INET ) ) )
    92                         irc->myhost = g_strdup( peer->h_name );
    93                 else if( inet_ntop( AF_INET, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL )
    94                         irc->myhost = g_strdup( buf );
    95         }
    96        
    97         i = sizeof( *sock );
    98 #ifdef IPV6
    99         i6 = sizeof( *sock6 );
    100         if( getpeername( irc->fd, (struct sockaddr*) sock6, &i6 ) == 0 && sock6->sin6_family == AF_INET6 )
    101         {
    102                 if( ( peer = gethostbyaddr( (char*) &sock6->sin6_addr, sizeof( sock6->sin6_addr ), AF_INET6 ) ) )
    103                         irc->host = g_strdup( peer->h_name );
    104                 else if( inet_ntop( AF_INET6, &sock6->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL )
     79                }
     80                else
     81                {
     82                        /* Rare, but possible. */
     83                        strncpy( irc->myhost, "localhost.localdomain", NI_MAXHOST );
     84                }
     85        }
     86       
     87        if( getpeername( irc->fd, (struct sockaddr*) &sock, &socklen ) == 0 )
     88        {
     89                char buf[NI_MAXHOST+1];
     90
     91                if( getnameinfo( (struct sockaddr *)&sock, socklen, buf,
     92                                 NI_MAXHOST, NULL, -1, 0 ) == 0 )
     93                {
    10594                        irc->host = g_strdup( ipv6_unwrap( buf ) );
    106         }
    107         else
    108 #endif
    109         if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INET )
    110         {
    111                 if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INET ) ) )
    112                         irc->host = g_strdup( peer->h_name );
    113                 else if( inet_ntop( AF_INET, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL )
    114                         irc->host = g_strdup( buf );
    115         }
    116        
    117         /* Rare, but possible. */
    118         if( !irc->host ) irc->host = g_strdup( "localhost." );
    119         if( !irc->myhost ) irc->myhost = g_strdup( "localhost." );
    120 
     95                }
     96                else
     97                {
     98                        /* Rare, but possible. */
     99                        strncpy( irc->host, "localhost.localdomain", NI_MAXHOST );
     100                }
     101        }
     102       
    121103        if( global.conf->ping_interval > 0 && global.conf->ping_timeout > 0 )
    122104                irc->ping_source_id = b_timeout_add( global.conf->ping_interval * 1000, irc_userping, irc );
     
    744726        irc_spawn( irc, u );
    745727       
    746         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 FAQ's are answered there." );
     728        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." );
    747729       
    748730        if( global.conf->runmode == RUNMODE_FORKDAEMON || global.conf->runmode == RUNMODE_DAEMON )
  • lib/misc.c

    ra6df0b5 rebb95b6  
    322322}
    323323
    324 #ifdef IPV6
    325324/* Wrap an IPv4 address into IPv6 space. Not thread-safe... */
    326325char *ipv6_wrap( char *src )
     
    360359        return ( src + 7 );
    361360}
    362 #endif
    363361
    364362/* Convert from one charset to another.
  • lib/proxy.c

    ra6df0b5 rebb95b6  
    211211        }
    212212
    213         if (proxyuser && *proxyuser) {
     213        if (strlen(proxyuser) > 0) {
    214214                char *t1, *t2;
    215215                t1 = g_strdup_printf("%s:%s", proxyuser, proxypass);
     
    539539        phb->data = data;
    540540       
    541         if ((proxytype == PROXY_NONE) || !proxyhost || !proxyhost[0] || !proxyport || (proxyport == -1))
     541        if ((proxytype == PROXY_NONE) || strlen(proxyhost) > 0 || !proxyport || (proxyport == -1))
    542542                return proxy_connect_none(host, port, phb);
    543543        else if (proxytype == PROXY_HTTP)
  • protocols/jabber/io.c

    ra6df0b5 rebb95b6  
    470470}
    471471
    472 static xt_status jabber_pkt_misc( struct xt_node *node, gpointer data )
    473 {
    474         printf( "Received unknown packet:\n" );
    475         xt_print( node );
    476        
    477         return XT_HANDLED;
    478 }
    479 
    480472static xt_status jabber_xmlconsole( struct xt_node *node, gpointer data )
    481473{
     
    509501        { "success",            "stream:stream",        sasl_pkt_result },
    510502        { "failure",            "stream:stream",        sasl_pkt_result },
    511         { NULL,                 "stream:stream",        jabber_pkt_misc },
    512503        { NULL,                 NULL,                   NULL }
    513504};
  • protocols/jabber/presence.c

    ra6df0b5 rebb95b6  
    170170                /* What else to do with it? */
    171171        }
    172         else
    173         {
    174                 printf( "Received PRES from %s:\n", from );
    175                 xt_print( node );
    176         }
    177172       
    178173        return XT_HANDLED;
  • protocols/jabber/xmltree.c

    ra6df0b5 rebb95b6  
    305305}
    306306
     307#ifdef DEBUG
    307308void xt_print( struct xt_node *node )
    308309{
     
    355356        printf( "</%s>\n", node->name );
    356357}
     358#endif
    357359
    358360struct xt_node *xt_dup( struct xt_node *node )
  • protocols/nogaim.c

    ra6df0b5 rebb95b6  
    3636#include <ctype.h>
    3737
    38 static int remove_chat_buddy_silent( struct groupchat *b, char *handle );
     38static int remove_chat_buddy_silent( struct groupchat *b, const char *handle );
    3939
    4040GSList *connections;
     
    578578                /* Remove him/her from the groupchats to prevent PART messages after he/she QUIT already */
    579579                for( c = ic->groupchats; c; c = c->next )
    580                         remove_chat_buddy_silent( c, (char*) handle );
     580                        remove_chat_buddy_silent( c, handle );
    581581        }
    582582       
     
    849849}
    850850
    851 static int remove_chat_buddy_silent( struct groupchat *b, char *handle )
     851static int remove_chat_buddy_silent( struct groupchat *b, const char *handle )
    852852{
    853853        GList *i;
  • protocols/oscar/oscar.c

    ra6df0b5 rebb95b6  
    10661066                        g_snprintf(tmp, BUF_LONG, "%s", args->msg);
    10671067                }
    1068         } else
     1068        } else if (args->mpmsg.numparts == 0) {
    10691069                g_snprintf(tmp, BUF_LONG, "%s", args->msg);
     1070        } else {
     1071                int i;
     1072               
     1073                *tmp = 0;
     1074                for (i = 0; i < args->mpmsg.numparts; i ++) {
     1075                        g_strlcat(tmp, (char*) args->mpmsg.parts[i].data, BUF_LONG);
     1076                        g_strlcat(tmp, "\n", BUF_LONG);
     1077                }
     1078        }
    10701079       
    10711080        strip_linefeed(tmp);
  • storage.h

    ra6df0b5 rebb95b6  
    6262
    6363void register_storage_backend(storage_t *);
    64 GList *storage_init(const char *primary, char **migrate);
     64G_GNUC_MALLOC GList *storage_init(const char *primary, char **migrate);
    6565
    6666#endif /* __STORAGE_H__ */
Note: See TracChangeset for help on using the changeset viewer.