|
|
| version 1.1.1.1, 2012/02/21 23:32:47 | version 1.1.1.4, 2021/03/17 00:39:23 |
|---|---|
| Line 26 | Line 26 |
| #include "ccp_mppc.h" | #include "ccp_mppc.h" |
| #endif | #endif |
| #ifdef USE_BACKTRACE | |
| #include <execinfo.h> | |
| #endif | |
| #include <netgraph.h> | #include <netgraph.h> |
| /* | /* |
| Line 47 | Line 50 |
| }; | }; |
| typedef struct option *Option; | typedef struct option *Option; |
| static const char *UsageStr = "[options] [system]"; | static const char *UsageStr = "[options] [configuration]"; |
| static struct option OptList[] = { | static struct option OptList[] = { |
| { 0, 'b', "background", "", | { 0, 'b', "background", "", |
| "Run as a background daemon" }, | "Run as a background daemon" }, |
| Line 65 | Line 68 |
| { 1, 's', "syslog-ident", "ident", | { 1, 's', "syslog-ident", "ident", |
| "Identifier to use for syslog" }, | "Identifier to use for syslog" }, |
| #endif | #endif |
| #ifdef USE_PAM | |
| { 1, 'm', "pam-service", "service", | |
| "PAM service name" }, | |
| #endif | |
| { 0, 'v', "version", "", | { 0, 'v', "version", "", |
| "Show version information" }, | "Show version information" }, |
| { 0, 'h', "help", "", | { 0, 'h', "help", "", |
| Line 99 | Line 106 |
| #ifdef PHYSTYPE_PPTP | #ifdef PHYSTYPE_PPTP |
| int gPPTPto = 10; | int gPPTPto = 10; |
| int gPPTPtunlimit = 100; | unsigned gPPTPtunlimit = 100; |
| #endif | #endif |
| #ifdef PHYSTYPE_L2TP | #ifdef PHYSTYPE_L2TP |
| int gL2TPto = 10; | int gL2TPto = 10; |
| #if ((__FreeBSD_version > 603100 && __FreeBSD_version < 700000) || __FreeBSD_version >= 700055) | #if ((__FreeBSD_version > 603100 && __FreeBSD_version < 700000) || __FreeBSD_version >= 700055) |
| int gL2TPtunlimit = 100; | unsigned gL2TPtunlimit = 100; |
| #else | #else |
| int gL2TPtunlimit = 10; | unsigned gL2TPtunlimit = 10; |
| #endif | #endif |
| #endif | #endif |
| int gChildren = 0; /* Current number of children links */ | int gChildren = 0; /* Current number of children links */ |
| Line 116 | Line 123 |
| struct acl *acl_filters[ACL_FILTERS]; /* mpd's global internal bpf filters */ | struct acl *acl_filters[ACL_FILTERS]; /* mpd's global internal bpf filters */ |
| #endif | #endif |
| #ifdef USE_PAM | |
| char gPamService[32]; | |
| #endif | |
| struct globalconf gGlobalConf; | struct globalconf gGlobalConf; |
| pthread_mutex_t gGiantMutex; | pthread_mutex_t gGiantMutex; |
| Line 163 main(int ac, char *av[]) | Line 174 main(int ac, char *av[]) |
| int ret, k; | int ret, k; |
| char *args[MAX_ARGS]; | char *args[MAX_ARGS]; |
| Context c; | Context c; |
| PhysType pt; | const struct phystype *pt; |
| gPid=getpid(); | gPid = getpid(); |
| /* enable libpdel typed_mem */ | /* enable libpdel typed_mem */ |
| typed_mem_enable(); | typed_mem_enable(); |
| Line 202 main(int ac, char *av[]) | Line 213 main(int ac, char *av[]) |
| RadsrvInit(&gRadsrv); | RadsrvInit(&gRadsrv); |
| #endif | #endif |
| #ifdef USE_PAM | |
| if (!*gPamService) | |
| strcpy(gPamService, "mpd"); | |
| #endif | |
| /* Set up libnetgraph logging */ | /* Set up libnetgraph logging */ |
| NgSetErrLog(NgFuncErr, NgFuncErrx); | NgSetErrLog(NgFuncErr, NgFuncErrx); |
| Line 251 main(int ac, char *av[]) | Line 268 main(int ac, char *av[]) |
| } | } |
| /* Create signaling pipe */ | /* Create signaling pipe */ |
| if ((ret = pipe(gSignalPipe)) != 0) { | if (pipe(gSignalPipe) < 0) { |
| Log(LG_ERR, ("Could not create signal pipe %d", ret)); | Perror("Could not create signal pipe"); |
| exit(EX_UNAVAILABLE); | exit(EX_UNAVAILABLE); |
| } | } |
| if (EventRegister(&gSignalEvent, EVENT_READ, gSignalPipe[0], | if (EventRegister(&gSignalEvent, EVENT_READ, gSignalPipe[0], |
| Line 306 static void | Line 323 static void |
| ConfigRead(int type, void *arg) | ConfigRead(int type, void *arg) |
| { | { |
| Context c = (Context)arg; | Context c = (Context)arg; |
| int err; | |
| (void)type; | |
| /* Read startup configuration section */ | /* Read startup configuration section */ |
| ReadFile(gConfigFile, STARTUP_CONF, DoCommand, c); | err = ReadFile(gConfigFile, STARTUP_CONF, DoCommand, c); |
| /* Read configuration as specified on the command line, or default */ | /* Read configuration as specified on the command line, or default */ |
| if (!gPeerSystem) | if (!gPeerSystem) { |
| ReadFile(gConfigFile, DEFAULT_CONF, DoCommand, c); | if (err != -2) |
| else { | ReadFile(gConfigFile, DEFAULT_CONF, DoCommand, c); |
| if (ReadFile(gConfigFile, gPeerSystem, DoCommand, c) < 0) { | } else { |
| if (err == -2 || ReadFile(gConfigFile, gPeerSystem, DoCommand, c) < 0) { | |
| Log(LG_ERR, ("can't read configuration for \"%s\"", gPeerSystem)); | Log(LG_ERR, ("can't read configuration for \"%s\"", gPeerSystem)); |
| DoExit(EX_CONFIG); | DoExit(EX_CONFIG); |
| } | } |
| Line 355 DoExit(int code) | Line 375 DoExit(int code) |
| Bund b; | Bund b; |
| Rep r; | Rep r; |
| Link l; | Link l; |
| PhysType pt; | const struct phystype *pt; |
| int k; | int k; |
| gShutdownInProgress=1; | gShutdownInProgress=1; |
| Line 429 SignalHandler(int type, void *arg) | Line 449 SignalHandler(int type, void *arg) |
| { | { |
| u_char sig; | u_char sig; |
| (void)type; | |
| (void)arg; | |
| read(gSignalPipe[0], &sig, sizeof(sig)); | read(gSignalPipe[0], &sig, sizeof(sig)); |
| switch(sig) { | switch(sig) { |
| Line 455 FatalSignal(int sig) | Line 477 FatalSignal(int sig) |
| static struct pppTimer gDeathTimer; | static struct pppTimer gDeathTimer; |
| int k; | int k; |
| int upLinkCount; | int upLinkCount; |
| #ifdef USE_BACKTRACE | |
| void *buffer[100]; | |
| char **strings; | |
| int n; | |
| #endif | |
| /* If a SIGTERM or SIGINT, gracefully shutdown; otherwise shutdown now */ | /* If a SIGTERM or SIGINT, gracefully shutdown; otherwise shutdown now */ |
| Log(LG_ERR, ("caught fatal signal %s", sys_signame[sig])); | Log(LG_ERR, ("caught fatal signal %s", sys_signame[sig])); |
| gShutdownInProgress=1; | gShutdownInProgress=1; |
| #ifdef USE_BACKTRACE | |
| if (sig != SIGTERM && sig != SIGINT) { | |
| n = backtrace(buffer, 100); | |
| strings = backtrace_symbols(buffer, n); | |
| if (strings == NULL) { | |
| Log(LG_ERR, ("No backtrace symbols found")); | |
| } else { | |
| for (k = 0; k < n; k++) { | |
| Log(LG_ERR, ("%s", strings[k])); | |
| } | |
| free(strings); | |
| } | |
| } | |
| #endif | |
| for (k = 0; k < gNumBundles; k++) { | for (k = 0; k < gNumBundles; k++) { |
| if ((b = gBundles[k])) { | if ((b = gBundles[k])) { |
| if (sig != SIGTERM && sig != SIGINT) | if (sig != SIGTERM && sig != SIGINT) |
| Line 590 OptApply(Option opt, int ac, char *av[]) | Line 631 OptApply(Option opt, int ac, char *av[]) |
| #ifdef SYSLOG_FACILITY | #ifdef SYSLOG_FACILITY |
| memset(gSysLogIdent, 0, sizeof(gSysLogIdent)); | memset(gSysLogIdent, 0, sizeof(gSysLogIdent)); |
| #endif | #endif |
| #ifdef USE_PAM | |
| memset(gPamService, 0, sizeof(gPamService)); | |
| #endif | |
| if (opt == NULL) | if (opt == NULL) |
| Usage(EX_USAGE); | Usage(EX_USAGE); |
| Line 619 OptApply(Option opt, int ac, char *av[]) | Line 663 OptApply(Option opt, int ac, char *av[]) |
| strlcpy(gSysLogIdent, *av, sizeof(gSysLogIdent)); | strlcpy(gSysLogIdent, *av, sizeof(gSysLogIdent)); |
| return(1); | return(1); |
| #endif | #endif |
| #ifdef USE_PAM | |
| case 'm': | |
| strlcpy(gPamService, *av, sizeof(gPamService)); | |
| return(1); | |
| #endif | |
| case 'v': | case 'v': |
| fprintf(stderr, "Version %s\n", gVersion); | fprintf(stderr, "Version %s\n", gVersion); |
| exit(EX_NORMAL); | exit(EX_NORMAL); |
| Line 666 Usage(int ex) | Line 715 Usage(int ex) |
| opt = OptList + k; | opt = OptList + k; |
| snprintf(buf, sizeof(buf), " -%c, --%-s %s", | snprintf(buf, sizeof(buf), " -%c, --%-s %s", |
| opt->sflag, opt->lflag, opt->usage); | opt->sflag, opt->lflag, opt->usage); |
| fprintf(stderr, "%-40s%s\n", buf, opt->desc); | fprintf(stderr, "%-35s%s\n", buf, opt->desc); |
| } | } |
| exit(ex); | exit(ex); |
| } | } |