summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pppd/sys-bsd.c
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2002-11-05 05:58:31 +0000
committerbrooks <brooks@FreeBSD.org>2002-11-05 05:58:31 +0000
commit9f22243053df586555c91efdc4719a616ebe73b1 (patch)
treeda1e2edc4e17c85650c25373732a45ea21dc8081 /usr.sbin/pppd/sys-bsd.c
parentf324bc490bfb9a76614ad8c868ff5a50b32a5b2d (diff)
downloadFreeBSD-src-9f22243053df586555c91efdc4719a616ebe73b1.zip
FreeBSD-src-9f22243053df586555c91efdc4719a616ebe73b1.tar.gz
Test for the existance of kernel ppp support by seeing if the kernel has
the module compiled in or loaded instead of bogusly checking for ppp0. Also if and only if the caller is actually root and the kernel does not have ppp support, try to load the ppp module before giving up.
Diffstat (limited to 'usr.sbin/pppd/sys-bsd.c')
-rw-r--r--usr.sbin/pppd/sys-bsd.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/usr.sbin/pppd/sys-bsd.c b/usr.sbin/pppd/sys-bsd.c
index d524f02..ed4bd41 100644
--- a/usr.sbin/pppd/sys-bsd.c
+++ b/usr.sbin/pppd/sys-bsd.c
@@ -44,6 +44,7 @@ static char rcsid[] = "$FreeBSD$";
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/param.h>
+#include <sys/module.h>
#ifdef NetBSD1_2
#include <util.h>
#endif
@@ -169,28 +170,29 @@ sys_check_options()
}
/*
- * ppp_available - check whether the system has any ppp interfaces
- * (in fact we check whether we can do an ioctl on ppp0).
+ * ppp_available - check whether the system has the ppp module loaded
+ * or compiled in. If it doesn't, and we're actually root (not just SUID
+ * root) try loading it before giving up.
*/
int
ppp_available()
{
- int s, ok;
- struct ifreq ifr;
+ const char *modname = "if_ppp";
extern char *no_ppp_msg;
- if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
- return 1; /* can't tell */
+ if (modfind(modname) != -1) {
+ return 1;
+ }
- strncpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name));
- ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0;
- close(s);
+ if (getuid() == 0 && kldload(modname) != -1)
+ return 1;
no_ppp_msg = "\
This system lacks kernel support for PPP. To include PPP support\n\
-in the kernel, please follow the steps detailed in the README.bsd\n\
-file in the ppp-2.2 distribution.\n";
- return ok;
+in the kernel, please add \"device ppp\" to your kernel config or \n\
+load the if_ppp module.\n";
+
+ return 0;
}
/*
OpenPOWER on IntegriCloud