From: Paul Mackerras Date: Tue, 9 Aug 2022 09:42:51 +0000 (+1000) Subject: Merge pull request #358 from enaess/ppp-autotools X-Git-Tag: ppp-2.5.0~28 X-Git-Url: http://git.ozlabs.org/?a=commitdiff_plain;h=8cbd7dd098cbb565dd9b01397fb352f1c98376f3;hp=e5d80f67d27e2696154171023a40838b7c2a2544;p=ppp.git Merge pull request #358 from enaess/ppp-autotools PPP autotools --- diff --git a/configure.ac b/configure.ac index 5a134fa..640f70e 100644 --- a/configure.ac +++ b/configure.ac @@ -17,8 +17,8 @@ AC_CONFIG_HEADERS([pppd/config.h pppd/pppdconf.h pppd/plugins/pppoe/config.h]) AC_PROG_CC AM_PROG_CC_C_O AC_PROG_INSTALL -AC_PROG_LIBTOOL AC_PROG_LN_S +LT_INIT PKG_PROG_PKG_CONFIG @@ -194,7 +194,7 @@ AS_IF([test "x$enable_openssl_engine" != "xno"], [], # # Specify runtime directory AC_ARG_WITH([plugin-dir], - AC_HELP_STRING([--with-plugin-dir=DIR], [Specify the plugin directory for pppd])) + AS_HELP_STRING([--with-plugin-dir=DIR],[Specify the plugin directory for pppd])) AS_IF([test -n "$with_plugin_dir"], [PPPD_PLUGIN_DIR="$with_plugin_dir"], [PPPD_PLUGIN_DIR="${libdir}/pppd/$VERSION"]) @@ -203,19 +203,19 @@ AC_SUBST(PPPD_PLUGIN_DIR, "$PPPD_PLUGIN_DIR", [The pppd plugin directory]) # # Specify runtime directory AC_ARG_WITH([runtime-dir], - AC_HELP_STRING([--with-runtime-dir=DIR], [Specify the runtime directory for pppd])) + AS_HELP_STRING([--with-runtime-dir=DIR],[Specify the runtime directory for pppd])) AS_IF([test -n "$with_runtime_dir"], [PPPD_RUNTIME_DIR="$with_runtime_dir"], - [PPPD_RUNTIME_DIR="${localstatedir}/run/pppd"]) + [PPPD_RUNTIME_DIR="${runstatedir}/pppd"]) AC_SUBST(PPPD_RUNTIME_DIR) # # Specify runtime directory AC_ARG_WITH([logfile-dir], - AC_HELP_STRING([--with-logfile-dir=DIR], [Specify the log directory for pppd])) + AS_HELP_STRING([--with-logfile-dir=DIR],[Specify the log directory for pppd])) AS_IF([test -n "$with_logfile_dir"], [PPPD_LOGFILE_DIR="$with_logfile_dir"], - [PPPD_LOGFILE_DIR="${localstatedir}/log/pppd"]) + [PPPD_LOGFILE_DIR="${localstatedir}/log/ppp"]) AC_SUBST(PPPD_LOGFILE_DIR) # diff --git a/pppd/Makefile.am b/pppd/Makefile.am index 7dc6cdd..b392f2e 100644 --- a/pppd/Makefile.am +++ b/pppd/Makefile.am @@ -68,7 +68,7 @@ pppd_SOURCES = \ upap.c \ utils.c -pppd_CPPFLAGS = -DPPPD_RUNTIME_DIR='"@PPPD_RUNTIME_DIR@"' -DPPPD_LOGFILE_DIR='"@PPPD_LOGFILE_DIR@"' +pppd_CPPFLAGS = -DSYSCONFDIR=\"${sysconfdir}\" -DLOCALSTATEDIR=\"${localstatedir}\" -DPPPD_RUNTIME_DIR='"@PPPD_RUNTIME_DIR@"' -DPPPD_LOGFILE_DIR='"@PPPD_LOGFILE_DIR@"' pppd_LDFLAGS = pppd_LIBS = diff --git a/pppd/auth.c b/pppd/auth.c index fc28390..5c64f28 100644 --- a/pppd/auth.c +++ b/pppd/auth.c @@ -750,7 +750,7 @@ link_down(int unit) if (auth_script_state == s_up && auth_script_pid == 0) { update_link_stats(unit); auth_script_state = s_down; - auth_script(_PATH_AUTHDOWN); + auth_script(PPP_PATH_AUTHDOWN); } } if (!doing_multilink) { @@ -899,7 +899,7 @@ network_phase(int unit) auth_state = s_up; if (auth_script_state == s_down && auth_script_pid == 0) { auth_script_state = s_up; - auth_script(_PATH_AUTHUP); + auth_script(PPP_PATH_AUTHUP); } } @@ -1489,7 +1489,7 @@ check_passwd(int unit, * Open the file of pap secrets and scan for a suitable secret * for authenticating this user. */ - filename = _PATH_UPAPFILE; + filename = PPP_PATH_UPAPFILE; addrs = opts = NULL; ret = UPAP_AUTHNAK; f = fopen(filename, "r"); @@ -1590,7 +1590,7 @@ null_login(int unit) * Open the file of pap secrets and scan for a suitable secret. */ if (ret <= 0) { - filename = _PATH_UPAPFILE; + filename = PPP_PATH_UPAPFILE; addrs = NULL; f = fopen(filename, "r"); if (f == NULL) @@ -1637,7 +1637,7 @@ get_pap_passwd(char *passwd) return ret; } - filename = _PATH_UPAPFILE; + filename = PPP_PATH_UPAPFILE; f = fopen(filename, "r"); if (f == NULL) return 0; @@ -1674,7 +1674,7 @@ have_pap_secret(int *lacks_ipp) return ret; } - filename = _PATH_UPAPFILE; + filename = PPP_PATH_UPAPFILE; f = fopen(filename, "r"); if (f == NULL) return 0; @@ -1716,7 +1716,7 @@ have_chap_secret(char *client, char *server, } } - filename = _PATH_CHAPFILE; + filename = PPP_PATH_CHAPFILE; f = fopen(filename, "r"); if (f == NULL) return 0; @@ -1754,7 +1754,7 @@ have_srp_secret(char *client, char *server, int need_ip, int *lacks_ipp) char *filename; struct wordlist *addrs; - filename = _PATH_SRPFILE; + filename = PPP_PATH_SRPFILE; f = fopen(filename, "r"); if (f == NULL) return 0; @@ -1802,7 +1802,7 @@ get_secret(int unit, char *client, char *server, return 0; } } else { - filename = _PATH_CHAPFILE; + filename = PPP_PATH_CHAPFILE; addrs = NULL; secbuf[0] = 0; @@ -1856,7 +1856,7 @@ get_srp_secret(int unit, char *client, char *server, if (!am_server && passwd[0] != '\0') { strlcpy(secret, passwd, MAXWORDLEN); } else { - filename = _PATH_SRPFILE; + filename = PPP_PATH_SRPFILE; addrs = NULL; fp = fopen(filename, "r"); @@ -2359,13 +2359,13 @@ auth_script_done(void *arg) case s_up: if (auth_state == s_down) { auth_script_state = s_down; - auth_script(_PATH_AUTHDOWN); + auth_script(PPP_PATH_AUTHDOWN); } break; case s_down: if (auth_state == s_up) { auth_script_state = s_up; - auth_script(_PATH_AUTHUP); + auth_script(PPP_PATH_AUTHUP); } break; } @@ -2419,7 +2419,7 @@ have_eaptls_secret_server(char *client, char *server, char cacertfile[MAXWORDLEN]; char pkfile[MAXWORDLEN]; - filename = _PATH_EAPTLSSERVFILE; + filename = PPP_PATH_EAPTLSSERVFILE; f = fopen(filename, "r"); if (f == NULL) return 0; @@ -2476,7 +2476,7 @@ have_eaptls_secret_client(char *client, char *server) if (pkcs12_file) return 1; - filename = _PATH_EAPTLSCLIFILE; + filename = PPP_PATH_EAPTLSCLIFILE; f = fopen(filename, "r"); if (f == NULL) return 0; @@ -2694,7 +2694,7 @@ get_eaptls_secret(int unit, char *client, char *server, } else { - filename = (am_server ? _PATH_EAPTLSSERVFILE : _PATH_EAPTLSCLIFILE); + filename = (am_server ? PPP_PATH_EAPTLSSERVFILE : PPP_PATH_EAPTLSCLIFILE); addrs = NULL; fp = fopen(filename, "r"); diff --git a/pppd/eap-tls.c b/pppd/eap-tls.c index 69e34a1..a7e444d 100644 --- a/pppd/eap-tls.c +++ b/pppd/eap-tls.c @@ -158,10 +158,10 @@ CONF *eaptls_ssl_load_config( void ) config = NCONF_new( NULL ); dbglog( "Loading OpenSSL config file" ); - ret_code = NCONF_load( config, _PATH_OPENSSLCONFFILE, &error_line ); + ret_code = NCONF_load( config, PPP_PATH_OPENSSLCONFFILE, &error_line ); if (ret_code == 0) { - warn( "EAP-TLS: Error in OpenSSL config file %s at line %d", _PATH_OPENSSLCONFFILE, error_line ); + warn( "EAP-TLS: Error in OpenSSL config file %s at line %d", PPP_PATH_OPENSSLCONFFILE, error_line ); NCONF_free( config ); config = NULL; ERR_clear_error(); diff --git a/pppd/eap.c b/pppd/eap.c index 4ad67a5..305a838 100644 --- a/pppd/eap.c +++ b/pppd/eap.c @@ -1503,7 +1503,7 @@ name_of_pn_file(void) errno = EINVAL; return (NULL); } - file = _PATH_PSEUDONYM; + file = PPP_PATH_PSEUDONYM; pl = strlen(user) + strlen(file) + 2; path = malloc(pl); if (path == NULL) diff --git a/pppd/ipcp.c b/pppd/ipcp.c index e3e8112..776f06f 100644 --- a/pppd/ipcp.c +++ b/pppd/ipcp.c @@ -1767,7 +1767,7 @@ ip_demand_conf(int u) } if (!sifaddr(u, wo->ouraddr, wo->hisaddr, GetMask(wo->ouraddr))) return 0; - ipcp_script(_PATH_IPPREUP, 1); + ipcp_script(PPP_PATH_IPPREUP, 1); if (!sifup(u)) return 0; if (!sifnpmode(u, PPP_IP, NPMODE_QUEUE)) @@ -1933,7 +1933,7 @@ ipcp_up(fsm *f) ifindex = if_nametoindex(ifname); /* run the pre-up script, if any, and wait for it to finish */ - ipcp_script(_PATH_IPPREUP, 1); + ipcp_script(PPP_PATH_IPPREUP, 1); /* check if preup script renamed the interface */ if (!if_indextoname(ifindex, ifname)) { @@ -2153,9 +2153,9 @@ create_resolv(u_int32_t peerdns1, u_int32_t peerdns2) { FILE *f; - f = fopen(_PATH_RESOLV, "w"); + f = fopen(PPP_PATH_RESOLV, "w"); if (f == NULL) { - error("Failed to create %s: %m", _PATH_RESOLV); + error("Failed to create %s: %m", PPP_PATH_RESOLV); return; } @@ -2166,7 +2166,7 @@ create_resolv(u_int32_t peerdns1, u_int32_t peerdns2) fprintf(f, "nameserver %s\n", ip_ntoa(peerdns2)); if (ferror(f)) - error("Write failed to %s: %m", _PATH_RESOLV); + error("Write failed to %s: %m", PPP_PATH_RESOLV); fclose(f); } diff --git a/pppd/main.c b/pppd/main.c index 49319e2..7e47752 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -294,12 +294,12 @@ main(int argc, char *argv[]) struct protent *protp; char numbuf[16]; - strlcpy(path_ipup, _PATH_IPUP, MAXPATHLEN); - strlcpy(path_ipdown, _PATH_IPDOWN, MAXPATHLEN); + strlcpy(path_ipup, PPP_PATH_IPUP, MAXPATHLEN); + strlcpy(path_ipdown, PPP_PATH_IPDOWN, MAXPATHLEN); #ifdef PPP_WITH_IPV6CP - strlcpy(path_ipv6up, _PATH_IPV6UP, MAXPATHLEN); - strlcpy(path_ipv6down, _PATH_IPV6DOWN, MAXPATHLEN); + strlcpy(path_ipv6up, PPP_PATH_IPV6UP, MAXPATHLEN); + strlcpy(path_ipv6down, PPP_PATH_IPV6DOWN, MAXPATHLEN); #endif link_stats_valid = 0; new_phase(PHASE_INITIALIZE); @@ -348,7 +348,7 @@ main(int argc, char *argv[]) * Parse, in order, the system options file, the user's options file, * and the command line arguments. */ - if (!options_from_file(_PATH_SYSOPTIONS, !privileged, 0, 1) + if (!options_from_file(PPP_PATH_SYSOPTIONS, !privileged, 0, 1) || !options_from_user() || !parse_args(argc-1, argv+1)) exit(EXIT_OPTION_ERROR); @@ -405,9 +405,9 @@ main(int argc, char *argv[]) die(0); /* Make sure fds 0, 1, 2 are open to somewhere. */ - fd_devnull = open(_PATH_DEVNULL, O_RDWR); + fd_devnull = open(PPP_DEVNULL, O_RDWR); if (fd_devnull < 0) - fatal("Couldn't open %s: %m", _PATH_DEVNULL); + fatal("Couldn't open %s: %m", PPP_DEVNULL); while (fd_devnull <= 2) { i = dup(fd_devnull); if (i < 0) @@ -421,12 +421,12 @@ main(int argc, char *argv[]) sys_init(); #ifdef PPP_WITH_TDB - pppdb = tdb_open(_PATH_PPPDB, 0, 0, O_RDWR|O_CREAT, 0644); + pppdb = tdb_open(PPP_PATH_PPPDB, 0, 0, O_RDWR|O_CREAT, 0644); if (pppdb != NULL) { slprintf(db_key, sizeof(db_key), "pppd%d", getpid()); update_db_entry(); } else { - warn("Warning: couldn't open ppp database %s", _PATH_PPPDB); + warn("Warning: couldn't open ppp database %s", PPP_PATH_PPPDB); if (multilink) { warn("Warning: disabling multilink"); multilink = 0; @@ -814,7 +814,7 @@ create_pidfile(int pid) FILE *pidfile; slprintf(pidfilename, sizeof(pidfilename), "%s%s.pid", - _PATH_VARRUN, ifname); + PPP_PATH_VARRUN, ifname); if ((pidfile = fopen(pidfilename, "w")) != NULL) { fprintf(pidfile, "%d\n", pid); (void) fclose(pidfile); @@ -833,7 +833,7 @@ create_linkpidfile(int pid) return; script_setenv("LINKNAME", linkname, 1); slprintf(linkpidfile, sizeof(linkpidfile), "%sppp-%s.pid", - _PATH_VARRUN, linkname); + PPP_PATH_VARRUN, linkname); if ((pidfile = fopen(linkpidfile, "w")) != NULL) { fprintf(pidfile, "%d\n", pid); if (ifname[0]) @@ -1655,7 +1655,7 @@ update_system_environment(void) /* * device_script - run a program to talk to the specified fds * (e.g. to run the connector or disconnector script). - * stderr gets connected to the log fd or to the _PATH_CONNERRS file. + * stderr gets connected to the log fd or to the PPP_PATH_CONNERRS file. */ int device_script(char *program, int in, int out, int dont_wait) @@ -1668,7 +1668,7 @@ device_script(char *program, int in, int out, int dont_wait) if (log_to_fd >= 0) errfd = log_to_fd; else - errfd = open(_PATH_CONNERRS, O_WRONLY | O_APPEND | O_CREAT, 0644); + errfd = open(PPP_PATH_CONNERRS, O_WRONLY | O_APPEND | O_CREAT, 0644); ++conn_running; pid = safe_fork(in, out, errfd); diff --git a/pppd/options.c b/pppd/options.c index 1fbe46e..92997e6 100644 --- a/pppd/options.c +++ b/pppd/options.c @@ -531,7 +531,7 @@ options_from_user(void) pw = getpwuid(getuid()); if (pw == NULL || (user = pw->pw_dir) == NULL || user[0] == 0) return 1; - file = _PATH_USEROPT; + file = PPP_PATH_USEROPT; pl = strlen(user) + strlen(file) + 2; path = malloc(pl); if (path == NULL) @@ -563,13 +563,13 @@ options_for_tty(void) dev = p + 5; if (dev[0] == 0 || strcmp(dev, "tty") == 0) return 1; /* don't look for /etc/ppp/options.tty */ - pl = strlen(_PATH_TTYOPT) + strlen(dev) + 1; + pl = strlen(PPP_PATH_TTYOPT) + strlen(dev) + 1; path = malloc(pl); if (path == NULL) novm("tty init file name"); - slprintf(path, pl, "%s%s", _PATH_TTYOPT, dev); + slprintf(path, pl, "%s%s", PPP_PATH_TTYOPT, dev); /* Turn slashes into dots, for Solaris case (e.g. /dev/term/a) */ - for (p = path + strlen(_PATH_TTYOPT); *p != 0; ++p) + for (p = path + strlen(PPP_PATH_TTYOPT); *p != 0; ++p) if (*p == '/') *p = '.'; option_priority = OPRIO_CFGFILE; @@ -1466,10 +1466,10 @@ callfile(char **argv) return 0; } - l = strlen(arg) + strlen(_PATH_PEERFILES) + 1; + l = strlen(arg) + strlen(PPP_PATH_PEERFILES) + 1; if ((fname = (char *) malloc(l)) == NULL) novm("call file name"); - slprintf(fname, l, "%s%s", _PATH_PEERFILES, arg); + slprintf(fname, l, "%s%s", PPP_PATH_PEERFILES, arg); script_setenv("CALL_FILE", arg, 0); ok = options_from_file(fname, 1, 1, 1); @@ -1597,7 +1597,7 @@ loadplugin(char **argv) const char *vers; if (strchr(arg, '/') == 0) { - const char *base = _PATH_PLUGIN; + const char *base = PPP_PATH_PLUGIN; int l = strlen(base) + strlen(arg) + 2; path = malloc(l); if (path == 0) diff --git a/pppd/pathnames.h b/pppd/pathnames.h index 57a130e..de2fb68 100644 --- a/pppd/pathnames.h +++ b/pppd/pathnames.h @@ -1,5 +1,46 @@ /* - * define path names + * pathnames.h - define default paths for pppd + * + * Copyright (c) 1999-2002 Paul Mackerras. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. The name(s) of the authors of this software must not be used to + * endorse or promote products derived from this software without + * prior written permission. + * + * 3. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by Paul Mackerras + * ". + * + * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Paths are controlled by configure. Typically, one would pass the following options + * to configure: + * ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var + * + * Note that if the prefix variable do control all the other directory variables, e.g + * sysconfdir is ${prefix}/etc. Setting prefix to /usr, you'll have to override + * sysconfdir with /etc to avoid installing config files into /usr/etc. + * + * In addition, there are three explicit variables that has overrides via configure: + * - PPPD_RUNTIME_DIR, set by --with-runtime-dir= + * - PPPD_LOGFILE_DIR, set by --with-logfile-dir= + * - PPPD_PLUGIN_DIR, set by --with-plugin-dir= */ #ifndef PPP_PATHNAMES_H #define PPP_PATHNAMES_H @@ -11,66 +52,82 @@ #endif /* HAVE_PATHS_H */ #ifndef _PATH_DEVNULL -#define _PATH_DEVNULL "/dev/null" +#define _PATH_DEVNULL "/dev/null" #endif +#define PPP_DEVNULL _PATH_DEVNULL + +/* + * PPPD_RUNTIME_DIR is set by passing --with-runtime-dir= via configure + * the default value set by configure when option is absent is ${localstatedir}/run/pppd + */ #ifdef PPPD_RUNTIME_DIR -#undef _PATH_VARRUN -#define _PATH_VARRUN PPPD_RUNTIME_DIR "/" +#define PPP_PATH_VARRUN PPPD_RUNTIME_DIR +#else +#define PPP_PATH_VARRUN _PATH_VARRUN #endif +/* + * PPPD_LOGFILE_DIR is set by passing --with-logfile-dir= via configure + * the default value set by configure when option is absent is ${localstatedir}/log/ppp + */ #ifdef PPPD_LOGFILE_DIR -#undef _PATH_VARLOG -#define _PATH_VARLOG PPPD_LOGFILE_DIR +#define PPP_PATH_VARLOG PPPD_LOGFILE_DIR +#else +#define PPP_PATH_VARLOG _PATH_VARRUN "/log/ppp" #endif +/* + * PPPD_PLUGIN_DIR is set by passing --with-plugin-dir= via configure + * the default value set by configure when option is absent is ${libdir}/pppd/${version} + */ #ifdef PPPD_PLUGIN_DIR -#define _PATH_PLUGIN PPPD_PLUGIN_DIR -#else -#ifdef __STDC__ -#define _PATH_PLUGIN DESTDIR "/lib/pppd/" VERSION -#else /* __STDC__ */ -#define _PATH_PLUGIN "/usr/lib/pppd" -#endif /* __STDC__ */ +#define PPP_PATH_PLUGIN PPPD_PLUGIN_DIR #endif /* PPPD_PLUGIN_DIR */ -#ifndef _ROOT_PATH -#define _ROOT_PATH -#endif +#define PPP_PATH_CONFDIR SYSCONFDIR "/ppp" -#define _PATH_UPAPFILE _ROOT_PATH "/etc/ppp/pap-secrets" -#define _PATH_CHAPFILE _ROOT_PATH "/etc/ppp/chap-secrets" -#define _PATH_SRPFILE _ROOT_PATH "/etc/ppp/srp-secrets" +#define PPP_PATH_UPAPFILE PPP_PATH_CONFDIR "/pap-secrets" +#define PPP_PATH_CHAPFILE PPP_PATH_CONFDIR "/chap-secrets" +#define PPP_PATH_SRPFILE PPP_PATH_CONFDIR "/srp-secrets" #ifdef PPP_WITH_EAPTLS -#define _PATH_EAPTLSCLIFILE _ROOT_PATH "/etc/ppp/eaptls-client" -#define _PATH_EAPTLSSERVFILE _ROOT_PATH "/etc/ppp/eaptls-server" -#define _PATH_OPENSSLCONFFILE _ROOT_PATH "/etc/ppp/openssl.cnf" +#define PPP_PATH_EAPTLSCLIFILE PPP_PATH_CONFDIR "/eaptls-client" +#define PPP_PATH_EAPTLSSERVFILE PPP_PATH_CONFDIR "/eaptls-server" +#define PPP_PATH_OPENSSLCONFFILE PPP_PATH_CONFDIR "/openssl.cnf" #endif /* PPP_WITH_EAPTLS */ -#define _PATH_SYSOPTIONS _ROOT_PATH "/etc/ppp/options" -#define _PATH_IPUP _ROOT_PATH "/etc/ppp/ip-up" -#define _PATH_IPDOWN _ROOT_PATH "/etc/ppp/ip-down" -#define _PATH_IPPREUP _ROOT_PATH "/etc/ppp/ip-pre-up" -#define _PATH_AUTHUP _ROOT_PATH "/etc/ppp/auth-up" -#define _PATH_AUTHDOWN _ROOT_PATH "/etc/ppp/auth-down" -#define _PATH_TTYOPT _ROOT_PATH "/etc/ppp/options." -#define _PATH_CONNERRS _ROOT_PATH _PATH_VARLOG "/connect-errors" -#define _PATH_PEERFILES _ROOT_PATH "/etc/ppp/peers/" -#define _PATH_RESOLV _ROOT_PATH "/etc/ppp/resolv.conf" +#define PPP_PATH_SYSOPTIONS PPP_PATH_CONFDIR "/options" +#define PPP_PATH_IPUP PPP_PATH_CONFDIR "/ip-up" +#define PPP_PATH_IPDOWN PPP_PATH_CONFDIR "/ip-down" +#define PPP_PATH_IPPREUP PPP_PATH_CONFDIR "/ip-pre-up" +#define PPP_PATH_AUTHUP PPP_PATH_CONFDIR "/auth-up" +#define PPP_PATH_AUTHDOWN PPP_PATH_CONFDIR "/auth-down" +#define PPP_PATH_TTYOPT PPP_PATH_CONFDIR "/options." +#define PPP_PATH_PEERFILES PPP_PATH_CONFDIR "/peers/" +#define PPP_PATH_RESOLV PPP_PATH_CONFDIR "/resolv.conf" -#define _PATH_USEROPT ".ppprc" -#define _PATH_PSEUDONYM ".ppp_pseudonym" +#define PPP_PATH_CONNERRS PPP_PATH_VARLOG "/connect-errors" + +#define PPP_PATH_USEROPT ".ppprc" +#define PPP_PATH_PSEUDONYM ".ppp_pseudonym" #ifdef PPP_WITH_IPV6CP -#define _PATH_IPV6UP _ROOT_PATH "/etc/ppp/ipv6-up" -#define _PATH_IPV6DOWN _ROOT_PATH "/etc/ppp/ipv6-down" +#define PPP_PATH_IPV6UP PPP_PATH_CONFDIR "/ipv6-up" +#define PPP_PATH_IPV6DOWN PPP_PATH_CONFDIR "/ipv6-down" +#endif + +#define PPP_PATH_PPPDB PPP_PATH_VARRUN "/pppd2.tdb" + +#ifdef __linux__ +#define PPP_PATH_LOCKDIR PPP_PATH_VARRUN "/lock" +#else +#ifdef SVR4 +#define PPP_PATH_LOCKDIR LOCALSTATEDIR "/spool/locks" +#else +#define PPP_PATH_LOCKDIR LOCALSTATEDIR "/spool/lock" +#endif #endif -#ifdef __STDC__ -#define _PATH_PPPDB _ROOT_PATH _PATH_VARRUN "pppd2.tdb" -#else /* __STDC__ */ -#define _PATH_PPPDB _PPP_VARRUN "pppd2.tdb" -#endif /* __STDC__ */ #endif /* PPP_PATHNAMES_H */ diff --git a/pppd/plugins/pppoe/Makefile.am b/pppd/plugins/pppoe/Makefile.am index 6cea70a..5fea701 100644 --- a/pppd/plugins/pppoe/Makefile.am +++ b/pppd/plugins/pppoe/Makefile.am @@ -6,7 +6,7 @@ dist_man8_MANS = pppoe-discovery.8 noinst_HEADERS = \ pppoe.h -pppoe_la_CPPFLAGS = -I${top_srcdir} +pppoe_la_CPPFLAGS = -I${top_srcdir} -DSYSCONFDIR=\"${sysconfdir}\" pppoe_la_LDFLAGS = -module -avoid-version pppoe_la_SOURCES = plugin.c discovery.c if.c common.c diff --git a/pppd/plugins/pppoe/plugin.c b/pppd/plugins/pppoe/plugin.c index 92d0493..7020565 100644 --- a/pppd/plugins/pppoe/plugin.c +++ b/pppd/plugins/pppoe/plugin.c @@ -53,13 +53,8 @@ static char const RCSID[] = #include #include #include -/* #include ?, see below ... */ -#ifndef _ROOT_PATH -#define _ROOT_PATH "" -#endif - -#define _PATH_ETHOPT _ROOT_PATH "/etc/ppp/options." +#define PPP_PATH_ETHOPT SYSCONFDIR "/ppp/options." char pppd_version[] = PPPD_VERSION; @@ -332,7 +327,7 @@ PPPOEDeviceOptions(void) { char buf[MAXPATHLEN]; - strlcpy(buf, _PATH_ETHOPT, MAXPATHLEN); + strlcpy(buf, PPP_PATH_ETHOPT, MAXPATHLEN); strlcat(buf, devnam, MAXPATHLEN); if (!options_from_file(buf, 0, 0, 1)) exit(EXIT_OPTION_ERROR); diff --git a/pppd/plugins/radius/Makefile.am b/pppd/plugins/radius/Makefile.am index ec637ae..40f4d16 100644 --- a/pppd/plugins/radius/Makefile.am +++ b/pppd/plugins/radius/Makefile.am @@ -47,7 +47,7 @@ radrealms_la_SOURCES = radrealms.c libradiusclient_la_SOURCES = \ avpair.c buildreq.c config.c dict.c ip_util.c \ clientid.c sendserver.c lock.c util.c -libradiusclient_la_CPPFLAGS = $(RADIUS_CPPFLAGS) +libradiusclient_la_CPPFLAGS = $(RADIUS_CPPFLAGS) -DSYSCONFDIR=\"${sysconfdir}\" if !WITH_OPENSSL libradiusclient_la_SOURCES += md5.c diff --git a/pppd/plugins/radius/pathnames.h b/pppd/plugins/radius/pathnames.h index 5aa4c60..3a00d2c 100644 --- a/pppd/plugins/radius/pathnames.h +++ b/pppd/plugins/radius/pathnames.h @@ -17,12 +17,12 @@ #ifndef PATHNAMES_H #define PATHNAMES_H -#define _PATH_DEV_URANDOM "/dev/urandom" /* Linux only */ -#define _PATH_ETC_ISSUE "/etc/issue" +#define PPP_PATH_DEV_URANDOM "/dev/urandom" /* Linux only */ +#define PPP_PATH_ETC_ISSUE "/etc/issue" /* normally defined in the Makefile */ -#ifndef _PATH_ETC_RADIUSCLIENT_CONF -#define _PATH_ETC_RADIUSCLIENT_CONF "/etc/radiusclient.conf" +#ifndef PPP_PATH_ETC_RADIUSCLIENT_CONF +#define PPP_PATH_ETC_RADIUSCLIENT_CONF SYSCONFDIR "/radiusclient.conf" #endif #endif /* PATHNAMES_H */ diff --git a/pppd/plugins/radius/sendserver.c b/pppd/plugins/radius/sendserver.c index f601286..acf78e5 100644 --- a/pppd/plugins/radius/sendserver.c +++ b/pppd/plugins/radius/sendserver.c @@ -491,7 +491,7 @@ static void rc_random_vector (unsigned char *vector) we use /dev/urandom here, as /dev/random might block and we don't need that much randomness. BTW, great idea, Ted! -lf, 03/18/95 */ - if ((fd = open(_PATH_DEV_URANDOM, O_RDONLY)) >= 0) + if ((fd = open(PPP_PATH_DEV_URANDOM, O_RDONLY)) >= 0) { unsigned char *pos; int readcount; diff --git a/pppd/utils.c b/pppd/utils.c index e75bb9c..bd82e2b 100644 --- a/pppd/utils.c +++ b/pppd/utils.c @@ -61,6 +61,7 @@ #include "pppd.h" #include "fsm.h" #include "lcp.h" +#include "pathnames.h" #if defined(SUNOS4) @@ -781,18 +782,6 @@ complete_read(int fd, void *buf, size_t count) #endif /* Procedures for locking the serial device using a lock file. */ -#ifndef LOCK_DIR -#ifdef __linux__ -#define LOCK_DIR "/var/lock" -#else -#ifdef SVR4 -#define LOCK_DIR "/var/spool/locks" -#else -#define LOCK_DIR "/var/spool/lock" -#endif -#endif -#endif /* LOCK_DIR */ - static char lock_file[MAXPATHLEN]; /* @@ -833,7 +822,7 @@ lock(char *dev) return -1; } slprintf(lock_file, sizeof(lock_file), "%s/LK.%03d.%03d.%03d", - LOCK_DIR, major(sbuf.st_dev), + PPP_PATH_LOCKDIR, major(sbuf.st_dev), major(sbuf.st_rdev), minor(sbuf.st_rdev)); #else char *p; @@ -851,7 +840,7 @@ lock(char *dev) if ((p = strrchr(dev, '/')) != NULL) dev = p + 1; - slprintf(lock_file, sizeof(lock_file), "%s/LCK..%s", LOCK_DIR, dev); + slprintf(lock_file, sizeof(lock_file), "%s/LCK..%s", PPP_PATH_LOCKDIR, dev); #endif while ((fd = open(lock_file, O_EXCL | O_CREAT | O_RDWR, 0644)) < 0) {