Changeset d25f6fc for unix.c


Ignore:
Timestamp:
2005-12-26T14:02:47Z (15 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
238f828
Parents:
ffea9b9
Message:

Added OperPassword and RunMode = ForkDaemon settings. Oper stuff is
*INSECURE* because users can just do /mode +o to become operator.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • unix.c

    rffea9b9 rd25f6fc  
    3232#include <unistd.h>
    3333#include <sys/time.h>
     34#include <sys/wait.h>
    3435
    3536global_t global;        /* Against global namespace pollution */
     
    4647        global.loop = g_main_new( FALSE );
    4748       
    48         log_init( );
     49        log_init();
    4950
    5051        nogaim_init();
     
    7071                log_message( LOGLVL_INFO, "Bitlbee %s starting in daemon mode.", BITLBEE_VERSION );
    7172        }
     73        else if( global.conf->runmode == RUNMODE_FORKDAEMON )
     74        {
     75                i = bitlbee_daemon_init();
     76                log_message( LOGLVL_INFO, "Bitlbee %s starting in forking daemon mode.", BITLBEE_VERSION );
     77        }
    7278        if( i != 0 )
    7379                return( i );
    7480
    75         global.storage = storage_init( global.conf->primary_storage,
    76                                                                    global.conf->migrate_storage );
     81        global.storage = storage_init( global.conf->primary_storage, global.conf->migrate_storage );
    7782        if ( global.storage == NULL) {
    7883                log_message( LOGLVL_ERROR, "Unable to load storage backend '%s'", global.conf->primary_storage );
     
    8489        memset( &sig, 0, sizeof( sig ) );
    8590        sig.sa_handler = sighandler;
     91        sigaction( SIGCHLD, &sig, &old );
    8692        sigaction( SIGPIPE, &sig, &old );
    8793        sig.sa_flags = SA_RESETHAND;
     
    107113static void sighandler( int signal )
    108114{
    109         /* FIXME: In fact, calling log_message() here can be dangerous. But well, let's take the risk for now. */
     115        /* FIXME: Calling log_message() here is not a very good idea! */
    110116       
    111117        if( signal == SIGTERM )
     
    133139                }
    134140        }
     141        else if( signal == SIGCHLD )
     142        {
     143                pid_t pid;
     144                int st;
     145               
     146                while( ( pid = waitpid( 0, &st, WNOHANG ) ) > 0 )
     147                {
     148                        if( WIFSIGNALED( st ) )
     149                                log_message( LOGLVL_INFO, "Client %d terminated normally. (status = %d)", pid, WEXITSTATUS( st ) );
     150                        else if( WIFEXITED( st ) )
     151                                log_message( LOGLVL_INFO, "Client %d killed by signal %d.", pid, WTERMSIG( st ) );
     152                }
     153        }
    135154        else if( signal != SIGPIPE )
    136155        {
Note: See TracChangeset for help on using the changeset viewer.