Changeset 712

Show
Ignore:
Timestamp:
07/18/07 05:42:39 (1 year ago)
Author:
raphael
Message:

Removed hardcoded /var/www/virtual path from 00_master.conf
Fixed #427: /etc/init.d/ispcp_daemon doesn't support "status"
Updated vhcs2ispcp.sql to reflect recent DB changes caused by #457
Added rotation of proftpd's log files (fixes incorrect ftp traffic counting when logs are big)
Cleaned up daemon code (also removed useless license-related stuff)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/CHANGELOG

    r711 r712  
    1919        - CONFIGS: 
    2020                * Made changes to reflect fix for #465 
     21                * Removed hardcoded /var/www/virtual path from 00_master.conf 
     22                * Fixed #427: /etc/init.d/ispcp_daemon doesn't support "status" 
     23                * Updated vhcs2ispcp.sql to reflect recent DB changes caused by #457 
     24                * Added rotation of proftpd's log files (fixes incorrect ftp traffic counting when logs are big) 
     25        - DAEMON: 
     26                * Cleaned up code (also removed useless license-related stuff) 
    2127 
    22282007-07-16 Benedikt Heintel 
    2329        - GUI: 
    24                 * Fixed #457: Improved max-attempts limit for lost password's CAPTCHA 
     30                * Fixed #457: Improve max-attempts limit for lost password's CAPTCHA 
    2531                * Fixed serveral errors. 
    2632        - SQL: 
  • trunk/configs/apache/00_master.conf

    r665 r712  
    1919    Alias /errors   {ROOT_DIR}/gui/errordocs/ 
    2020 
    21     ErrorDocument 401 /errors/index.php 
    22     ErrorDocument 403 /errors/index.php 
    23     ErrorDocument 404 /errors/index.php 
    24     ErrorDocument 500 /errors/index.php 
     21    ErrorDocument 401 /errors/401.html 
     22    ErrorDocument 403 /errors/403.html 
     23    ErrorDocument 404 /errors/404.html 
     24    ErrorDocument 500 /errors/500.html 
    2525 
    2626    Alias /pma      {ROOT_DIR}/gui/tools/pma/ 
     
    5353    <IfModule mod_php4.c> 
    5454        <Directory {ROOT_DIR}/gui> 
    55             php_admin_value open_basedir "{ROOT_DIR}/gui/:/etc/ispcp/:/proc/:/var/www/virtual/:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" 
     55            php_admin_value open_basedir "{ROOT_DIR}/gui/:/etc/ispcp/:/proc/:{APACHE_WWW_DIR}/:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" 
    5656            php_admin_value session.save_path "{ROOT_DIR}/gui/phptmp/" 
    5757        </Directory> 
     
    5959    <IfModule mod_php5.c> 
    6060        <Directory {ROOT_DIR}/gui> 
    61             php_admin_value open_basedir "{ROOT_DIR}/gui/:/etc/ispcp/:/proc/:/var/www/virtual/:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" 
     61            php_admin_value open_basedir "{ROOT_DIR}/gui/:/etc/ispcp/:/proc/:{APACHE_WWW_DIR}/:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" 
    6262            php_admin_value session.save_path "{ROOT_DIR}/gui/phptmp/" 
    6363        </Directory> 
  • trunk/configs/init.d/ispcp_daemon

    r652 r712  
    77#               Modified for Debian GNU/Linux 
    88#               by Ian Murdock <imurdock@gnu.ai.mit.edu>. 
    9 #               Modified for Debian  
     9#               Modified for Debian 
    1010#               by Erik Lehmann <erik.lehmann@ispcp.net> 
    1111# 
     
    2727case "$1" in 
    2828  start) 
    29         echo -n "Starting $DESC: " 
    3029        start-stop-daemon --start --verbose --exec $DAEMON -- -p $PID 
    31         echo "$NAME." 
    3230        ;; 
    3331  stop) 
    34         echo -n "Stopping $DESC: " 
    35         start-stop-daemon --stop --verbose --pidfile $PID --exec $DAEMON 
    36         rm $PID 
    37         echo "$NAME." 
     32        start-stop-daemon --stop --verbose --pidfile $PID --exec $DAEMON --retry 5 
     33    rm $PID 
    3834        ;; 
    3935  restart|force-reload) 
    40         echo "Restarting $DESC: "                                       
    41         start-stop-daemon --stop --verbose --pidfile $PID --exec $DAEMON 
     36        start-stop-daemon --stop --verbose --pidfile $PID --exec $DAEMON --retry 5 
    4237        rm $PID 
    4338        start-stop-daemon --start --verbose --exec $DAEMON -- -p $PID 
    44         echo "$NAME." 
     39        ;; 
     40  status) 
     41    if [ -s $PID ]; then 
     42        RPID=`cat $PID` 
     43        kill -0 $RPID 2> /dev/null 
     44        if [ "$?" = 0 ] ; then 
     45            echo "$NAME is started" 
     46            exit 0 
     47        fi 
     48    fi 
     49    echo "$NAME is stopped" 
     50    exit 1 
    4551        ;; 
    4652  *) 
    4753        N=/etc/init.d/$NAME 
    48         echo "Usage: $N {start|stop|restart|force-reload}" >&2 
     54        echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 
    4955        exit 1 
    5056        ;; 
  • trunk/configs/logrotate/ispcp

    r683 r712  
    2121        endscript 
    2222} 
     23 
     24/var/log/proftpd/xferlog { 
     25  daily 
     26  rotate 7 
     27  missingok 
     28  compress 
     29  delaycompress 
     30  postrotate 
     31    /usr/bin/killall -HUP syslogd 
     32  endscript 
     33} 
     34 
     35/var/log/proftpd/ftp_traff.log { 
     36  daily 
     37  rotate 7 
     38  missingok 
     39  compress 
     40  delaycompress 
     41  prerotate 
     42    /var/www/ispcp/engine/traffic/ispcp-vrl-traff &> /var/log/ispcp/ispcp-vrl-traff.log 
     43  endscript 
     44  postrotate 
     45    /usr/bin/killall -HUP syslogd 
     46  endscript 
     47} 
  • trunk/engine/setup/ispcp-setup

    r698 r712  
    22502250                                                '{DEFAULT_ADMIN_ADDRESS}'       => $main::cfg{'DEFAULT_ADMIN_ADDRESS'}, 
    22512251                                                '{ROOT_DIR}'                            => $main::cfg{'ROOT_DIR'}, 
     2252                                                '{APACHE_WWW_DIR}'              => $main::cfg{'APACHE_WWW_DIR'}, 
    22522253                                                '{APACHE_USERS_LOG_DIR}'        => $main::cfg{'APACHE_USERS_LOG_DIR'}, 
    22532254                                                '{APACHE_LOG_DIR}'                      => $main::cfg{'APACHE_LOG_DIR'}, 
     
    22912292                                                '{DEFAULT_ADMIN_ADDRESS}'       => $main::cfg{'DEFAULT_ADMIN_ADDRESS'}, 
    22922293                                                '{ROOT_DIR}'                            => $main::cfg{'ROOT_DIR'}, 
     2294                                                '{APACHE_WWW_DIR}'              => $main::cfg{'APACHE_WWW_DIR'}, 
    22932295                                                '{APACHE_USERS_LOG_DIR}'        => $main::cfg{'APACHE_USERS_LOG_DIR'}, 
    22942296                                                '{APACHE_LOG_DIR}'                      => $main::cfg{'APACHE_LOG_DIR'}, 
     
    23422344 
    23432345        # 
    2344         # Disable default site --> 000-default (if not, ispcp is not working
     2346        # Disable default site --> 000-default (if not, ispcp does not work
    23452347        # 
    23462348 
     
    23532355        # 
    23542356        # start fastcgi, suexec and rewrite mod 
    2355         # Disable default site (if not, ispcp not working) 
    23562357        # 
    23572358 
     
    23662367                        sys_command_rs("/usr/sbin/a2enmod proxy &> /tmp/ispcp-setup-services.log"); 
    23672368                } 
     2369 
     2370        } 
     2371 
     2372        # 
     2373        # Disable default fastcgi, otherwise FastCgiIpcDir is already defined 
     2374        # 
     2375 
     2376        if (-e "/usr/sbin/a2dismod") { 
     2377 
     2378                sys_command_rs("/usr/sbin/a2dismod fastcgi &> /tmp/ispcp-setup-services.log"); 
    23682379 
    23692380        } 
  • trunk/engine/setup/vhcs2ispcp.sql

    r689 r712  
    2323ALTER TABLE `login` ADD `ipaddr` VARCHAR( 15 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL ; 
    2424ALTER TABLE `login` ADD `user_name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL ; 
     25ALTER TABLE `login` ADD `captcha_count` TINYINT( 1 ) NULL ; 
    2526ALTER TABLE `login` ADD `login_count` TINYINT( 1 ) NULL; 
    2627 
  • trunk/gui/include/ispcp-functions.php

    r691 r712  
    5353        global $Version; 
    5454 
     55        $code = 999; 
     56 
    5557    @$socket = socket_create (AF_INET, SOCK_STREAM, 0); 
    5658    if ($socket < 0) { 
     
    6870    $out = read_line($socket); 
    6971 
     72    list($code) = explode(' ', $out); 
     73    if ($code == 999) { 
     74        return $out; 
     75    } 
     76 
    7077    /* send hello query */ 
    7178    $query = "helo  $Version\r\n"; 
     
    7481    /* read one line with helo answer */ 
    7582    $out = read_line($socket); 
     83 
     84    list($code) = explode(' ', $out); 
     85    if ($code == 999) { 
     86        return $out; 
     87    } 
    7688 
    7789    /* send reg check query */ 
     
    8193    $execute_replay = read_line($socket); 
    8294 
     95    list($code) = explode(' ', $execute_replay); 
     96    if ($code == 999) { 
     97        return $out; 
     98    } 
     99 
    83100    /* send quit query */ 
    84101    $quit_query = "bye\r\n"; 
     
    87104    $quit_replay = read_line($socket); 
    88105 
    89     /* analyze key replay */ 
    90     $answer = $execute_replay; 
    91  
    92     /* close socket */ 
     106    list($code) = explode(' ', $quit_replay); 
     107    if ($code == 999) { 
     108        return $out; 
     109    } 
     110 
     111    list($answer) = explode(' ', $execute_replay); 
     112 
    93113    socket_close ($socket); 
    94114 
    95     /* return function result */ 
    96115    return $answer; 
    97116 
  • trunk/tools/daemon/BSDmakefile

    r469 r712  
    2121helo_cmd.o helo_syntax.o lr_cmd.o lr_syntax.o bye_cmd.o bye_syntax.o 
    2222 
    23 BUILD = gcc -O2 -ansi -Wall -Wstrict-prototypes -pedantic -o 
     23BUILD = gcc -O3 -ansi -Wall -Wstrict-prototypes -pedantic -o 
    2424 
    25 COMPILE = gcc -O2 -ansi -Wall -Wstrict-prototypes -pedantic -c -o 
     25COMPILE = gcc -O3 -ansi -Wall -Wstrict-prototypes -pedantic -c -o 
    2626 
    2727STRIP = strip -s 
     
    3131        $(STRIP) ispcp_daemon 
    3232         
    33 ispcp_daemon.o: ispcp_daemon.c defs.h 
    34         $(COMPILE) ispcp_daemon.o ispcp_daemon.c 
    35  
    36 daemon_init.o: daemon_init.c daemon_init.h 
    37         $(COMPILE) daemon_init.o daemon_init.c 
    38          
    39 message.o: message.c message.h  
    40         $(COMPILE) message.o message.c 
    41          
    42 say.o: say.c say.h 
    43         $(COMPILE) say.o say.c 
    44  
    45 signal-handlers.o: signal-handlers.c signal-handlers.h 
    46         $(COMPILE) signal-handlers.o signal-handlers.c 
    47          
    48 receive_data.o: receive_data.c receive_data.h 
    49         $(COMPILE) receive_data.o receive_data.c 
    50  
    51 send_data.o: send_data.c send_data.h 
    52         $(COMPILE) send_data.o send_data.c 
    53  
    54 take_connection.o: take_connection.c take_connection.h 
    55         $(COMPILE) take_connection.o take_connection.c 
    56  
    57 send_line.o: send_line.c send_line.h 
    58         $(COMPILE) send_line.o send_line.c 
    59  
    60 recv_line.o: recv_line.c recv_line.h 
    61         $(COMPILE) recv_line.o recv_line.c 
    62  
    63 helo_cmd.o: helo_cmd.c helo_cmd.h 
    64         $(COMPILE) helo_cmd.o helo_cmd.c 
    65  
    66 helo_syntax.o: helo_syntax.c helo_syntax.h 
    67         $(COMPILE) helo_syntax.o helo_syntax.c 
    68  
    69 lr_cmd.o: lr_cmd.c lr_cmd.h 
    70         $(COMPILE) lr_cmd.o lr_cmd.c 
    71  
    72 lr_syntax.o: lr_syntax.c lr_syntax.h 
    73         $(COMPILE) lr_syntax.o lr_syntax.c 
    74  
    75 bye_cmd.o: bye_cmd.c bye_cmd.h 
    76         $(COMPILE) bye_cmd.o bye_cmd.c 
    77  
    78 bye_syntax.o: bye_syntax.c bye_syntax.h 
    79         $(COMPILE) bye_syntax.o bye_syntax.c 
     33%.o: %.c 
     34        $(COMPILE) $@ $*.c 
    8035 
    8136uninstall: clean 
     
    8641        rm -rf ispcp_daemon 
    8742 
     43.PHONY: clean uninstall 
  • trunk/tools/daemon/Makefile

    r480 r712  
    2424# The ISPCP Home Page is at: 
    2525# 
    26 #    http://www.ispcp.net 
     26#    http://www.isp-control.net 
    2727 
    2828 
     
    3131helo_cmd.o helo_syntax.o lr_cmd.o lr_syntax.o bye_cmd.o bye_syntax.o 
    3232 
    33 BUILD = gcc -O2 -ansi -Wall -Wstrict-prototypes -pedantic -o 
     33BUILD = gcc -O3 -ansi -Wall -Wstrict-prototypes -pedantic -o 
    3434 
    35 COMPILE = gcc -O2 -ansi -Wall -Wstrict-prototypes -pedantic -c -o 
     35COMPILE = gcc -O3 -ansi -Wall -Wstrict-prototypes -pedantic -c -o 
    3636 
    3737STRIP = strip -s 
     
    4141        $(STRIP) ispcp_daemon 
    4242         
    43 ispcp_daemon.o: ispcp_daemon.c defs.h 
    44         $(COMPILE) ispcp_daemon.o ispcp_daemon.c 
    45  
    46 daemon_init.o: daemon_init.c daemon_init.h 
    47         $(COMPILE) daemon_init.o daemon_init.c 
    48          
    49 message.o: message.c message.h  
    50         $(COMPILE) message.o message.c 
    51          
    52 say.o: say.c say.h 
    53         $(COMPILE) say.o say.c 
    54  
    55 signal-handlers.o: signal-handlers.c signal-handlers.h 
    56         $(COMPILE) signal-handlers.o signal-handlers.c 
    57          
    58 receive_data.o: receive_data.c receive_data.h 
    59         $(COMPILE) receive_data.o receive_data.c 
    60  
    61 send_data.o: send_data.c send_data.h 
    62         $(COMPILE) send_data.o send_data.c 
    63  
    64 take_connection.o: take_connection.c take_connection.h 
    65         $(COMPILE) take_connection.o take_connection.c 
    66  
    67 send_line.o: send_line.c send_line.h 
    68         $(COMPILE) send_line.o send_line.c 
    69  
    70 recv_line.o: recv_line.c recv_line.h 
    71         $(COMPILE) recv_line.o recv_line.c 
    72  
    73 helo_cmd.o: helo_cmd.c helo_cmd.h 
    74         $(COMPILE) helo_cmd.o helo_cmd.c 
    75  
    76 helo_syntax.o: helo_syntax.c helo_syntax.h 
    77         $(COMPILE) helo_syntax.o helo_syntax.c 
    78  
    79 lr_cmd.o: lr_cmd.c lr_cmd.h 
    80         $(COMPILE) lr_cmd.o lr_cmd.c 
    81  
    82 lr_syntax.o: lr_syntax.c lr_syntax.h 
    83         $(COMPILE) lr_syntax.o lr_syntax.c 
    84  
    85 bye_cmd.o: bye_cmd.c bye_cmd.h 
    86         $(COMPILE) bye_cmd.o bye_cmd.c 
    87  
    88 bye_syntax.o: bye_syntax.c bye_syntax.h 
    89         $(COMPILE) bye_syntax.o bye_syntax.c 
     43%.o: %.c %.h 
     44        $(COMPILE) $@ $*.c 
    9045 
    9146uninstall: clean 
     
    9651        rm -rf ispcp_daemon 
    9752 
     53.PHONY: clean uninstall 
  • trunk/tools/daemon/bye_cmd.c

    r154 r712  
    22#include "bye_cmd.h" 
    33 
    4 int bye_cmd(int fd
     4int bye_cmd(int fd, char *msg
    55{ 
    6         char *buff = calloc(MAX_MSG_SIZE, sizeof(char)); 
    7  
    8         int res; 
    9  
    10         for ( ; ; ) { 
    11                 memset(buff, '\0', MAX_MSG_SIZE); 
    12  
    13                 if (recv_line(fd, buff, MAX_MSG_SIZE - 1) <= 0) { 
    14  
    15                         free(buff); 
    16  
    17                         return (-1); 
    18                 } 
    19  
    20                 res = bye_syntax(fd, buff); 
    21  
    22                 if (res == -1) { 
    23  
    24                         free(buff); 
    25  
    26                         return (-1); 
    27  
    28                 } else if (res == 1) 
    29                         continue; 
    30                 else 
    31                         break; 
    32         } 
    33  
    34     free(buff); 
    35  
    36         return (NO_ERROR); 
     6        return bye_syntax(fd, msg); 
    377} 
  • trunk/tools/daemon/bye_cmd.h

    r154 r712  
    33#define _BYE_CMD_H 
    44 
    5 #define NO_ERROR                0 
    6  
    7 #define MAX_MSG_SIZE            1025 
     5#include "defs.h" 
    86 
    97#include <sys/types.h> 
     
    1715extern int bye_syntax(int fd, char *buff); 
    1816 
    19 int bye_cmd(int fd); 
     17int bye_cmd(int fd, char *msg); 
    2018 
    21 #else 
    22 # 
    2319#endif 
  • trunk/tools/daemon/bye_syntax.c

    r154 r712  
    99 
    1010        if (ptr != buff) { 
    11  
    12                 if (send_line(fd, message(MSG_BAD_SYNTAX), strlen(message(MSG_BAD_SYNTAX))) < 0) { 
    13                         return (-1); 
    14                 } 
    1511 
    1612                return (1); 
  • trunk/tools/daemon/bye_syntax.h

    r154 r712  
    33#define _BYE_SYNTAX_H 
    44 
     5#include "defs.h" 
     6 
    57#include <stdlib.h> 
    68 
    79#include <string.h> 
    8  
    9 #define NO_ERROR                0 
    10  
    11 #define MAX_MSG_SIZE            1025 
    12  
    13 #define MSG_BAD_SYNTAX          10016 
    14  
    15 #define MSG_CMD_OK              10017 
    16  
    17 #define MSG_BYE_CMD             10019 
    1810 
    1911extern char *message(int message_number); 
     
    2315int bye_syntax(int fd, char *buff); 
    2416 
    25 #else 
    26 # 
    2717#endif 
  • trunk/tools/daemon/daemon_init.h

    r154 r712  
    2626void daemon_init(const char *pname, int facility); 
    2727 
    28 #else 
    29 # 
    3028#endif 
  • trunk/tools/daemon/defs.h

    r469 r712  
    22 
    33#define _DEFS_H 
    4  
    5 /* Needed headers. */ 
    6  
    7 /* 
    8  calloc, malloc, free, realloc - Allocate and free dynamic memory 
    9  */ 
    10  
    11 #include <stdlib.h> 
    12  
    13 /* 
    14  Will we log it ? 
    15  */ 
    16  
    17 #include <syslog.h> 
    18  
    19 /* 
    20  Socket manipulation functions. 
    21  */ 
    22  
    23 #include <sys/stat.h> 
    24 #include <sys/types.h> 
    25 #include <sys/socket.h> 
    26  
    27 /* 
    28  Internet Socket Address Structure IPv4. 
    29  */ 
    30  
    31 #include <netinet/in.h> 
    32  
    33 /* 
    34  Socket timeouts. 
    35  */ 
    36  
    37 #include <sys/time.h> 
    38  
    39 /* 
    40  Signal handling. 
    41  */ 
    42  
    43 #include <signal.h> 
    44  
    45 /* 
    46  String manipulation. 
    47  */ 
    48  
    49 #include <string.h> 
    50  
    51 /* 
    52  Error handling. 
    53  */ 
    54  
    55 #include <errno.h> 
    56  
    57 /* 
    58  Something more about fork. 
    59  */ 
    60  
    61 #include <unistd.h> 
    62  
    63 /* 
    64  String manipulation. 
    65  */ 
    66  
    67 #include <stdio.h> 
    68  
    69 /* 
    70  inet_ntop() function. 
    71  */ 
    72  
    73 #include <arpa/inet.h> 
    74  
    75 /* 
    76  Predefined names. 
    77  */ 
    784 
    795/* 
     
    9622 
    9723/* 
    98  Max length of transfferd messages. 
     24 Max length of transferred messages. 
    9925 */ 
    10026 
     
    10531 */ 
    10632 
    107 #define MSG_MAX_COUNT           28 
     33#define NO_ERROR                0 
    10834 
    10935#define MSG_WELCOME             10001 
     36#define MSG_WELCOME_TXT             "250 OK ispCP Daemon v1.1 Welcomes You!\r\n" 
     37#define MSG_DAEMON_VER          10002 
     38#define MSG_DAEMON_VER_TXT          "ispCP daemon v1.1 started!" 
     39#define MSG_DAEMON_NAME         10003 
     40#define MSG_DAEMON_NAME_TXT         "ispcp_daemon" 
     41#define MSG_ERROR_LISTEN        10004 
     42#define MSG_ERROR_LISTEN_TXT        "listen() error: %s" 
     43#define MSG_SIG_CHLD            10005 
     44#define MSG_SIG_CHLD_TXT            "child %s terminated !" 
     45#define MSG_SIG_PIPE            10006 
     46#define MSG_SIG_PIPE_TXT            "Aeee! SIG_PIPE was received ! Will we survive ?" 
     47#define MSG_ERROR_EINTR         10007 
     48#define MSG_ERROR_EINTR_TXT         "EINTR was received ! continue;" 
     49#define MSG_ERROR_ACCEPT        10008 
     50#define MSG_ERROR_ACCEPT_TXT        "accept() error: %s" 
     51#define MSG_START_CHILD         10009 
     52#define MSG_START_CHILD_TXT         "child %s started !" 
     53#define MSG_ERROR_SOCKET_WR     10010 
     54#define MSG_ERROR_SOCKET_WR_TXT     "send_line(): socket write error: %s" 
     55#define MSG_BYTES_WRITTEN       10011 
     56#define MSG_BYTES_WRITTEN_TXT       "send_line(): %s byte(s) successfully written !" 
     57#define MSG_ERROR_SOCKET_RD     10012 
     58#define MSG_ERROR_SOCKET_RD_TXT     "read_line(): socket read error: %s" 
     59#define MSG_ERROR_SOCKET_EOF    10013 
     60#define MSG_ERROR_SOCKET_EOF_TXT    "read_line(): socket EOF ! other end closed the connection !" 
     61#define MSG_BYTES_READ          10014 
     62#define MSG_BYTES_READ_TXT          "read_line(): %s byte(s) successfully read !" 
     63#define MSG_HELO_CMD            10015 
     64#define MSG_HELO_CMD_TXT            "helo " 
     65#define MSG_BAD_SYNTAX          10016 
     66#define MSG_BAD_SYNTAX_TXT          "999 ERR Incorrect Syntax !\r\n" 
     67#define MSG_CMD_OK              10017 
     68#define MSG_CMD_OK_TXT              "250 OK " 
     69#define MSG_BYE_CMD             10018 
     70#define MSG_BYE_CMD_TXT             "bye" 
     71#define MSG_EQ_CMD              10019 
     72#define MSG_EQ_CMD_TXT              "execute query" 
     73#define MSG_CONF_FILE           10020 
     74#define MSG_CONF_FILE_TXT           "ispCP configuration file not found !" 
     75#define MSG_MISSING_REG_DATA    10021 
     76#define MSG_MISSING_REG_DATA_TXT    "ispCP data cannot be found in the config file !" 
     77#define MSG_ERROR_BIND          10022 
     78#define MSG_ERROR_BIND_TXT          "bind() error: %s ! \r\n Please check for an other running daemon!\r\n " 
    11079 
    111 #define MSG_DAEMON_VER          1000
     80#define MSG_MAX_COUNT           2
    11281 
    113 #define MSG_DAEMON_NAME         10003 
    114  
    115 #define MSG_ERROR_LISTEN        10004 
    116  
    117 #define MSG_SIG_CHLD            10005 
    118  
    119 #define MSG_SIG_PIPE            10006 
    120  
    121 #define MSG_ERROR_EINTR         10007 
    122  
    123 #define MSG_ERROR_ACCEPT        10008 
    124  
    125 #define MSG_START_CHILD         10009 
    126  
    127 #define MSG_ERROR_SOCKET_WR     10010 
    128  
    129 #define MSG_BYTES_WRITTEN       10011 
    130  
    131 #define MSG_ERROR_SOCKET_RD     10012 
    132  
    133 #define MSG_ERROR_SOCKET_EOF    10013 
    134  
    135 #define MSG_BYTES_READ          10014 
    136  
    137 #define MSG_HELO_CMD            10015 
    138  
    139 #define MSG_BAD_SYNTAX          10016 
    140  
    141 #define MSG_CMD_OK              10017 
    142  
    143 #define MSG_LR_CMD              10018 
    144  
    145 #define MSG_BYE_CMD             10019 
    146  
    147 #define MSG_LS_CMD              10018 
    148  
    149 #define MSG_EQ_CMD              10021 
    150  
    151 #define MSG_CONF_FILE           10022 
    152  
    153 #define MSG_MISSING_REG_DATA    10023 
    154  
    155 #define MSG_ERROR_SOCKET        10024 
    156  
    157 #define MSG_ERROR_CONNECT       10025 
    158  
    159 #define MSG_LSERVER_WELCOME     10026 
    160  
    161 #define MSG_LICENSE_ERROR       10027 
    162  
    163 #define MSG_ERROR_BIND          10028 
    164  
    165 /* 
    166  Common Error Codes. 
    167  */ 
    168 #define NO_ERROR                0 
    169  
    170  
    171 /* Type definitions. */ 
    172  
    173 typedef unsigned int word; 
    174  
    175  
    176 /* Global variables. */ 
    177  
    178 char *messages_array[MSG_MAX_COUNT][1] = { 
    179     {"250 OK ispCP Server Welcomes You !\r\n"}, 
    180     {"ispCP_daemon v1.0 started !"}, 
    181     {"ispcp_daemon"}, 
    182     {"listen() error: %s"}, 
    183     {"child %s terminated !"}, 
    184     {"Aeee! SIG_PIPE was received ! Will we survive ?"}, 
    185     {"EINTR was received ! continue;"}, 
    186     {"accept() error: %s"}, 
    187     {"child %s started !"}, 
    188     {"send_line(): socket write error: %s"}, 
    189     {"send_line(): %s byte(s) successfully written !"}, 
    190     {"read_line(): socket read error: %s"}, 
    191     {"read_line(): socket EOF ! other end closed the connection !"}, 
    192     {"read_line(): %s byte(s) successfully read !"}, 
    193     {"helo "}, 
    194     {"999 ERR Incorrect Syntax !\r\n"}, 
    195     {"250 OK "}, 
    196     {"license request: "}, 
    197     {"bye"}, 
    198     {"license status"}, 
    199     {"execute query"}, 
    200     {"ispCP configuration file not found !"}, 
    201     {"ispCP data cannot be found in the config file !"}, 
    202     {"Connect to license-server: socket() error [%s]!"}, 
    203     {"Connect to license-server: connect() error [%s]!"}, 
    204     {"250 OK ispCP Server Welcomes You !\r\n"}, 
    205     {"999 ERR License error !\r\n"}, 
    206     {"bind() error: %s ! \r\n Please check for another daemon runing !\r\n "} 
    207 }; 
    208  
    209 char client_ip [MAX_MSG_SIZE]; 
    210  
    211 /* 
    212  BEGIN: ispcp_daemon variables 
    213  */ 
    214  
    215 char product_number [MAX_MSG_SIZE]; 
    216  
    217 char product_version [MAX_MSG_SIZE]; 
    218  
    219 char license_key [MAX_MSG_SIZE]; 
    220  
    221 char license_status [MAX_MSG_SIZE]; 
    222  
    223 /* 
    224  END: ispcp_daemon variables 
    225  */ 
    226  
    227 struct timeval     *tv_rcv; 
    228  
    229 struct timeval     *tv_snd; 
    230  
    231 /* External functions. */ 
    232  
    233 extern void daemon_init(const char *pname, int facility); 
    234  
    235 extern char *message(int message_number); 
    236  
    237 extern void say(char *format, char *message); 
    238  
    239 extern void sig_child (int signo); 
    240  
    241 extern void sig_pipe(int signo); 
    242  
    243 extern void take_connection(int sockfd); 
    244  
    245 extern int query_license_server(void); 
     82extern char *messages_array[][1]; 
    24683 
    24784#endif 
  • trunk/tools/daemon/helo_cmd.c

    r154 r712  
    22#include "helo_cmd.h" 
    33 
    4 int helo_cmd(int fd, license_data_type *ld
     4int helo_cmd(int fd
    55{ 
    66        char *buff = calloc(MAX_MSG_SIZE, sizeof(char)); 
    77        int res; 
    88 
    9         for ( ; ; ) { 
     9        while (1) { 
    1010                memset(buff, '\0', MAX_MSG_SIZE); 
    1111 
     
    1515                } 
    1616 
    17                 res = helo_syntax(fd, ld, buff); 
     17                res = helo_syntax(fd, buff); 
    1818 
    1919                if (res == -1) { 
  • trunk/tools/daemon/helo_cmd.h

    r154 r712  
    33#define _HELO_CMD_H 
    44 
    5 #define NO_ERROR                0 
    6  
    7 #define MAX_MSG_SIZE            1025 
     5#include "defs.h" 
    86 
    97#include <sys/types.h> 
     
    1513#include <string.h> 
    1614 
    17 typedef struct { 
    18  
    19     char ip[MAX_MSG_SIZE]; 
    20  
    21     char host[MAX_MSG_SIZE]; 
    22  
    23     /* 
    24      Request data. 
    25      */ 
    26  
    27     char rd[MAX_MSG_SIZE]; 
    28  
    29     /* 
    30      Status data. 
    31      */ 
    32  
    33     char sd[MAX_MSG_SIZE]; 
    34  
    35 } license_data_type; 
    36  
    37 /* 
    38  extern char *message(int message_number); 
    39  
    40  
    41  extern int send_line(int fd, char *src, size_t len); 
    42  */ 
    43  
    4415extern void say(char *format, char *message); 
    4516 
    4617extern int recv_line(int fd, char *dest, size_t n); 
    4718 
    48 extern int helo_syntax(int fd, license_data_type *ld, char *buff); 
     19extern int helo_syntax(int fd, char *buff); 
    4920 
    50 int helo_cmd(int fd, license_data_type *ld); 
     21int helo_cmd(int fd); 
    5122 
    52 #else 
    53 # 
    5423#endif 
  • trunk/tools/daemon/helo_syntax.c

    r154 r712  
    22#include "helo_syntax.h" 
    33 
    4 int helo_syntax(int fd, license_data_type *ld, char *buff) 
     4int helo_syntax(int fd, char *buff) 
    55{ 
    66        char *ptr; 
     
    1717 
    1818        } else { 
    19         char *helo_ans = calloc(MAX_MSG_SIZE, sizeof(char)); 
    20                 memset(ld -> ip, '\0', MAX_MSG_SIZE); 
    21  
    22                 memset(ld -> host, '\0', MAX_MSG_SIZE); 
    23  
    24                 strcat(ld -> ip, client_ip); 
     19                char *helo_ans = calloc(MAX_MSG_SIZE, sizeof(char)); 
    2520 
    2621                ptr = strstr(buff, " "); 
    2722 
    28                 strncat(ld -> host, ptr + 1, strlen(ptr + 1) - 2); 
    29  
    30         strcat(helo_ans, message(MSG_CMD_OK)); 
    31                 strcat(helo_ans, ld -> host); 
     23                strcat(helo_ans, message(MSG_CMD_OK)); 
     24                strcat(helo_ans, client_ip); 
     25               strcat(helo_ans, "/"); 
     26                strncat(helo_ans, ptr + 1, strlen(ptr + 1) - 2); 
    3227                strcat(helo_ans, "\r\n"); 
    3328 
    34  
    35                 if (send_line(fd, helo_ans,  strlen(helo_ans)) < 0) { 
    36             free(helo_ans); 
     29                if (send_line(fd, helo_ans, strlen(helo_ans)) < 0) { 
     30                        free(helo_ans); 
    3731                        return (-1); 
    3832                } 
  • trunk/tools/daemon/helo_syntax.h

    r154 r712  
    33#define _HELO_SYNTAX_H 
    44 
    5 #define NO_ERROR                0 
    6  
    7 #define MAX_MSG_SIZE            1025 
    8  
    9 #define MSG_HELO_CMD            10015 
    10  
    11 #define MSG_BAD_SYNTAX          10016 
    12  
    13 #define MSG_CMD_OK              10017 
     5#include "defs.h" 
    146 
    157#include <sys/types.h> 
     
    2113#include <stdio.h> 
    2214 
    23 typedef struct { 
    24  
    25     char ip[MAX_MSG_SIZE]; 
    26  
    27     char host[MAX_MSG_SIZE]; 
    28  
    29     /* 
    30      Request data. 
    31      */ 
    32  
    33     char rd[MAX_MSG_SIZE]; 
    34  
    35     /* 
    36      Status data. 
    37      */ 
    38  
    39     char sd[MAX_MSG_SIZE]; 
    40  
    41 } license_data_type; 
    42  
    4315extern char client_ip[MAX_MSG_SIZE]; 
    4416 
     
    4921extern int send_line(int fd, char *src, size_t len); 
    5022 
    51 int helo_syntax(int fd, license_data_type *ld, char *buff); 
     23int helo_syntax(int fd, char *buff); 
    5224 
    53 #else 
    54 # 
    5525#endif 
  • trunk/tools/daemon/ispcp_daemon.c

    r469 r712  
    11 
    2 #include "defs.h" 
     2#include "ispcp_daemon.h" 
    33 
    44int getopt(int argc, char * const argv[], const char *optstring); 
  • trunk/tools/daemon/lr_cmd.c