]> git.ozlabs.org Git - ppp.git/commitdiff
Cleanup in pppd/pppd.h, eliminate unecessary headers
authorEivind Næss <eivnaes@yahoo.com>
Mon, 13 Sep 2021 15:17:17 +0000 (08:17 -0700)
committerEivind Næss <eivnaes@yahoo.com>
Fri, 15 Jul 2022 22:25:39 +0000 (15:25 -0700)
This removes the need to include the following heades in pppd.h

<limits.h>, this is included where needed (main.c). The number of groups already retrieved is stored in the "int ngroups" variable.
<sys/params.h>, use MAXPATHLEN where needed
<net/if.h>, such that the value of IFNAMSIZ doesn't have to be declared to include <pppd/pppd.h>

Signed-off-by: Eivind Næss <eivnaes@yahoo.com>
pppd/main.c
pppd/options.c
pppd/plugins/passprompt.c
pppd/plugins/pppoatm/pppoatm.c
pppd/plugins/pppoe/plugin.c
pppd/plugins/pppoe/pppoe-discovery.c
pppd/plugins/radius/radius.c
pppd/plugins/radius/radrealms.c
pppd/pppd.h
pppd/sys-linux.c
pppd/tty.c

index 84a58c465a2b1da1f9a5aabfe11646db6aa0998a..49319e2a81a7fbd4e8cc6cce5e131b931de8f1b6 100644 (file)
@@ -93,6 +93,7 @@
 #include <arpa/inet.h>
 #include <limits.h>
 #include <inttypes.h>
+#include <net/if.h>
 
 #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);
index 42a3456429fb682df83bf26eb467d78c62f25985..ec36bfe6be540a9cddc786277eb895187903fe7e 100644 (file)
@@ -54,6 +54,8 @@
 #include <syslog.h>
 #include <string.h>
 #include <pwd.h>
+#include <sys/param.h>
+#include <net/if.h>
 #ifdef PPP_WITH_PLUGINS
 #include <dlfcn.h>
 #endif
index 7cd0a2bfe1cbac8a0f29a23b0c2319c1c0080497..35398a9169d7208629610ad4595c3186ba889149 100644 (file)
@@ -12,6 +12,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <sys/wait.h>
+#include <sys/param.h>
 #include <syslog.h>
 #include <pppd/pppd.h>
 
index cb482449fd9ae03686d4d7710b7b021f89d6fc97..5ac03c8483d66e44f40da04f1ab7f7290b3a72c0 100644 (file)
@@ -23,6 +23,7 @@
 #include <sys/stat.h>
 #include <net/if.h>
 #include <sys/ioctl.h>
+#include <sys/param.h>
 
 #include <pppd/pppd.h>
 #include <pppd/pathnames.h>
@@ -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;
 }
index 8443c920584d25be61e6aa5cdcb966c71fd45364..92d049353c49b24b6bb81f295a37317cfd1cd778 100644 (file)
@@ -37,6 +37,7 @@ static char const RCSID[] =
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
+#include <sys/param.h>
 #include <string.h>
 #include <stdlib.h>
 #include <errno.h>
@@ -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;
index 4e2a5f2b7edea8edefd8d3089c11275d222ebf5c..b698bca7b17fd56d68fa7e30c8de353056d41ad5 100644 (file)
@@ -21,6 +21,7 @@
 #include <string.h>
 #include <time.h>
 #include <signal.h>
+#include <sys/time.h>
 
 #include "pppoe.h"
 
index d89fdd1e8c8c9b498ea5d25cca7e3187f6f8f4d7..0417454d504ecbe52dd566639a978eb484740bf9 100644 (file)
@@ -29,6 +29,7 @@ static char const RCSID[] =
 #include <syslog.h>
 #include <sys/types.h>
 #include <sys/time.h>
+#include <sys/param.h>
 #include <string.h>
 #include <netinet/in.h>
 #include <stdlib.h>
index 493af0322f7d412ed67170174492e782fe94002e..27955e06d079c4a9caaee048a7fe3cc490ae7a06 100644 (file)
@@ -20,6 +20,7 @@ static char const RCSID[] =
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <sys/param.h>
 #include <pppd/pppd.h>
 
 #include "radiusclient.h"
index 9dc6d714a59b2138c2133950218ad8dec0dfb7ca..c5f9b6d5e4c41c19937a79648d1ba2bb94faa8ac 100644 (file)
@@ -57,9 +57,7 @@
 #include <stdarg.h>
 #include <stdint.h>
 #include <sys/types.h>         /* for u_int32_t, if defined */
-#include <sys/time.h>          /* for struct timeval */
 #include <net/ppp_defs.h>
-#include <net/if.h>
 
 #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 */
index 329a141d2940024b0efec25e416eb5d53a315a88..b68babdfa659cdc161507f65f6a63fe94a33b50e 100644 (file)
@@ -81,6 +81,7 @@
 #include <sys/stat.h>
 #include <sys/utsname.h>
 #include <sys/sysmacros.h>
+#include <sys/param.h>
 
 #include <errno.h>
 #include <stddef.h>
index 7e208badaff078c20c3ed8345c12778c769f5fbf..ad743539ec806c8fcfa2b7cfc9ea95195c063bf8 100644 (file)
@@ -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;