From: Eivind Næss Date: Mon, 13 Sep 2021 15:17:17 +0000 (-0700) Subject: Cleanup in pppd/pppd.h, eliminate unecessary headers X-Git-Tag: ppp-2.5.0~36^2~7 X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=d2330632fd4bdab5cf89bfdcce45eefd6fe34b97 Cleanup in pppd/pppd.h, eliminate unecessary headers This removes the need to include the following heades in pppd.h , this is included where needed (main.c). The number of groups already retrieved is stored in the "int ngroups" variable. , use MAXPATHLEN where needed , such that the value of IFNAMSIZ doesn't have to be declared to include Signed-off-by: Eivind Næss --- diff --git a/pppd/main.c b/pppd/main.c index 84a58c4..49319e2 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -93,6 +93,7 @@ #include #include #include +#include #include "pppd.h" #include "magic.h" @@ -293,8 +294,8 @@ main(int argc, char *argv[]) struct protent *protp; char numbuf[16]; - strlcpy(path_ipup, _PATH_IPUP, sizeof(path_ipup)); - strlcpy(path_ipdown, _PATH_IPDOWN, sizeof(path_ipdown)); + strlcpy(path_ipup, _PATH_IPUP, MAXPATHLEN); + strlcpy(path_ipdown, _PATH_IPDOWN, MAXPATHLEN); #ifdef PPP_WITH_IPV6CP strlcpy(path_ipv6up, _PATH_IPV6UP, MAXPATHLEN); diff --git a/pppd/options.c b/pppd/options.c index 42a3456..ec36bfe 100644 --- a/pppd/options.c +++ b/pppd/options.c @@ -54,6 +54,8 @@ #include #include #include +#include +#include #ifdef PPP_WITH_PLUGINS #include #endif diff --git a/pppd/plugins/passprompt.c b/pppd/plugins/passprompt.c index 7cd0a2b..35398a9 100644 --- a/pppd/plugins/passprompt.c +++ b/pppd/plugins/passprompt.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include diff --git a/pppd/plugins/pppoatm/pppoatm.c b/pppd/plugins/pppoatm/pppoatm.c index cb48244..5ac03c8 100644 --- a/pppd/plugins/pppoatm/pppoatm.c +++ b/pppd/plugins/pppoatm/pppoatm.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -88,7 +89,7 @@ static int setdevname_pppoatm(const char *cp, const char **argv, int doit) return 1; memcpy(&pvcaddr, &addr, sizeof pvcaddr); - strlcpy(devnam, cp, sizeof devnam); + strlcpy(devnam, cp, MAXPATHLEN); devstat.st_mode = S_IFSOCK; if (the_channel != &pppoa_channel) { the_channel = &pppoa_channel; @@ -162,7 +163,7 @@ static int connect_pppoatm(void) pppoatm_max_mtu = lcp_allowoptions[0].mru; pppoatm_max_mru = lcp_wantoptions[0].mru; set_line_discipline_pppoatm(fd); - strlcpy(ppp_devnam, devnam, sizeof(ppp_devnam)); + strlcpy(ppp_devnam, devnam, MAXPATHLEN); pppoa_fd = fd; return fd; } diff --git a/pppd/plugins/pppoe/plugin.c b/pppd/plugins/pppoe/plugin.c index 8443c92..92d0493 100644 --- a/pppd/plugins/pppoe/plugin.c +++ b/pppd/plugins/pppoe/plugin.c @@ -37,6 +37,7 @@ static char const RCSID[] = #include #include #include +#include #include #include #include @@ -200,7 +201,7 @@ PPPOEConnectDevice(void) conn->acName = acName; conn->serviceName = pppd_pppoe_service; - strlcpy(ppp_devnam, devnam, sizeof(ppp_devnam)); + strlcpy(ppp_devnam, devnam, MAXPATHLEN); if (existingSession) { unsigned int mac[ETH_ALEN]; int i, ses; @@ -395,7 +396,7 @@ PPPoEDevnameHook(char *cmd, char **argv, int doit) /* Close socket */ close(fd); if (r && doit) { - strlcpy(devnam, cmd, sizeof(devnam)); + strlcpy(devnam, cmd, MAXPATHLEN); if (the_channel != &pppoe_channel) { the_channel = &pppoe_channel; diff --git a/pppd/plugins/pppoe/pppoe-discovery.c b/pppd/plugins/pppoe/pppoe-discovery.c index 4e2a5f2..b698bca 100644 --- a/pppd/plugins/pppoe/pppoe-discovery.c +++ b/pppd/plugins/pppoe/pppoe-discovery.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "pppoe.h" diff --git a/pppd/plugins/radius/radius.c b/pppd/plugins/radius/radius.c index d89fdd1..0417454 100644 --- a/pppd/plugins/radius/radius.c +++ b/pppd/plugins/radius/radius.c @@ -29,6 +29,7 @@ static char const RCSID[] = #include #include #include +#include #include #include #include diff --git a/pppd/plugins/radius/radrealms.c b/pppd/plugins/radius/radrealms.c index 493af03..27955e0 100644 --- a/pppd/plugins/radius/radrealms.c +++ b/pppd/plugins/radius/radrealms.c @@ -20,6 +20,7 @@ static char const RCSID[] = #include #include #include +#include #include #include "radiusclient.h" diff --git a/pppd/pppd.h b/pppd/pppd.h index 9dc6d71..c5f9b6d 100644 --- a/pppd/pppd.h +++ b/pppd/pppd.h @@ -57,9 +57,7 @@ #include #include #include /* for u_int32_t, if defined */ -#include /* for struct timeval */ #include -#include #ifdef PPP_WITH_IPV6CP #include "eui64.h" @@ -216,7 +214,7 @@ struct notifier { extern int got_sigterm; /* SIGINT or SIGTERM was received */ extern int hungup; /* Physical layer has disconnected */ extern int ifunit; /* Interface unit number */ -extern char ifname[]; /* Interface name */ +extern char ifname[]; /* Interface name (IFNAMSIZ) */ extern char hostname[]; /* Our hostname */ extern u_char outpacket_buf[]; /* Buffer for outgoing packets */ extern int devfd; /* fd of underlying device */ @@ -231,7 +229,7 @@ extern int privileged; /* We were run by real-uid root */ extern int need_holdoff; /* Need holdoff period after link terminates */ extern char **script_env; /* Environment variables for scripts */ extern int detached; /* Have detached from controlling tty */ -extern GIDSET_TYPE groups[NGROUPS_MAX]; /* groups the user is in */ +extern GIDSET_TYPE groups[]; /* groups the user is in */ extern int ngroups; /* How many groups valid in groups */ extern struct pppd_stats link_stats; /* byte/packet counts etc. for link */ extern int link_stats_valid; /* set if link_stats is valid */ @@ -246,7 +244,7 @@ extern int unsuccess; /* # unsuccessful connection attempts */ extern int do_callback; /* set if we want to do callback next */ extern int doing_callback; /* set if this is a callback */ extern int error_count; /* # of times error() has been called */ -extern char ppp_devnam[MAXPATHLEN]; +extern char ppp_devnam[]; /* name of PPP tty (maybe ttypx) */ extern char remote_number[MAXNAMELEN]; /* Remote telephone number, if avail. */ extern int ppp_session_number; /* Session number (eg PPPoE session) */ extern int fd_devnull; /* fd open to /dev/null */ @@ -280,7 +278,7 @@ extern struct notifier *fork_notifier; /* we are a new child process */ extern int debug; /* Debug flag */ extern int kdebugflag; /* Tell kernel to print debug messages */ extern int default_device; /* Using /dev/tty or equivalent */ -extern char devnam[MAXPATHLEN]; /* Device name */ +extern char devnam[]; /* Device name */ extern int crtscts; /* Use hardware flow control */ extern int stop_bits; /* Number of serial port stop bits */ extern bool modem; /* Use modem control lines */ @@ -319,14 +317,14 @@ extern char *pty_socket; /* Socket to connect to pty */ extern char *record_file; /* File to record chars sent/received */ extern bool sync_serial; /* Device is synchronous serial device */ extern int maxfail; /* Max # of unsuccessful connection attempts */ -extern char linkname[MAXPATHLEN]; /* logical name for link */ +extern char linkname[]; /* logical name for link */ extern bool tune_kernel; /* May alter kernel settings as necessary */ extern int connect_delay; /* Time to delay after connect script */ extern int max_data_rate; /* max bytes/sec through charshunt */ extern int req_unit; /* interface unit number to use */ -extern char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */ -extern char path_ipdown[MAXPATHLEN]; /* pathname of ip-down script */ -extern char req_ifname[IFNAMSIZ]; /* interface name to use */ +extern char path_ipup[]; /* pathname of ip-up script */ +extern char path_ipdown[]; /* pathname of ip-down script */ +extern char req_ifname[]; /* interface name to use (IFNAMSIZ) */ extern bool multilink; /* enable multilink operation */ extern bool noendpoint; /* don't send or accept endpt. discrim. */ extern char *bundle_name; /* bundle name for multilink */ diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c index 329a141..b68babd 100644 --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -81,6 +81,7 @@ #include #include #include +#include #include #include diff --git a/pppd/tty.c b/pppd/tty.c index 7e208ba..ad74353 100644 --- a/pppd/tty.c +++ b/pppd/tty.c @@ -319,7 +319,7 @@ setdevname(char *cp, char **argv, int doit) } if (doit) { - strlcpy(devnam, cp, sizeof(devnam)); + strlcpy(devnam, cp, MAXPATHLEN); devstat = statbuf; default_device = 0; } @@ -414,7 +414,7 @@ void tty_process_extra_options(void) option_error("no device specified and stdin is not a tty"); exit(EXIT_OPTION_ERROR); } - strlcpy(devnam, p, sizeof(devnam)); + strlcpy(devnam, p, MAXPATHLEN); if (stat(devnam, &devstat) < 0) fatal("Couldn't stat default device %s: %m", devnam); } @@ -518,7 +518,7 @@ int connect_tty(void) * Get a pty master/slave pair if the pty, notty, socket, * or record options were specified. */ - strlcpy(ppp_devnam, devnam, sizeof(ppp_devnam)); + strlcpy(ppp_devnam, devnam, MAXPATHLEN); pty_master = -1; pty_slave = -1; real_ttyfd = -1;