diff options
author | Kozlov Dmitry <dima@server> | 2010-10-06 16:43:14 +0400 |
---|---|---|
committer | Kozlov Dmitry <dima@server> | 2010-10-06 16:43:14 +0400 |
commit | b6a1268714671904e96a49b88680dc3ff07aaa1c (patch) | |
tree | 60424372b94312710b9f583b1bcc641de4020316 /accel-pptpd | |
parent | 5cf93f33f2350ed3b92f73ead1d2829a6883810a (diff) | |
download | accel-ppp-b6a1268714671904e96a49b88680dc3ff07aaa1c.tar.gz accel-ppp-b6a1268714671904e96a49b88680dc3ff07aaa1c.zip |
project cleanup and prepare to release
Diffstat (limited to 'accel-pptpd')
23 files changed, 395 insertions, 138 deletions
diff --git a/accel-pptpd/CMakeLists.txt b/accel-pptpd/CMakeLists.txt index a8a6c04e..dd1b2570 100644 --- a/accel-pptpd/CMakeLists.txt +++ b/accel-pptpd/CMakeLists.txt @@ -1,6 +1,3 @@ -PROJECT (pptpd) -cmake_minimum_required(VERSION 2.6) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fvisibility=hidden -D_GNU_SOURCE -DGCC_SPINLOCK -DMEMDEBUG") INCLUDE_DIRECTORIES(include) @@ -33,13 +30,27 @@ ADD_EXECUTABLE(accel-pptpd iprange.c utils.c - sigchld.c log.c main.c memdebug.c ) + +SET( FALSE) +SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) + TARGET_LINK_LIBRARIES(accel-pptpd triton rt pthread ssl) +set_property(TARGET accel-pptpd PROPERTY CMAKE_SKIP_BUILD_RPATH FALSE) +set_property(TARGET accel-pptpd PROPERTY CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +set_property(TARGET accel-pptpd PROPERTY INSTALL_RPATH_USE_LINK_PATH FALSE) +set_property(TARGET accel-pptpd PROPERTY INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/usr/lib/accel-pptp) + +INSTALL(TARGETS accel-pptpd + RUNTIME DESTINATION usr/sbin +) + +INSTALL(FILES accel-pptp.conf DESTINATION /etc) +INSTALL(FILES accel-pptp.conf.5 DESTINATION usr/share/man/man5) -ADD_LIBRARY(ippool SHARED ippool.c) +INSTALL(CODE "EXECUTE_PROCESS(COMMAND mkdir -p /var/log/accel-pptp)") diff --git a/accel-pptpd/accel-pptpd.conf b/accel-pptpd/accel-pptp.conf index 80688d96..62c0f897 100644 --- a/accel-pptpd/accel-pptpd.conf +++ b/accel-pptpd/accel-pptp.conf @@ -1,4 +1,5 @@ [modules] +#path=/usr/local/lib/accel-pptp log_file #log_pgsql pptp @@ -6,12 +7,13 @@ auth_pap auth_chap_md5 auth_mschap_v1 auth_mschap_v2 -libradius.so -pppd_compat +radius ippool +sigchld +pppd_compat [core] -log-error=/dev/stderr +log-error=/var/log/accel-pptp/core.log thread-count=4 [ppp] @@ -28,40 +30,38 @@ echo-failure=3 echo-interval=30 verbose=1 +[dns] +#dns1=172.16.0.1 +#dns2=172.16.1.1 + [radius] -dictionary=../radius/dict/dictionary -nas-identifier=pptp +#dictionary=/usr/local/share/accel-pptp/dictionary +nas-identifier=accel-pptp nas-ip-address=127.0.0.1 -gw-ip-address=192.168.100.100 +gw-ip-address=192.168.100.1 auth_server=127.0.0.1:1812,testing123 acct_server=127.0.0.1:1813,testing123 dm_coa_secret=testing123 verbose=1 [client-ip-range] -192.168.10.20-30 -192.168.10.6/32 -192.168.10.1/24 -192.168.11.0/24 -192.168.0.0/24 +10.0.0.0/8 [ip-pool] -gw-ip-address=192.168.100.1 -#gw=192.168.100.210-211 -#tunnel=192.168.100.200-201 -192.168.100.2-255 -192.168.101.1-255 -192.168.102.1-255 -192.168.103.1-255 +gw-ip-address=192.168.0.1 +192.168.0.2-255 +192.168.1.1-255 +192.168.2.1-255 +192.168.3.1-255 [log] -log-file=general.log -log-emerg=/dev/stderr -log-debug=/dev/stdout +log-file=/var/log/accel-pptp/accel-pptp.log +log-emerg=/var/log/accel-pptp/emerg.log +#log-debug=/dev/stdout copy=1 #color=1 #per-user-dir=per_user -per-session-dir=per_session +#per-session-dir=per_session #per-session=1 level=3 @@ -70,8 +70,8 @@ conninfo=user=log log-table=log [pppd-compat] -ip-up=./ip-up.sh -ip-down=./ip-down.sh -ip-change=./ip-change.sh -radattr-prefix=./radattr +ip-up=/etc/ppp/ip-up +ip-down=/etc/ppp/ip-down +ip-change=/etc/ppp/ip-change +radattr-prefix=/var/run/radattr verbose=1 diff --git a/accel-pptpd/accel-pptp.conf.5 b/accel-pptpd/accel-pptp.conf.5 new file mode 100644 index 00000000..a983c7c9 --- /dev/null +++ b/accel-pptpd/accel-pptp.conf.5 @@ -0,0 +1,272 @@ +.TH ACCEL-PPTP.CONF 5 "6 October 2010" +.SH NAME +.B accel-pptp.conf +- ACCEL-PPTP VPN daemon configuration +.SH DESCRIPTION +.BR accel-pptpd (8) +reads options from this file, usually +.IR /etc/accel-pptp.conf +.TP +Configuration file consists of sections in form: +.TP +[section1] +.br +name1=val1 +.br +name2=val2 +.br +name3 +.TP +[section2] +.br + .... +.br +.SH SECTIONS +.TP +.SH [modules] +containes list of modules to load +.TP +.BI log_file +This is logging target which logs messages to files. It support per-session/per-user features. +.TP +.BI log_pgsql +This is logging target which logs messages to PostgreSQL. +.TP +.BI pptp +.br +PPTP controlling connection handling module. +.TP +.BI auth_pap +PAP authentication module. +.TP +.BI auth_chap +CHAP (md5) authentication module. +.TP +.BI auth_mschap_v1 +Microsoft CHAP (version 1) authentication module. +.TP +.BI auth_mschap_v2 +Microsoft CHAP (version 2) authentication module. +.TP +.BI radius +.br +RADIUS interaction module. +.TP +.BI ippool +.br +IP address assigning module. +.TP +.BI sigchld +Helper module to manage child processes, required by pppd_compat +.TP +.BI pppd_compat +This module starts pppd compatible ip-up/ip-down scripts and ip-change to handle RADIUS CoA request. +.TP +.SH [core] +Configuration of core module +.TP +.BI "log-error=" path +Path to file for core module error logging. +.TP +.BI "thread-count=" n +number of working threads, optimal - number of processors/cores +.TP +.SH [ppp] +.br +PPP module configuration. +.TP +.BI "verbose=" n +If n is not zero ppp module will produce verbose logging. +.TP +.BI "min-mtu=" n +Minimum acceptable MTU. If client will try to negotiate less then specified MTU then it will be NAKed or disconnected if rejects greater MTU. +.TP +.BI "mtu=" n +MTU which will be negotiated if client's MRU will be not acceptable. +.TP +.BI "mru=" n +Prefered MRU. +.TP +.SH [lcp] +.br +PPP LCP module configuration +.TP +.BI "echo-interval=" n +If this option is given and greater then 0 then lcp module will send echo-request every +.B n +seconds. +.TP +.BI "echo-failure=" n +Specifies maximum number of echo-requests may be sent without valid echo-reply, if exceeds connection will be terminated. +.TP +.SH [dns] +.TP +.BI "dns1=" x.x.x.x +Specifies primary DNS to be sent to peer. +.TP +.BI "dns2=" x.x.x.x +Specifies secondary DNS to be sent to peer. +.TP +.SH [client-ip-range] +You have to explicitly specify range of ip address from which clients can connect to server in form: +.br +.B x.x.x.x/mask +(for example 10.0.0.0/8) +.br +.B x.x.x.x-y +(for example 10.0.0.1-254) +.TP +.SH [pptp] +.br +Configuration of PPTP module. +.TP +.BI "bind=" x.x.x.x +If this option is given then pptp server will bind to specified IP address. +.TP +.BI "verbose=" n +If this option is given and +.B n +is greater of zero then pptp module will produce verbose logging. +.TP +.BI "echo-interval=" n +If this option is given and greater then zero then pptp module will send echo-request every +.B n +seconds. +.TP +.BI "echo-failure=" n +Specifies maximum number of echo-requests may be sent without valid echo-reply, if exceeds connection will be terminated. +.TP +.BI "timeout=" n +Timeout waiting reply from client in seconds (default 5). +.TP +.SH [radius] +.br +Configuration of RADIUS module. +.TP +.BI "nas-identifier=" identifier +Specifies value to send to RADIUS server in NAS-Identifier attribute and to be matched in DM/CoA requests. +.TP +.BI "nas-ip-address=" x.x.x.x +Specifies value to send to RADIUS server in NAS-IP-Address attribute and to be matched in DM/CoA requests. +Also DM/CoA server will bind to that address. +.TP +.BI "gw-ip-address=" x.x.x.x +Specifies address to use as local address of ppp interfaces if Framed-IP-Address received from RADIUS server. +.TP +.BI "auth_server=" x.x.x.x:port,secret +Specifies IP address, port and secret of authentication RADIUS server. +.TP +.BI "acct_server=" x.x.x.x:port,secret +Specifies IP address, port and secret of accounting RADIUS server. +.TP +.BI "dm_coa_secret=" secret +Specifies secret to use in DM/CoA communication. +.TP +.SH [log] +.br +Configuration of log and log_file modules. +.TP +.BI "log-file=" file +Path to file to write general log. +.TP +.BI "log-emerg=" file +Path to file to write emergency messages. +.TP +.BI "copy=" n +If this options is given and greater then zero logging engine will duplicate session log in general log. +(Useful when per-session/per-user logs are not used) +.TP +.BI "per-session-dir=" dir +Directory for session logs. If specified each session will be logged separately to file which name is unique session identifier. +.TP +.BI "per-user-dir=" dir +Directory for user logs. If specified all sessions of same user will be logged to file which name is user name. +.TP +.BI "per-session=" n +If specified and n is greater then zero each session of same user will be logger separately to directory specified by "per-user-dir" +and subdirectory which name is user name and to file which name os unique session identifier. +.TP +.BI "level=" n +Specifies log level which values are: +.br +.B 0 +turn off all logging +.br +.B 1 +log only error messages +.br +.B 2 +log error and warning messages +.br +.B 3 +log error, warning and information messages (use this level in conjuction with verbose option of other modules if you need verbose logging) +.br +.B 4 +log all messages including debug messages +.TP +.SH [log-pgsql] +.br +Configuration of log_pgsql module. +.TP +.BI "conninfo=" conninfo +Conninfo to connect to PostgreSQL server. +.TP +.BI "log-table=" table +Table to send log messages. Table must contain following field: +.br +.B timestamp +timestamp +.br +.B username +text +.br +.B sessionid +text +.br +.B msg +text +.TP +.SH [pppd_compat] +.br +Configuration of pppd_compat module. +.TP +.BI "ip-up=" file +Path to ip-up script which is executed when ppp interfaces is completly configured and started. +.TP +.BI "ip-down=" file +Path to ip-down script which is executed when session is about to terminate. +.TP +.BI "ip-change=" file +Path to ip-change script which is executed for RADIUS CoA handling. +.TP +.BI "radattr=" prefix +Prefix of radattr files (for example /var/run/radattr, resulting files will be /var/run/radattr.pppX) +.TP +.BI "verbose=" n +If specified and greated then zero pppd_module will produce verbose logging. +.TP +.SH [ip-pool] +.br +Configuration of ippool module. +.TP +.BI "gw-ip-address=" x.x.x.x +Specifies single IP address to be used as local address of ppp interfaces. +.TP +.BI "gw=" range +Specifies range of local address of ppp interfaces if form: +.br +.B x.x.x.x/mask +(for example 10.0.0.0/8) +.br +.B x.x.x.x-y +(for example 10.0.0.1-254) +.TP +.BI "tunnel=" range +Specifies range of remote address of ppp interfaces if form: +.br +.B x.x.x.x/mask +.br +.B x.x.x.x-y +.TP +.BI "x.x.x.x/mask or x.x.x.x-y" +Also specifies range of remote address of ppp interfaces. diff --git a/accel-pptpd/auth/CMakeLists.txt b/accel-pptpd/auth/CMakeLists.txt index f0e6465c..69b18b7b 100644 --- a/accel-pptpd/auth/CMakeLists.txt +++ b/accel-pptpd/auth/CMakeLists.txt @@ -3,3 +3,7 @@ ADD_LIBRARY(auth_chap_md5 SHARED auth_chap_md5.c) ADD_LIBRARY(auth_mschap_v1 SHARED auth_mschap_v1.c) ADD_LIBRARY(auth_mschap_v2 SHARED auth_mschap_v2.c) +INSTALL(TARGETS auth_pap auth_chap_md5 auth_mschap_v1 auth_mschap_v2 + LIBRARY DESTINATION usr/lib/accel-pptp +) + diff --git a/accel-pptpd/ctrl/CMakeLists.txt b/accel-pptpd/ctrl/CMakeLists.txt index 97f8e0d8..53b0dc1c 100644 --- a/accel-pptpd/ctrl/CMakeLists.txt +++ b/accel-pptpd/ctrl/CMakeLists.txt @@ -2,3 +2,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) ADD_LIBRARY(pptp SHARED pptp.c) +INSTALL(TARGETS pptp + LIBRARY DESTINATION usr/lib/accel-pptp +) + diff --git a/accel-pptpd/ctrl/pptp.c b/accel-pptpd/ctrl/pptp.c index 4f1146be..1151dabe 100644 --- a/accel-pptpd/ctrl/pptp.c +++ b/accel-pptpd/ctrl/pptp.c @@ -677,14 +677,19 @@ static void __init pptp_init(void) struct sockaddr_in addr; char *opt; - serv.hnd.fd = socket (PF_INET, SOCK_STREAM, 0); + serv.hnd.fd = socket(PF_INET, SOCK_STREAM, 0); if (serv.hnd.fd < 0) { log_emerg("pptp: failed to create server socket: %s\n", strerror(errno)); return; } addr.sin_family = AF_INET; - addr.sin_port = htons (PPTP_PORT); - addr.sin_addr.s_addr = htonl (INADDR_ANY); + addr.sin_port = htons(PPTP_PORT); + + opt = conf_get_opt("pptp", "bind"); + if (opt) + addr.sin_addr.s_addr = inet_addr(opt); + else + addr.sin_addr.s_addr = htonl(INADDR_ANY); setsockopt(serv.hnd.fd, SOL_SOCKET, SO_REUSEADDR, &serv.hnd.fd, 4); if (bind (serv.hnd.fd, (struct sockaddr *) &addr, sizeof (addr)) < 0) { diff --git a/accel-pptpd/extra/CMakeLists.txt b/accel-pptpd/extra/CMakeLists.txt index 7b4b69b6..a14a5a3b 100644 --- a/accel-pptpd/extra/CMakeLists.txt +++ b/accel-pptpd/extra/CMakeLists.txt @@ -1,2 +1,8 @@ ADD_LIBRARY(pppd_compat SHARED pppd_compat.c) +ADD_LIBRARY(ippool SHARED ippool.c) +ADD_LIBRARY(sigchld SHARED sigchld.c) + +INSTALL(TARGETS pppd_compat ippool sigchld + LIBRARY DESTINATION usr/lib/accel-pptp +) diff --git a/accel-pptpd/ippool.c b/accel-pptpd/extra/ippool.c index ec50a9bf..5f90fe8a 100644 --- a/accel-pptpd/ippool.c +++ b/accel-pptpd/extra/ippool.c @@ -7,7 +7,7 @@ #include "ipdb.h" #include "list.h" -#include "triton/spinlock.h" +#include "spinlock.h" #include "memdebug.h" diff --git a/accel-pptpd/extra/pppd_compat.c b/accel-pptpd/extra/pppd_compat.c index e45d609a..8dd35028 100644 --- a/accel-pptpd/extra/pppd_compat.c +++ b/accel-pptpd/extra/pppd_compat.c @@ -48,7 +48,7 @@ static void ip_up_handler(struct sigchld_handler_t *h, int status) struct pppd_compat_pd_t *pd = container_of(h, typeof(*pd), ip_up_hnd); if (conf_verbose) { log_switch(NULL, pd->ppp); - log_ppp_debug("pppd_compat: ip-up finished (%i)\n", status); + log_ppp_info("pppd_compat: ip-up finished (%i)\n", status); } } @@ -57,7 +57,7 @@ static void ip_down_handler(struct sigchld_handler_t *h, int status) struct pppd_compat_pd_t *pd = container_of(h, typeof(*pd), ip_down_hnd); if (conf_verbose) { log_switch(NULL, pd->ppp); - log_ppp_debug("pppd_compat: ip-down finished (%i)\n", status); + log_ppp_info("pppd_compat: ip-down finished (%i)\n", status); } sched_yield(); triton_context_wakeup(pd->ppp->ctrl->ctx); @@ -68,7 +68,7 @@ static void ip_change_handler(struct sigchld_handler_t *h, int status) struct pppd_compat_pd_t *pd = container_of(h, typeof(*pd), ip_change_hnd); if (conf_verbose) { log_switch(NULL, pd->ppp); - log_ppp_debug("pppd_compat: ip-change finished (%i)\n", status); + log_ppp_info("pppd_compat: ip-change finished (%i)\n", status); } sched_yield(); pd->ip_change_res = status; @@ -113,7 +113,7 @@ static void ev_ppp_started(struct ppp_t *ppp) pd->ip_up_hnd.pid = pid; sigchld_register_handler(&pd->ip_up_hnd); if (conf_verbose) - log_ppp_debug("pppd_compat: ip-up started (pid %i)\n", pid); + log_ppp_info("pppd_compat: ip-up started (pid %i)\n", pid); sigchld_unlock(); } else if (pid == 0) { execv(conf_ip_up, argv); @@ -156,7 +156,7 @@ static void ev_ppp_finished(struct ppp_t *ppp) pd->ip_down_hnd.pid = pid; sigchld_register_handler(&pd->ip_down_hnd); if (conf_verbose) - log_ppp_debug("pppd_compat: ip-down started (pid %i)\n", pid); + log_ppp_info("pppd_compat: ip-down started (pid %i)\n", pid); sigchld_unlock(); triton_context_schedule(pd->ppp->ctrl->ctx); pthread_mutex_lock(&pd->ip_down_hnd.lock); diff --git a/accel-pptpd/sigchld.c b/accel-pptpd/extra/sigchld.c index 19c76533..49bcfd43 100644 --- a/accel-pptpd/sigchld.c +++ b/accel-pptpd/extra/sigchld.c @@ -113,5 +113,5 @@ void __export sigchld_unlock() static void __init init(void) { if (pthread_create(&sigchld_thr, NULL, sigchld_thread, NULL)) - fprintf(stderr, "sigchld: pthread_create: %s\n", strerror(errno)); + log_emerg("sigchld: pthread_create: %s\n", strerror(errno)); } diff --git a/accel-pptpd/sigchld.h b/accel-pptpd/extra/sigchld.h index 27d1adf4..27d1adf4 100644 --- a/accel-pptpd/sigchld.h +++ b/accel-pptpd/extra/sigchld.h diff --git a/accel-pptpd/include/ppp_fsm.h b/accel-pptpd/include/ppp_fsm.h index 77f983d3..5c6b7f47 100644..120000 --- a/accel-pptpd/include/ppp_fsm.h +++ b/accel-pptpd/include/ppp_fsm.h @@ -1,69 +1 @@ -#ifndef PPP_FSM_H -#define PPP_FSM_H - -typedef enum {FSM_Initial=0,FSM_Starting,FSM_Closed,FSM_Stopped,FSM_Closing,FSM_Stopping,FSM_Req_Sent,FSM_Ack_Rcvd,FSM_Ack_Sent,FSM_Opened} FSM_STATE; -/* - * CP (LCP, IPCP, etc.) codes. - */ -#define CONFREQ 1 /* Configuration Request */ -#define CONFACK 2 /* Configuration Ack */ -#define CONFNAK 3 /* Configuration Nak */ -#define CONFREJ 4 /* Configuration Reject */ -#define TERMREQ 5 /* Termination Request */ -#define TERMACK 6 /* Termination Ack */ -#define CODEREJ 7 /* Code Reject */ -#define PROTOREJ 8 /* Code Reject */ -#define ECHOREQ 9 /* Echo Request */ -#define ECHOREP 10 /* Echo Reply */ - -struct ppp_t; - -struct ppp_fsm_t -{ - struct ppp_t *ppp; - FSM_STATE fsm_state; - uint16_t proto; - - struct triton_timer_t restart_timer; - int restart_counter; - int max_terminate; - int max_configure; - int max_failure; - int timeout; - int conf_failure; - - int id; - int recv_id; - - //fsm handling - void (*layer_up)(struct ppp_fsm_t*); - void (*layer_down)(struct ppp_fsm_t*); - void (*layer_started)(struct ppp_fsm_t*); - void (*layer_finished)(struct ppp_fsm_t*); - int (*send_conf_req)(struct ppp_fsm_t*); - void (*send_conf_ack)(struct ppp_fsm_t*); - void (*send_conf_nak)(struct ppp_fsm_t*); - void (*send_conf_rej)(struct ppp_fsm_t*); - void (*send_code_rej)(struct ppp_fsm_t*); -}; - -void ppp_fsm_init(struct ppp_fsm_t*); -void ppp_fsm_free(struct ppp_fsm_t*); - -int ppp_fsm_lower_up(struct ppp_fsm_t*); -void ppp_fsm_lower_down(struct ppp_fsm_t*); -int ppp_fsm_open(struct ppp_fsm_t*); -void ppp_fsm_close(struct ppp_fsm_t*); -void ppp_fsm_timeout0(struct ppp_fsm_t *layer); -void ppp_fsm_timeout1(struct ppp_fsm_t *layer); -void ppp_fsm_recv_conf_req_ack(struct ppp_fsm_t *layer); -void ppp_fsm_recv_conf_req_nak(struct ppp_fsm_t *layer); -void ppp_fsm_recv_conf_req_rej(struct ppp_fsm_t *layer); -void ppp_fsm_recv_conf_ack(struct ppp_fsm_t *layer); -void ppp_fsm_recv_conf_rej(struct ppp_fsm_t *layer); -void ppp_fsm_recv_term_req(struct ppp_fsm_t *layer); -void ppp_fsm_recv_term_ack(struct ppp_fsm_t *layer); -void ppp_fsm_recv_unk(struct ppp_fsm_t *layer); -void ppp_fsm_recv_code_rej_bad(struct ppp_fsm_t *layer); - -#endif +../ppp/ppp_fsm.h
\ No newline at end of file diff --git a/accel-pptpd/include/sigchld.h b/accel-pptpd/include/sigchld.h index 166c77e6..9b74ebdb 120000 --- a/accel-pptpd/include/sigchld.h +++ b/accel-pptpd/include/sigchld.h @@ -1 +1 @@ -../sigchld.h
\ No newline at end of file +../extra/sigchld.h
\ No newline at end of file diff --git a/accel-pptpd/logs/CMakeLists.txt b/accel-pptpd/logs/CMakeLists.txt index 4282761b..f1b09ca8 100644 --- a/accel-pptpd/logs/CMakeLists.txt +++ b/accel-pptpd/logs/CMakeLists.txt @@ -1,4 +1,13 @@ ADD_LIBRARY(log_file SHARED log_file.c) -ADD_LIBRARY(log_pgsql SHARED log_pgsql.c) -TARGET_LINK_LIBRARIES(log_pgsql pq) +INSTALL(TARGETS log_file + LIBRARY DESTINATION usr/lib/accel-pptp +) + +IF(LOG_PGSQL) + ADD_LIBRARY(log_pgsql SHARED log_pgsql.c) + TARGET_LINK_LIBRARIES(log_pgsql pq) + INSTALL(TARGETS log_pgsql + LIBRARY DESTINATION usr/lib/accel-pptp + ) +ENDIF(LOG_PGSQL) diff --git a/accel-pptpd/main.c b/accel-pptpd/main.c index b543f0d8..e261fbb4 100644 --- a/accel-pptpd/main.c +++ b/accel-pptpd/main.c @@ -9,6 +9,7 @@ #include "triton/triton.h" #include "memdebug.h" +#include "log.h" static int goto_daemon; static char *pid_file; @@ -85,11 +86,8 @@ int main(int argc, char **argv) sigset_t set; int sig; - if (triton_load_modules("modules")) - return EXIT_FAILURE; - if (goto_daemon) { - pid_t pid = fork(); + /*pid_t pid = fork(); if (pid > 0) _exit(EXIT_SUCCESS); if (pid < 0) { @@ -105,7 +103,8 @@ int main(int argc, char **argv) chdir("/"); close(STDIN_FILENO); close(STDOUT_FILENO); - close(STDERR_FILENO); + close(STDERR_FILENO);*/ + daemon(0, 0); } if (pid_file) { @@ -119,6 +118,9 @@ int main(int argc, char **argv) //signal(SIGTERM, sigterm); //signal(SIGPIPE, sigterm); + if (triton_load_modules("modules")) + return EXIT_FAILURE; + triton_run(); sigfillset(&set); @@ -144,7 +146,7 @@ int main(int argc, char **argv) sigaddset(&set, SIGBUS); sigwait(&set, &sig); - printf("terminate, sig = %i\n", sig); + log_info("terminate, sig = %i\n", sig); triton_terminate(); diff --git a/accel-pptpd/radius/CMakeLists.txt b/accel-pptpd/radius/CMakeLists.txt index c8c44f80..b82512e9 100644 --- a/accel-pptpd/radius/CMakeLists.txt +++ b/accel-pptpd/radius/CMakeLists.txt @@ -1,4 +1,3 @@ -SET(target radius) SET(sources radius.c dict.c @@ -9,5 +8,13 @@ SET(sources dm_coa.c ) +ADD_DEFINITIONS(-DDICT_PATH="${CMAKE_INSTALL_PREFIX}/usr/share/accel-pptp/dictionary") + ADD_LIBRARY(radius SHARED ${sources}) +INSTALL(TARGETS radius + LIBRARY DESTINATION usr/lib/accel-pptp +) +FILE(GLOB dict "${CMAKE_CURRENT_SOURCE_DIR}/dict/*") +INSTALL(FILES ${dict} DESTINATION usr/share/accel-pptp) + diff --git a/accel-pptpd/radius/dm_coa.c b/accel-pptpd/radius/dm_coa.c index e0343210..64fe97ac 100644 --- a/accel-pptpd/radius/dm_coa.c +++ b/accel-pptpd/radius/dm_coa.c @@ -246,11 +246,11 @@ static struct dm_coa_serv_t serv = { static void __init init(void) { - struct sockaddr_in addr; + struct sockaddr_in addr; serv.hnd.fd = socket (PF_INET, SOCK_DGRAM, 0); if (serv.hnd.fd < 0) { - log_error("radius:dm_coa: socket: %s\n", strerror(errno)); + log_emerg("radius:dm_coa: socket: %s\n", strerror(errno)); return; } addr.sin_family = AF_INET; @@ -260,13 +260,13 @@ static void __init init(void) else addr.sin_addr.s_addr = htonl (INADDR_ANY); if (bind (serv.hnd.fd, (struct sockaddr *) &addr, sizeof (addr)) < 0) { - log_error("radius:dm_coa: bind: %s\n", strerror(errno)); + log_emerg("radius:dm_coa: bind: %s\n", strerror(errno)); close(serv.hnd.fd); return; } if (fcntl(serv.hnd.fd, F_SETFL, O_NONBLOCK)) { - log_error("radius:dm_coa: failed to set nonblocking mode: %s\n", strerror(errno)); + log_emerg("radius:dm_coa: failed to set nonblocking mode: %s\n", strerror(errno)); close(serv.hnd.fd); return; } diff --git a/accel-pptpd/radius/radius.c b/accel-pptpd/radius/radius.c index 99d9a3ed..9f5c7ffc 100644 --- a/accel-pptpd/radius/radius.c +++ b/accel-pptpd/radius/radius.c @@ -309,6 +309,7 @@ static int parse_server(const char *opt, char **name, int *port, char **secret) static void __init radius_init(void) { char *opt; + char *dict = DICT_PATH; rpd_pool = mempool_create(sizeof(struct radius_pd_t)); @@ -338,16 +339,16 @@ static void __init radius_init(void) opt = conf_get_opt("radius", "auth_server"); if (!opt) { - log_error("radius: auth_server not specified\n"); + log_emerg("radius: auth_server not specified\n"); _exit(EXIT_FAILURE); } else if (parse_server(opt, &conf_auth_server, &conf_auth_server_port, &conf_auth_secret)) { - log_error("radius: failed to parse auth_server\n"); + log_emerg("radius: failed to parse auth_server\n"); _exit(EXIT_FAILURE); } opt = conf_get_opt("radius", "acct_server"); if (opt && parse_server(opt, &conf_acct_server, &conf_acct_server_port, &conf_acct_secret)) { - log_error("radius: failed to parse acct_server\n"); + log_emerg("radius: failed to parse acct_server\n"); _exit(EXIT_FAILURE); } @@ -356,11 +357,10 @@ static void __init radius_init(void) conf_dm_coa_secret = opt; opt = conf_get_opt("radius", "dictionary"); - if (!opt) { - fprintf(stderr, "radius: dictionary not specified\n"); - _exit(EXIT_FAILURE); - } - if (rad_dict_load(opt)) + if (opt) + dict = opt; + + if (rad_dict_load(dict)) _exit(EXIT_FAILURE); pwdb_register(&pwdb); @@ -371,4 +371,3 @@ static void __init radius_init(void) triton_event_register_handler(EV_PPP_FINISHING, (triton_event_func)ppp_finishing); triton_event_register_handler(EV_PPP_FINISHED, (triton_event_func)ppp_finished); } - diff --git a/accel-pptpd/radius/req.c b/accel-pptpd/radius/req.c index bdd02b9d..f3f41386 100644 --- a/accel-pptpd/radius/req.c +++ b/accel-pptpd/radius/req.c @@ -236,7 +236,7 @@ void __init req_init(void) { urandom_fd = open("/dev/urandom", O_RDONLY); if (!urandom_fd) { - perror("radius:req: open /dev/urandom"); + log_emerg("radius:req: open /dev/urandom: %s\n", strerror(errno)); _exit(EXIT_FAILURE); } } diff --git a/accel-pptpd/triton/CMakeLists.txt b/accel-pptpd/triton/CMakeLists.txt index 95ab4160..3e5e068a 100644 --- a/accel-pptpd/triton/CMakeLists.txt +++ b/accel-pptpd/triton/CMakeLists.txt @@ -1,4 +1,3 @@ -SET(target triton) SET(sources_c md.c timer.c @@ -9,7 +8,13 @@ SET(sources_c mempool.c event.c ) + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) -ADD_LIBRARY(${target} SHARED ${sources_c}) +ADD_DEFINITIONS(-DMODULE_PATH="${CMAKE_INSTALL_PREFIX}/usr/lib/accel-pptp") + +ADD_LIBRARY(triton SHARED ${sources_c}) +INSTALL(TARGETS triton + LIBRARY DESTINATION usr/lib/accel-pptp +) diff --git a/accel-pptpd/triton/loader.c b/accel-pptpd/triton/loader.c index 0fef03da..b6c1914e 100644 --- a/accel-pptpd/triton/loader.c +++ b/accel-pptpd/triton/loader.c @@ -15,7 +15,7 @@ int load_modules(const char *name) struct conf_sect_t *sect; struct conf_option_t *opt; char *fname; - char *path="."; + char *path = MODULE_PATH; sect = conf_get_section(name); if (!sect) { diff --git a/accel-pptpd/triton/log.c b/accel-pptpd/triton/log.c index 7bb55598..c7e6b7fe 100644 --- a/accel-pptpd/triton/log.c +++ b/accel-pptpd/triton/log.c @@ -46,6 +46,8 @@ static void do_log(FILE *f, const char *fmt, va_list ap) fprintf(f, "[%s.%i]", date, (int)tv.tv_usec / 1000); vfprintf(f, fmt,ap); pthread_mutex_unlock(&lock); + + fflush(f); } void triton_log_error(const char *fmt,...) { diff --git a/accel-pptpd/triton/mempool.c b/accel-pptpd/triton/mempool.c index 16d6ab3c..c96c3ba2 100644 --- a/accel-pptpd/triton/mempool.c +++ b/accel-pptpd/triton/mempool.c @@ -177,4 +177,3 @@ static void __init init(void) { signal(35, sigclean); } - |