Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
8b218ed366 | ||
|
1f674debe0 | ||
|
00211a77d4 | ||
|
4b872881e7 | ||
|
cb9af79e1a |
0
.cvsignore → .gitignore
vendored
0
.cvsignore → .gitignore
vendored
21
Makefile
21
Makefile
@ -1,21 +0,0 @@
|
||||
# Makefile for source rpm: ppp
|
||||
# $Id: Makefile,v 1.1 2004/09/09 10:38:57 cvsdist Exp $
|
||||
NAME := ppp
|
||||
SPECFILE = $(firstword $(wildcard *.spec))
|
||||
|
||||
define find-makefile-common
|
||||
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done
|
||||
endef
|
||||
|
||||
MAKEFILE_COMMON := $(shell $(find-makefile-common))
|
||||
|
||||
ifeq ($(MAKEFILE_COMMON),)
|
||||
# attempt a checkout
|
||||
define checkout-makefile-common
|
||||
test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2
|
||||
endef
|
||||
|
||||
MAKEFILE_COMMON := $(shell $(checkout-makefile-common))
|
||||
endif
|
||||
|
||||
include $(MAKEFILE_COMMON)
|
@ -1,6 +1,6 @@
|
||||
diff -up ppp-2.4.4/pppd/ipcp.c.bogus_dns_addr ppp-2.4.4/pppd/ipcp.c
|
||||
--- ppp-2.4.4/pppd/ipcp.c.bogus_dns_addr 2005-08-26 01:59:34.000000000 +0200
|
||||
+++ ppp-2.4.4/pppd/ipcp.c 2008-12-11 12:39:05.000000000 +0100
|
||||
+++ ppp-2.4.4/pppd/ipcp.c 2010-01-06 08:03:55.325096361 +0100
|
||||
@@ -715,7 +715,8 @@ ipcp_cilen(f)
|
||||
#define LENCIADDRS(neg) (neg ? CILEN_ADDRS : 0)
|
||||
#define LENCIVJ(neg, old) (neg ? (old? CILEN_COMPRESS : CILEN_VJ) : 0)
|
||||
@ -53,7 +53,29 @@ diff -up ppp-2.4.4/pppd/ipcp.c.bogus_dns_addr ppp-2.4.4/pppd/ipcp.c
|
||||
*lenp -= len;
|
||||
}
|
||||
|
||||
@@ -1159,6 +1179,15 @@ ipcp_nakci(f, p, len, treat_as_reject)
|
||||
@@ -1097,19 +1117,11 @@ ipcp_nakci(f, p, len, treat_as_reject)
|
||||
);
|
||||
|
||||
NAKCIDNS(CI_MS_DNS1, req_dns1,
|
||||
- if (treat_as_reject) {
|
||||
- try.req_dns1 = 0;
|
||||
- } else {
|
||||
- try.dnsaddr[0] = cidnsaddr;
|
||||
- }
|
||||
+ try.dnsaddr[0] = cidnsaddr;
|
||||
);
|
||||
|
||||
NAKCIDNS(CI_MS_DNS2, req_dns2,
|
||||
- if (treat_as_reject) {
|
||||
- try.req_dns2 = 0;
|
||||
- } else {
|
||||
- try.dnsaddr[1] = cidnsaddr;
|
||||
- }
|
||||
+ try.dnsaddr[1] = cidnsaddr;
|
||||
);
|
||||
|
||||
/*
|
||||
@@ -1159,6 +1171,15 @@ ipcp_nakci(f, p, len, treat_as_reject)
|
||||
try.neg_addr = 1;
|
||||
no.neg_addr = 1;
|
||||
break;
|
||||
@ -69,7 +91,7 @@ diff -up ppp-2.4.4/pppd/ipcp.c.bogus_dns_addr ppp-2.4.4/pppd/ipcp.c
|
||||
}
|
||||
p = next;
|
||||
}
|
||||
@@ -1275,6 +1304,21 @@ ipcp_rejci(f, p, len)
|
||||
@@ -1275,6 +1296,21 @@ ipcp_rejci(f, p, len)
|
||||
try.neg = 0; \
|
||||
}
|
||||
|
||||
@ -91,7 +113,7 @@ diff -up ppp-2.4.4/pppd/ipcp.c.bogus_dns_addr ppp-2.4.4/pppd/ipcp.c
|
||||
|
||||
REJCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs,
|
||||
go->ouraddr, go->hisaddr);
|
||||
@@ -1288,6 +1332,10 @@ ipcp_rejci(f, p, len)
|
||||
@@ -1288,6 +1324,10 @@ ipcp_rejci(f, p, len)
|
||||
|
||||
REJCIDNS(CI_MS_DNS2, req_dns2, go->dnsaddr[1]);
|
||||
|
||||
|
554
ppp-2.4.4-fd_leak.patch
Normal file
554
ppp-2.4.4-fd_leak.patch
Normal file
@ -0,0 +1,554 @@
|
||||
diff -up ppp-2.4.4/pppd/auth.c.fd_leak ppp-2.4.4/pppd/auth.c
|
||||
--- ppp-2.4.4/pppd/auth.c.fd_leak 2006-06-18 13:26:00.000000000 +0200
|
||||
+++ ppp-2.4.4/pppd/auth.c 2009-10-08 21:22:59.789547513 +0200
|
||||
@@ -424,7 +424,7 @@ setupapfile(argv)
|
||||
option_error("unable to reset uid before opening %s: %m", fname);
|
||||
return 0;
|
||||
}
|
||||
- ufile = fopen(fname, "r");
|
||||
+ ufile = fopen_r(fname);
|
||||
if (seteuid(euid) == -1)
|
||||
fatal("unable to regain privileges: %m");
|
||||
if (ufile == NULL) {
|
||||
@@ -1404,7 +1404,7 @@ check_passwd(unit, auser, userlen, apass
|
||||
filename = _PATH_UPAPFILE;
|
||||
addrs = opts = NULL;
|
||||
ret = UPAP_AUTHNAK;
|
||||
- f = fopen(filename, "r");
|
||||
+ f = fopen_r(filename);
|
||||
if (f == NULL) {
|
||||
error("Can't open PAP password file %s: %m", filename);
|
||||
|
||||
@@ -1649,7 +1649,7 @@ plogin(user, passwd, msg)
|
||||
struct lastlog ll;
|
||||
int fd;
|
||||
|
||||
- if ((fd = open(_PATH_LASTLOG, O_RDWR, 0)) >= 0) {
|
||||
+ if ((fd = open_fd_mode(_PATH_LASTLOG, O_RDWR, 0)) >= 0) {
|
||||
(void)lseek(fd, (off_t)(pw->pw_uid * sizeof(ll)), SEEK_SET);
|
||||
memset((void *)&ll, 0, sizeof(ll));
|
||||
(void)time(&ll.ll_time);
|
||||
@@ -1721,7 +1721,7 @@ null_login(unit)
|
||||
if (ret <= 0) {
|
||||
filename = _PATH_UPAPFILE;
|
||||
addrs = NULL;
|
||||
- f = fopen(filename, "r");
|
||||
+ f = fopen_r(filename);
|
||||
if (f == NULL)
|
||||
return 0;
|
||||
check_access(f, filename);
|
||||
@@ -1768,7 +1768,7 @@ get_pap_passwd(passwd)
|
||||
}
|
||||
|
||||
filename = _PATH_UPAPFILE;
|
||||
- f = fopen(filename, "r");
|
||||
+ f = fopen_r(filename);
|
||||
if (f == NULL)
|
||||
return 0;
|
||||
check_access(f, filename);
|
||||
@@ -1806,7 +1806,7 @@ have_pap_secret(lacks_ipp)
|
||||
}
|
||||
|
||||
filename = _PATH_UPAPFILE;
|
||||
- f = fopen(filename, "r");
|
||||
+ f = fopen_r(filename);
|
||||
if (f == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -1851,7 +1851,7 @@ have_chap_secret(client, server, need_ip
|
||||
}
|
||||
|
||||
filename = _PATH_CHAPFILE;
|
||||
- f = fopen(filename, "r");
|
||||
+ f = fopen_r(filename);
|
||||
if (f == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -1893,7 +1893,7 @@ have_srp_secret(client, server, need_ip,
|
||||
struct wordlist *addrs;
|
||||
|
||||
filename = _PATH_SRPFILE;
|
||||
- f = fopen(filename, "r");
|
||||
+ f = fopen_r(filename);
|
||||
if (f == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -1949,7 +1949,7 @@ get_secret(unit, client, server, secret,
|
||||
addrs = NULL;
|
||||
secbuf[0] = 0;
|
||||
|
||||
- f = fopen(filename, "r");
|
||||
+ f = fopen_r(filename);
|
||||
if (f == NULL) {
|
||||
error("Can't open chap secret file %s: %m", filename);
|
||||
return 0;
|
||||
@@ -2006,7 +2006,7 @@ get_srp_secret(unit, client, server, sec
|
||||
filename = _PATH_SRPFILE;
|
||||
addrs = NULL;
|
||||
|
||||
- fp = fopen(filename, "r");
|
||||
+ fp = fopen_r(filename);
|
||||
if (fp == NULL) {
|
||||
error("Can't open srp secret file %s: %m", filename);
|
||||
return 0;
|
||||
@@ -2412,7 +2412,7 @@ scan_authfile(f, client, server, secret,
|
||||
*/
|
||||
if (word[0] == '@' && word[1] == '/') {
|
||||
strlcpy(atfile, word+1, sizeof(atfile));
|
||||
- if ((sf = fopen(atfile, "r")) == NULL) {
|
||||
+ if ((sf = fopen_r(atfile)) == NULL) {
|
||||
warn("can't open indirect secret file %s", atfile);
|
||||
continue;
|
||||
}
|
||||
diff -up ppp-2.4.4/pppd/eap.c.fd_leak ppp-2.4.4/pppd/eap.c
|
||||
--- ppp-2.4.4/pppd/eap.c.fd_leak 2004-11-09 23:39:25.000000000 +0100
|
||||
+++ ppp-2.4.4/pppd/eap.c 2009-10-08 21:22:59.791544181 +0200
|
||||
@@ -1226,7 +1226,7 @@ mode_t modebits;
|
||||
|
||||
if ((path = name_of_pn_file()) == NULL)
|
||||
return (-1);
|
||||
- fd = open(path, modebits, S_IRUSR | S_IWUSR);
|
||||
+ fd = open_fd(path, modebits, S_IRUSR | S_IWUSR);
|
||||
err = errno;
|
||||
free(path);
|
||||
errno = err;
|
||||
diff -up ppp-2.4.4/pppd/main.c.fd_leak ppp-2.4.4/pppd/main.c
|
||||
--- ppp-2.4.4/pppd/main.c.fd_leak 2009-10-08 21:22:59.769544859 +0200
|
||||
+++ ppp-2.4.4/pppd/main.c 2009-10-08 21:30:32.356546561 +0200
|
||||
@@ -201,6 +201,8 @@ int ngroups; /* How many groups valid
|
||||
|
||||
static struct timeval start_time; /* Time when link was started. */
|
||||
|
||||
+static int cloexec_works; /* controlls setting FD_CLOEXEC flag up */
|
||||
+
|
||||
static struct pppd_stats old_link_stats;
|
||||
struct pppd_stats link_stats;
|
||||
unsigned link_connect_time;
|
||||
@@ -245,6 +247,7 @@ static void holdoff_end __P((void *));
|
||||
static void forget_child __P((int pid, int status));
|
||||
static int reap_kids __P((void));
|
||||
static void childwait_end __P((void *));
|
||||
+static void check_cloexec __P((int));
|
||||
|
||||
#ifdef USE_TDB
|
||||
static void update_db_entry __P((void));
|
||||
@@ -419,7 +422,7 @@ main(argc, argv)
|
||||
die(0);
|
||||
|
||||
/* Make sure fds 0, 1, 2 are open to somewhere. */
|
||||
- fd_devnull = open(_PATH_DEVNULL, O_RDWR);
|
||||
+ fd_devnull = open_fd(_PATH_DEVNULL, O_RDWR);
|
||||
if (fd_devnull < 0)
|
||||
fatal("Couldn't open %s: %m", _PATH_DEVNULL);
|
||||
while (fd_devnull <= 2) {
|
||||
@@ -464,7 +467,6 @@ main(argc, argv)
|
||||
}
|
||||
syslog(LOG_NOTICE, "pppd %s started by %s, uid %d", VERSION, p, uid);
|
||||
script_setenv("PPPLOGNAME", p, 0);
|
||||
-
|
||||
if (devnam[0])
|
||||
script_setenv("DEVICE", devnam, 1);
|
||||
slprintf(numbuf, sizeof(numbuf), "%d", getpid());
|
||||
@@ -606,7 +608,6 @@ static void
|
||||
handle_events()
|
||||
{
|
||||
struct timeval timo;
|
||||
-
|
||||
kill_link = open_ccp_flag = 0;
|
||||
if (sigsetjmp(sigjmp, 1) == 0) {
|
||||
sigprocmask(SIG_BLOCK, &signals_handled, NULL);
|
||||
@@ -865,6 +866,104 @@ holdoff_end(arg)
|
||||
new_phase(PHASE_DORMANT);
|
||||
}
|
||||
|
||||
+
|
||||
+/*
|
||||
+ * check_cloexec - checks for FD_CLOEXEC flag and adds it if necessary
|
||||
+ */
|
||||
+static void
|
||||
+check_cloexec(int fd)
|
||||
+{
|
||||
+ if (cloexec_works == 0) {
|
||||
+ int fl = fcntl(fd, F_GETFD);
|
||||
+ cloexec_works = (fl & FD_CLOEXEC) ? 1 : -1;
|
||||
+ }
|
||||
+ if (cloexec_works > 0)
|
||||
+ return;
|
||||
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * socket_fd - create an endpoint for communication. uses FD_CLOEXEC if supported
|
||||
+ */
|
||||
+int
|
||||
+socket_fd(int domain, int type, int protocol)
|
||||
+{
|
||||
+ int fd;
|
||||
+
|
||||
+#ifdef SOCK_CLOEXEC
|
||||
+ if (cloexec_works != -1)
|
||||
+ type |= SOCK_CLOEXEC;
|
||||
+#endif
|
||||
+ fd = socket(domain, type, protocol);
|
||||
+ if (fd == -1)
|
||||
+ return -1;
|
||||
+ check_cloexec(fd);
|
||||
+ return fd;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * open_fd - open file with FD_CLOEXEC flag
|
||||
+ */
|
||||
+int
|
||||
+open_fd(const char *path, int flags)
|
||||
+{
|
||||
+ int fd;
|
||||
+
|
||||
+#if defined(O_CLOEXEC) && defined(SOCK_CLOEXEC)
|
||||
+ if (cloexec_works != -1)
|
||||
+ flags |= O_CLOEXEC;
|
||||
+#endif
|
||||
+ fd = open(path, flags);
|
||||
+ if (fd == -1)
|
||||
+ return -1;
|
||||
+ check_cloexec(fd);
|
||||
+ return fd;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * open_fd_mmode - open file with FD_CLOEXEC flag
|
||||
+ */
|
||||
+int
|
||||
+open_fd_mode(const char *path, int flags, int mode)
|
||||
+{
|
||||
+ int fd;
|
||||
+
|
||||
+#if defined(O_CLOEXEC) && defined(SOCK_CLOEXEC)
|
||||
+ if (cloexec_works != -1)
|
||||
+ flags |= O_CLOEXEC;
|
||||
+#endif
|
||||
+ fd = open(path, flags, mode);
|
||||
+ if (fd == -1)
|
||||
+ return -1;
|
||||
+ check_cloexec(fd);
|
||||
+ return fd;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * fopen_r - open file with FD_CLOEXEC flag
|
||||
+ */
|
||||
+FILE *
|
||||
+fopen_r(const char *path)
|
||||
+{
|
||||
+ FILE *f;
|
||||
+
|
||||
+#if defined(O_CLOEXEC) && defined(SOCK_CLOEXEC)
|
||||
+ if (cloexec_exec != -1) {
|
||||
+ f = fopen(path, "re");
|
||||
+ if (f != NULL) {
|
||||
+ check_cloexec(fileno(f));
|
||||
+ return f;
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
+ f = fopen(path, "r");
|
||||
+ if (f == NULL)
|
||||
+ return NULL;
|
||||
+ check_cloexec(fileno(f));
|
||||
+ return f;
|
||||
+}
|
||||
+
|
||||
/* List of protocol names, to make our messages a little more informative. */
|
||||
struct protocol_list {
|
||||
u_short proto;
|
||||
@@ -1618,7 +1717,7 @@ device_script(program, in, out, dont_wai
|
||||
if (log_to_fd >= 0)
|
||||
errfd = log_to_fd;
|
||||
else
|
||||
- errfd = open(_PATH_CONNERRS, O_WRONLY | O_APPEND | O_CREAT, 0600);
|
||||
+ errfd = open_fd_mode(_PATH_CONNERRS, O_WRONLY | O_APPEND | O_CREAT, 0600);
|
||||
|
||||
++conn_running;
|
||||
pid = safe_fork(in, out, errfd);
|
||||
diff -up ppp-2.4.4/pppd/options.c.fd_leak ppp-2.4.4/pppd/options.c
|
||||
--- ppp-2.4.4/pppd/options.c.fd_leak 2006-06-18 13:26:00.000000000 +0200
|
||||
+++ ppp-2.4.4/pppd/options.c 2009-10-08 21:22:59.797544174 +0200
|
||||
@@ -409,7 +409,7 @@ options_from_file(filename, must_exist,
|
||||
option_error("unable to drop privileges to open %s: %m", filename);
|
||||
return 0;
|
||||
}
|
||||
- f = fopen(filename, "r");
|
||||
+ f = fopen_r(filename);
|
||||
err = errno;
|
||||
if (check_prot && seteuid(euid) == -1)
|
||||
fatal("unable to regain privileges");
|
||||
@@ -1521,9 +1521,9 @@ setlogfile(argv)
|
||||
option_error("unable to drop permissions to open %s: %m", *argv);
|
||||
return 0;
|
||||
}
|
||||
- fd = open(*argv, O_WRONLY | O_APPEND | O_CREAT | O_EXCL, 0644);
|
||||
+ fd = open_fd_mode(*argv, O_WRONLY | O_APPEND | O_CREAT | O_EXCL, 0644);
|
||||
if (fd < 0 && errno == EEXIST)
|
||||
- fd = open(*argv, O_WRONLY | O_APPEND);
|
||||
+ fd = open_fd(*argv, O_WRONLY | O_APPEND);
|
||||
err = errno;
|
||||
if (!privileged_option && seteuid(euid) == -1)
|
||||
fatal("unable to regain privileges: %m");
|
||||
diff -up ppp-2.4.4/pppd/pppd.h.fd_leak ppp-2.4.4/pppd/pppd.h
|
||||
--- ppp-2.4.4/pppd/pppd.h.fd_leak 2005-08-26 01:59:34.000000000 +0200
|
||||
+++ ppp-2.4.4/pppd/pppd.h 2009-10-08 21:22:59.800544904 +0200
|
||||
@@ -494,6 +494,10 @@ int ppp_send_config __P((int, int, u_in
|
||||
int ppp_recv_config __P((int, int, u_int32_t, int, int));
|
||||
const char *protocol_name __P((int));
|
||||
void remove_pidfiles __P((void));
|
||||
+int socket_fd __P((int, int, int));
|
||||
+int open_fd __P((const char *, int));
|
||||
+int open_fd_mode __P((const char *, int, int));
|
||||
+FILE *fopen_r __P((const char *));
|
||||
void lock_db __P((void));
|
||||
void unlock_db __P((void));
|
||||
|
||||
diff -up ppp-2.4.4/pppd/sys-linux.c.fd_leak ppp-2.4.4/pppd/sys-linux.c
|
||||
--- ppp-2.4.4/pppd/sys-linux.c.fd_leak 2009-10-08 21:22:59.778544744 +0200
|
||||
+++ ppp-2.4.4/pppd/sys-linux.c 2009-10-08 21:22:59.803544377 +0200
|
||||
@@ -308,12 +308,12 @@ static int modify_flags(int fd, int clea
|
||||
void sys_init(void)
|
||||
{
|
||||
/* Get an internet socket for doing socket ioctls. */
|
||||
- sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
+ sock_fd = socket_fd(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sock_fd < 0)
|
||||
fatal("Couldn't create IP socket: %m(%d)", errno);
|
||||
|
||||
#ifdef INET6
|
||||
- sock6_fd = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
+ sock6_fd = socket_fd(AF_INET6, SOCK_DGRAM, 0);
|
||||
if (sock6_fd < 0)
|
||||
sock6_fd = -errno; /* save errno for later */
|
||||
#endif
|
||||
@@ -459,7 +459,7 @@ int generic_establish_ppp (int fd)
|
||||
goto err;
|
||||
}
|
||||
dbglog("using channel %d", chindex);
|
||||
- fd = open("/dev/ppp", O_RDWR);
|
||||
+ fd = open_fd("/dev/ppp", O_RDWR);
|
||||
if (fd < 0) {
|
||||
error("Couldn't reopen /dev/ppp: %m");
|
||||
goto err;
|
||||
@@ -619,7 +619,7 @@ static int make_ppp_unit()
|
||||
dbglog("in make_ppp_unit, already had /dev/ppp open?");
|
||||
close(ppp_dev_fd);
|
||||
}
|
||||
- ppp_dev_fd = open("/dev/ppp", O_RDWR);
|
||||
+ ppp_dev_fd = open_fd("/dev/ppp", O_RDWR);
|
||||
if (ppp_dev_fd < 0)
|
||||
fatal("Couldn't open /dev/ppp: %m");
|
||||
flags = fcntl(ppp_dev_fd, F_GETFL);
|
||||
@@ -693,7 +693,7 @@ int bundle_attach(int ifnum)
|
||||
if (!new_style_driver)
|
||||
return -1;
|
||||
|
||||
- master_fd = open("/dev/ppp", O_RDWR);
|
||||
+ master_fd = open_fd("/dev/ppp", O_RDWR);
|
||||
if (master_fd < 0)
|
||||
fatal("Couldn't open /dev/ppp: %m");
|
||||
if (ioctl(master_fd, PPPIOCATTACH, &ifnum) < 0) {
|
||||
@@ -1412,7 +1412,7 @@ static char *path_to_procfs(const char *
|
||||
/* Default the mount location of /proc */
|
||||
strlcpy (proc_path, "/proc", sizeof(proc_path));
|
||||
proc_path_len = 5;
|
||||
- fp = fopen(MOUNTED, "r");
|
||||
+ fp = fopen_r(MOUNTED);
|
||||
if (fp != NULL) {
|
||||
while ((mntent = getmntent(fp)) != NULL) {
|
||||
if (strcmp(mntent->mnt_type, MNTTYPE_IGNORE) == 0)
|
||||
@@ -1472,7 +1472,7 @@ static int open_route_table (void)
|
||||
close_route_table();
|
||||
|
||||
path = path_to_procfs("/net/route");
|
||||
- route_fd = fopen (path, "r");
|
||||
+ route_fd = fopen_r(path);
|
||||
if (route_fd == NULL) {
|
||||
error("can't open routing table %s: %m", path);
|
||||
return 0;
|
||||
@@ -1713,7 +1713,7 @@ int sifproxyarp (int unit, u_int32_t his
|
||||
if (tune_kernel) {
|
||||
forw_path = path_to_procfs("/sys/net/ipv4/ip_forward");
|
||||
if (forw_path != 0) {
|
||||
- int fd = open(forw_path, O_WRONLY);
|
||||
+ int fd = open_fd(forw_path, O_WRONLY);
|
||||
if (fd >= 0) {
|
||||
if (write(fd, "1", 1) != 1)
|
||||
error("Couldn't enable IP forwarding: %m");
|
||||
@@ -1855,7 +1855,7 @@ get_if_hwaddr(u_char *addr, char *name)
|
||||
struct ifreq ifreq;
|
||||
int ret, sock_fd;
|
||||
|
||||
- sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
+ sock_fd = socket_fd(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sock_fd < 0)
|
||||
return 0;
|
||||
memset(&ifreq.ifr_hwaddr, 0, sizeof(struct sockaddr));
|
||||
@@ -2036,19 +2036,19 @@ int ppp_available(void)
|
||||
sscanf(utsname.release, "%d.%d.%d", &osmaj, &osmin, &ospatch);
|
||||
kernel_version = KVERSION(osmaj, osmin, ospatch);
|
||||
|
||||
- fd = open("/dev/ppp", O_RDWR);
|
||||
+ fd = open_fd("/dev/ppp", O_RDWR);
|
||||
#if 0
|
||||
if (fd < 0 && errno == ENOENT) {
|
||||
/* try making it and see if that helps. */
|
||||
if (mknod("/dev/ppp", S_IFCHR | S_IRUSR | S_IWUSR,
|
||||
makedev(108, 0)) >= 0) {
|
||||
- fd = open("/dev/ppp", O_RDWR);
|
||||
+ fd = open_fd("/dev/ppp", O_RDWR);
|
||||
if (fd >= 0)
|
||||
info("Created /dev/ppp device node");
|
||||
else
|
||||
unlink("/dev/ppp"); /* didn't work, undo the mknod */
|
||||
} else if (errno == EEXIST) {
|
||||
- fd = open("/dev/ppp", O_RDWR);
|
||||
+ fd = open_fd("/dev/ppp", O_RDWR);
|
||||
}
|
||||
}
|
||||
#endif /* 0 */
|
||||
@@ -2075,7 +2075,7 @@ int ppp_available(void)
|
||||
/*
|
||||
* Open a socket for doing the ioctl operations.
|
||||
*/
|
||||
- s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
+ s = socket_fd(AF_INET, SOCK_DGRAM, 0);
|
||||
if (s < 0)
|
||||
return 0;
|
||||
|
||||
@@ -2323,7 +2323,7 @@ int sifaddr (int unit, u_int32_t our_adr
|
||||
int fd;
|
||||
|
||||
path = path_to_procfs("/sys/net/ipv4/ip_dynaddr");
|
||||
- if (path != 0 && (fd = open(path, O_WRONLY)) >= 0) {
|
||||
+ if (path != 0 && (fd = open_fd(path, O_WRONLY)) >= 0) {
|
||||
if (write(fd, "1", 1) != 1)
|
||||
error("Couldn't enable dynamic IP addressing: %m");
|
||||
close(fd);
|
||||
@@ -2499,7 +2499,7 @@ get_pty(master_fdp, slave_fdp, slave_nam
|
||||
/*
|
||||
* Try the unix98 way first.
|
||||
*/
|
||||
- mfd = open("/dev/ptmx", O_RDWR);
|
||||
+ mfd = open_fd("/dev/ptmx", O_RDWR);
|
||||
if (mfd >= 0) {
|
||||
int ptn;
|
||||
if (ioctl(mfd, TIOCGPTN, &ptn) >= 0) {
|
||||
@@ -2510,7 +2510,7 @@ get_pty(master_fdp, slave_fdp, slave_nam
|
||||
if (ioctl(mfd, TIOCSPTLCK, &ptn) < 0)
|
||||
warn("Couldn't unlock pty slave %s: %m", pty_name);
|
||||
#endif
|
||||
- if ((sfd = open(pty_name, O_RDWR | O_NOCTTY)) < 0)
|
||||
+ if ((sfd = open_fd(pty_name, O_RDWR | O_NOCTTY)) < 0)
|
||||
warn("Couldn't open pty slave %s: %m", pty_name);
|
||||
}
|
||||
}
|
||||
@@ -2521,10 +2521,10 @@ get_pty(master_fdp, slave_fdp, slave_nam
|
||||
for (i = 0; i < 64; ++i) {
|
||||
slprintf(pty_name, sizeof(pty_name), "/dev/pty%c%x",
|
||||
'p' + i / 16, i % 16);
|
||||
- mfd = open(pty_name, O_RDWR, 0);
|
||||
+ mfd = open_fd_mode(pty_name, O_RDWR, 0);
|
||||
if (mfd >= 0) {
|
||||
pty_name[5] = 't';
|
||||
- sfd = open(pty_name, O_RDWR | O_NOCTTY, 0);
|
||||
+ sfd = open_fd_mode(pty_name, O_RDWR | O_NOCTTY, 0);
|
||||
if (sfd >= 0) {
|
||||
fchown(sfd, uid, -1);
|
||||
fchmod(sfd, S_IRUSR | S_IWUSR);
|
||||
@@ -2789,7 +2789,7 @@ ether_to_eui64(eui64_t *p_eui64)
|
||||
int skfd;
|
||||
const unsigned char *ptr;
|
||||
|
||||
- skfd = socket(PF_INET6, SOCK_DGRAM, 0);
|
||||
+ skfd = socket_fd(PF_INET6, SOCK_DGRAM, 0);
|
||||
if(skfd == -1)
|
||||
{
|
||||
warn("could not open IPv6 socket");
|
||||
diff -up ppp-2.4.4/pppd/tdb.c.fd_leak ppp-2.4.4/pppd/tdb.c
|
||||
--- ppp-2.4.4/pppd/tdb.c.fd_leak 2004-11-13 08:13:07.000000000 +0100
|
||||
+++ ppp-2.4.4/pppd/tdb.c 2009-10-08 21:22:59.806583590 +0200
|
||||
@@ -1724,7 +1724,7 @@ TDB_CONTEXT *tdb_open_ex(const char *nam
|
||||
goto internal;
|
||||
}
|
||||
|
||||
- if ((tdb->fd = open(name, open_flags, mode)) == -1) {
|
||||
+ if ((tdb->fd = open_fd_mode(name, open_flags, mode)) == -1) {
|
||||
TDB_LOG((tdb, 5, "tdb_open_ex: could not open file %s: %s\n",
|
||||
name, strerror(errno)));
|
||||
goto fail; /* errno set by open(2) */
|
||||
@@ -1967,7 +1967,7 @@ int tdb_reopen(TDB_CONTEXT *tdb)
|
||||
}
|
||||
if (close(tdb->fd) != 0)
|
||||
TDB_LOG((tdb, 0, "tdb_reopen: WARNING closing tdb->fd failed!\n"));
|
||||
- tdb->fd = open(tdb->name, tdb->open_flags & ~(O_CREAT|O_TRUNC), 0);
|
||||
+ tdb->fd = open_fd_mode(tdb->name, tdb->open_flags & ~(O_CREAT|O_TRUNC), 0);
|
||||
if (tdb->fd == -1) {
|
||||
TDB_LOG((tdb, 0, "tdb_reopen: open failed (%s)\n", strerror(errno)));
|
||||
goto fail;
|
||||
diff -up ppp-2.4.4/pppd/tty.c.fd_leak ppp-2.4.4/pppd/tty.c
|
||||
--- ppp-2.4.4/pppd/tty.c.fd_leak 2006-06-04 09:04:57.000000000 +0200
|
||||
+++ ppp-2.4.4/pppd/tty.c 2009-10-08 21:22:59.809544300 +0200
|
||||
@@ -569,7 +569,7 @@ int connect_tty()
|
||||
status = EXIT_OPEN_FAILED;
|
||||
goto errret;
|
||||
}
|
||||
- real_ttyfd = open(devnam, O_NONBLOCK | O_RDWR, 0);
|
||||
+ real_ttyfd = open_fd_mode(devnam, O_NONBLOCK | O_RDWR, 0);
|
||||
err = errno;
|
||||
if (prio < OPRIO_ROOT && seteuid(0) == -1)
|
||||
fatal("Unable to regain privileges");
|
||||
@@ -723,7 +723,7 @@ int connect_tty()
|
||||
if (connector == NULL && modem && devnam[0] != 0) {
|
||||
int i;
|
||||
for (;;) {
|
||||
- if ((i = open(devnam, O_RDWR)) >= 0)
|
||||
+ if ((i = open_fd(devnam, O_RDWR)) >= 0)
|
||||
break;
|
||||
if (errno != EINTR) {
|
||||
error("Failed to reopen %s: %m", devnam);
|
||||
@@ -893,7 +893,8 @@ open_socket(dest)
|
||||
*sep = ':';
|
||||
|
||||
/* get a socket and connect it to the other end */
|
||||
- sock = socket(PF_INET, SOCK_STREAM, 0);
|
||||
+ //sock = socket(PF_INET, SOCK_STREAM, 0);
|
||||
+ sock = socket_fd(PF_INET, SOCK_STREAM, 0);
|
||||
if (sock < 0) {
|
||||
error("Can't create socket: %m");
|
||||
return -1;
|
||||
diff -up ppp-2.4.4/pppd/utils.c.fd_leak ppp-2.4.4/pppd/utils.c
|
||||
--- ppp-2.4.4/pppd/utils.c.fd_leak 2009-10-08 21:22:59.620325739 +0200
|
||||
+++ ppp-2.4.4/pppd/utils.c 2009-10-08 21:22:59.811573725 +0200
|
||||
@@ -931,14 +931,14 @@ lock(dev)
|
||||
slprintf(lock_file, sizeof(lock_file), "%s/LCK..%s", LOCK_DIR, dev);
|
||||
#endif
|
||||
|
||||
- while ((fd = open(lock_file, O_EXCL | O_CREAT | O_RDWR, 0644)) < 0) {
|
||||
+ while ((fd = open_fd_mode(lock_file, O_EXCL | O_CREAT | O_RDWR, 0644)) < 0) {
|
||||
if (errno != EEXIST) {
|
||||
error("Can't create lock file %s: %m", lock_file);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Read the lock file to find out who has the device locked. */
|
||||
- fd = open(lock_file, O_RDONLY, 0);
|
||||
+ fd = open_fd_mode(lock_file, O_RDONLY, 0);
|
||||
if (fd < 0) {
|
||||
if (errno == ENOENT) /* This is just a timing problem. */
|
||||
continue;
|
||||
@@ -1017,7 +1017,7 @@ relock(pid)
|
||||
|
||||
if (lock_file[0] == 0)
|
||||
return -1;
|
||||
- fd = open(lock_file, O_WRONLY, 0);
|
||||
+ fd = open_fd_mode(lock_file, O_WRONLY, 0);
|
||||
if (fd < 0) {
|
||||
error("Couldn't reopen lock file %s: %m", lock_file);
|
||||
lock_file[0] = 0;
|
290
ppp-2.4.4-gigaword.patch
Normal file
290
ppp-2.4.4-gigaword.patch
Normal file
@ -0,0 +1,290 @@
|
||||
diff -Npru ppp/pppd/main.c ppp-2.4.4b1/pppd/main.c
|
||||
--- ppp/pppd/main.c 2005-08-26 01:59:34.000000000 +0200
|
||||
+++ ppp-2.4.4b1/pppd/main.c 2006-11-28 17:07:23.000000000 +0100
|
||||
@@ -1345,9 +1345,9 @@ update_link_stats(u)
|
||||
|
||||
slprintf(numbuf, sizeof(numbuf), "%u", link_connect_time);
|
||||
script_setenv("CONNECT_TIME", numbuf, 0);
|
||||
- slprintf(numbuf, sizeof(numbuf), "%u", link_stats.bytes_out);
|
||||
+ snprintf(numbuf, sizeof(numbuf), "%llu", link_stats.bytes_out);
|
||||
script_setenv("BYTES_SENT", numbuf, 0);
|
||||
- slprintf(numbuf, sizeof(numbuf), "%u", link_stats.bytes_in);
|
||||
+ snprintf(numbuf, sizeof(numbuf), "%llu", link_stats.bytes_in);
|
||||
script_setenv("BYTES_RCVD", numbuf, 0);
|
||||
}
|
||||
|
||||
diff -Npru ppp/pppd/plugins/radius/avpair.c ppp-2.4.4b1/pppd/plugins/radius/avpair.c
|
||||
--- ppp/pppd/plugins/radius/avpair.c 2004-11-14 08:26:26.000000000 +0100
|
||||
+++ ppp-2.4.4b1/pppd/plugins/radius/avpair.c 2006-11-28 17:10:04.000000000 +0100
|
||||
@@ -291,9 +291,19 @@ static void rc_extract_vendor_specific_a
|
||||
/* Set attrlen to length of data */
|
||||
attrlen -= 4;
|
||||
for (; attrlen; attrlen -= vlen+2, ptr += vlen) {
|
||||
- vtype = *ptr++;
|
||||
- vlen = *ptr++;
|
||||
- vlen -= 2;
|
||||
+
|
||||
+ if ( vendor_id == VENDOR_USR ) {
|
||||
+ vlen = attrlen - 4;
|
||||
+ vtype = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | ptr[3];
|
||||
+ ptr += 4;
|
||||
+ /* fixup */
|
||||
+ attrlen -= 2;
|
||||
+ } else {
|
||||
+ vtype = *ptr++;
|
||||
+ vlen = *ptr++;
|
||||
+ vlen -= 2;
|
||||
+ }
|
||||
+
|
||||
if (vlen < 0 || vlen > attrlen - 2) {
|
||||
/* Do not log an error. We are supposed to be able to cope with
|
||||
arbitrary vendor-specific gunk */
|
||||
diff -Npru ppp/pppd/plugins/radius/etc/dictionary ppp-2.4.4b1/pppd/plugins/radius/etc/dictionary
|
||||
--- ppp/pppd/plugins/radius/etc/dictionary 2004-11-14 08:26:26.000000000 +0100
|
||||
+++ ppp-2.4.4b1/pppd/plugins/radius/etc/dictionary 2006-11-28 17:43:12.000000000 +0100
|
||||
@@ -81,6 +81,8 @@ ATTRIBUTE Acct-Authentic 45 integer
|
||||
ATTRIBUTE Acct-Session-Time 46 integer
|
||||
ATTRIBUTE Acct-Input-Packets 47 integer
|
||||
ATTRIBUTE Acct-Output-Packets 48 integer
|
||||
+ATTRIBUTE Acct-Input-Gigawords 52 integer
|
||||
+ATTRIBUTE Acct-Output-Gigawords 53 integer
|
||||
ATTRIBUTE Acct-Terminate-Cause 49 integer
|
||||
ATTRIBUTE Chap-Challenge 60 string
|
||||
ATTRIBUTE NAS-Port-Type 61 integer
|
||||
diff -Npru ppp/pppd/plugins/radius/radius.c ppp-2.4.4b1/pppd/plugins/radius/radius.c
|
||||
--- ppp/pppd/plugins/radius/radius.c 2005-07-10 12:28:55.000000000 +0200
|
||||
+++ ppp-2.4.4b1/pppd/plugins/radius/radius.c 2006-11-28 17:57:00.000000000 +0100
|
||||
@@ -963,18 +963,44 @@ radius_acct_stop(void)
|
||||
|
||||
|
||||
if (link_stats_valid) {
|
||||
+ DICT_ATTR* attr;
|
||||
+ static char bigint[64];
|
||||
+
|
||||
av_type = link_connect_time;
|
||||
rc_avpair_add(&send, PW_ACCT_SESSION_TIME, &av_type, 0, VENDOR_NONE);
|
||||
|
||||
- av_type = link_stats.bytes_out;
|
||||
+ if ( (attr=rc_dict_findattr("Acct-Output-Octets-64")) ) {
|
||||
+ snprintf(bigint,sizeof(bigint),"%llu",link_stats.bytes_out);
|
||||
+ rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
|
||||
+ }
|
||||
+ av_type = (UINT4)link_stats.bytes_out;
|
||||
rc_avpair_add(&send, PW_ACCT_OUTPUT_OCTETS, &av_type, 0, VENDOR_NONE);
|
||||
|
||||
- av_type = link_stats.bytes_in;
|
||||
+ av_type = (UINT4)(link_stats.bytes_out >> 32);
|
||||
+ rc_avpair_add(&send, PW_ACCT_OUTPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE);
|
||||
+
|
||||
+ if ( (attr=rc_dict_findattr("Acct-Input-Octets-64")) ) {
|
||||
+ snprintf(bigint,sizeof(bigint),"%llu",link_stats.bytes_in);
|
||||
+ rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
|
||||
+ }
|
||||
+ av_type = (UINT4)link_stats.bytes_in;
|
||||
rc_avpair_add(&send, PW_ACCT_INPUT_OCTETS, &av_type, 0, VENDOR_NONE);
|
||||
|
||||
+ av_type = (UINT4)(link_stats.bytes_in >> 32);
|
||||
+ rc_avpair_add(&send, PW_ACCT_INPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE);
|
||||
+
|
||||
+ if ( (attr=rc_dict_findattr("Acct-Output-Packets-64")) ) {
|
||||
+ snprintf(bigint,sizeof(bigint),"%llu",link_stats.pkts_out);
|
||||
+ rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
|
||||
+ }
|
||||
+
|
||||
av_type = link_stats.pkts_out;
|
||||
rc_avpair_add(&send, PW_ACCT_OUTPUT_PACKETS, &av_type, 0, VENDOR_NONE);
|
||||
-
|
||||
+
|
||||
+ if ( (attr=rc_dict_findattr("Acct-Input-Packets-64")) ) {
|
||||
+ snprintf(bigint,sizeof(bigint),"%llu",link_stats.pkts_in);
|
||||
+ rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
|
||||
+ }
|
||||
av_type = link_stats.pkts_in;
|
||||
rc_avpair_add(&send, PW_ACCT_INPUT_PACKETS, &av_type, 0, VENDOR_NONE);
|
||||
}
|
||||
@@ -1105,20 +1131,45 @@ radius_acct_interim(void *ignored)
|
||||
update_link_stats(0);
|
||||
|
||||
if (link_stats_valid) {
|
||||
+ DICT_ATTR* attr;
|
||||
+ static char bigint[64];
|
||||
+
|
||||
link_stats_valid = 0; /* Force later code to update */
|
||||
|
||||
av_type = link_connect_time;
|
||||
rc_avpair_add(&send, PW_ACCT_SESSION_TIME, &av_type, 0, VENDOR_NONE);
|
||||
|
||||
- av_type = link_stats.bytes_out;
|
||||
+ if ( (attr=rc_dict_findattr("Acct-Output-Octets-64")) ) {
|
||||
+ snprintf(bigint,sizeof(bigint),"%llu",link_stats.bytes_out);
|
||||
+ rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
|
||||
+ }
|
||||
+ av_type = (UINT4)link_stats.bytes_out;
|
||||
rc_avpair_add(&send, PW_ACCT_OUTPUT_OCTETS, &av_type, 0, VENDOR_NONE);
|
||||
|
||||
- av_type = link_stats.bytes_in;
|
||||
+ av_type = (UINT4)(link_stats.bytes_out >> 32);
|
||||
+ rc_avpair_add(&send, PW_ACCT_OUTPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE);
|
||||
+
|
||||
+ if ( (attr=rc_dict_findattr("Acct-Input-Octets-64")) ) {
|
||||
+ snprintf(bigint,sizeof(bigint),"%llu",link_stats.bytes_in);
|
||||
+ rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
|
||||
+ }
|
||||
+ av_type = (UINT4)link_stats.bytes_in;
|
||||
rc_avpair_add(&send, PW_ACCT_INPUT_OCTETS, &av_type, 0, VENDOR_NONE);
|
||||
|
||||
+ av_type = (UINT4)(link_stats.bytes_in >> 32);
|
||||
+ rc_avpair_add(&send, PW_ACCT_INPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE);
|
||||
+
|
||||
+ if ( (attr=rc_dict_findattr("Acct-Output-Packets-64")) ) {
|
||||
+ snprintf(bigint,sizeof(bigint),"%llu",link_stats.pkts_out);
|
||||
+ rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
|
||||
+ }
|
||||
av_type = link_stats.pkts_out;
|
||||
rc_avpair_add(&send, PW_ACCT_OUTPUT_PACKETS, &av_type, 0, VENDOR_NONE);
|
||||
|
||||
+ if ( (attr=rc_dict_findattr("Acct-Input-Packets-64")) ) {
|
||||
+ snprintf(bigint,sizeof(bigint),"%llu",link_stats.pkts_in);
|
||||
+ rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
|
||||
+ }
|
||||
av_type = link_stats.pkts_in;
|
||||
rc_avpair_add(&send, PW_ACCT_INPUT_PACKETS, &av_type, 0, VENDOR_NONE);
|
||||
}
|
||||
diff -Npru ppp/pppd/plugins/radius/radiusclient.h ppp-2.4.4b1/pppd/plugins/radius/radiusclient.h
|
||||
--- ppp/pppd/plugins/radius/radiusclient.h 2004-11-14 08:26:26.000000000 +0100
|
||||
+++ ppp-2.4.4b1/pppd/plugins/radius/radiusclient.h 2006-11-28 17:42:32.000000000 +0100
|
||||
@@ -167,6 +167,8 @@ typedef struct pw_auth_hdr
|
||||
#define PW_ACCT_TERMINATE_CAUSE 49 /* integer */
|
||||
#define PW_ACCT_MULTI_SESSION_ID 50 /* string */
|
||||
#define PW_ACCT_LINK_COUNT 51 /* integer */
|
||||
+#define PW_ACCT_INPUT_GIGAWORDS 52 /* integer */
|
||||
+#define PW_ACCT_OUTPUT_GIGAWORDS 53 /* integer */
|
||||
|
||||
/* From RFC 2869 */
|
||||
#define PW_ACCT_INTERIM_INTERVAL 85 /* integer */
|
||||
@@ -292,6 +294,7 @@ typedef struct pw_auth_hdr
|
||||
/* Vendor codes */
|
||||
#define VENDOR_NONE (-1)
|
||||
#define VENDOR_MICROSOFT 311
|
||||
+#define VENDOR_USR 429
|
||||
|
||||
/* Server data structures */
|
||||
|
||||
diff -Npru ppp/pppd/plugins/radius/sendserver.c ppp-2.4.4b1/pppd/plugins/radius/sendserver.c
|
||||
--- ppp/pppd/plugins/radius/sendserver.c 2004-11-14 08:26:26.000000000 +0100
|
||||
+++ ppp-2.4.4b1/pppd/plugins/radius/sendserver.c 2006-11-28 17:32:34.000000000 +0100
|
||||
@@ -56,6 +56,14 @@ static int rc_pack_list (VALUE_PAIR *vp,
|
||||
*buf++ = (((unsigned int) vp->vendorcode) >> 8) & 255;
|
||||
*buf++ = ((unsigned int) vp->vendorcode) & 255;
|
||||
|
||||
+ /* Stolen from freeradius's source, that USR vendor
|
||||
+ /* attributes are to handled otherwise */
|
||||
+ if ( vp->vendorcode == VENDOR_USR ) {
|
||||
+ *buf++ = (vp->attribute >> 24) & 0xff;
|
||||
+ *buf++ = (vp->attribute >> 16) & 0xff;
|
||||
+ *buf++ = (vp->attribute >> 8) & 0xff;
|
||||
+ }
|
||||
+
|
||||
/* Insert vendor-type */
|
||||
*buf++ = vp->attribute;
|
||||
|
||||
@@ -64,7 +72,8 @@ static int rc_pack_list (VALUE_PAIR *vp,
|
||||
case PW_TYPE_STRING:
|
||||
length = vp->lvalue;
|
||||
*lenptr = length + 8;
|
||||
- *buf++ = length+2;
|
||||
+ if ( vp->vendorcode != VENDOR_USR )
|
||||
+ *buf++ = length+2;
|
||||
memcpy(buf, vp->strvalue, (size_t) length);
|
||||
buf += length;
|
||||
total_length += length+8;
|
||||
@@ -73,7 +82,8 @@ static int rc_pack_list (VALUE_PAIR *vp,
|
||||
case PW_TYPE_IPADDR:
|
||||
length = sizeof(UINT4);
|
||||
*lenptr = length + 8;
|
||||
- *buf++ = length+2;
|
||||
+ if ( vp->vendorcode != VENDOR_USR )
|
||||
+ *buf++ = length+2;
|
||||
lvalue = htonl(vp->lvalue);
|
||||
memcpy(buf, (char *) &lvalue, sizeof(UINT4));
|
||||
buf += length;
|
||||
@@ -82,6 +92,10 @@ static int rc_pack_list (VALUE_PAIR *vp,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
+ if ( vp->vendorcode == VENDOR_USR ) {
|
||||
+ *lenptr += 2;
|
||||
+ total_length += 2;
|
||||
+ }
|
||||
} else {
|
||||
*buf++ = vp->attribute;
|
||||
switch (vp->attribute) {
|
||||
diff -Npru ppp/pppd/pppd.h ppp-2.4.4b1/pppd/pppd.h
|
||||
--- ppp/pppd/pppd.h 2005-08-26 01:59:34.000000000 +0200
|
||||
+++ ppp-2.4.4b1/pppd/pppd.h 2006-11-28 17:33:38.000000000 +0100
|
||||
@@ -170,10 +170,10 @@ struct permitted_ip {
|
||||
* pppd needs.
|
||||
*/
|
||||
struct pppd_stats {
|
||||
- unsigned int bytes_in;
|
||||
- unsigned int bytes_out;
|
||||
- unsigned int pkts_in;
|
||||
- unsigned int pkts_out;
|
||||
+ unsigned long long bytes_in;
|
||||
+ unsigned long long bytes_out;
|
||||
+ unsigned long long pkts_in;
|
||||
+ unsigned long long pkts_out;
|
||||
};
|
||||
|
||||
/* Used for storing a sequence of words. Usually malloced. */
|
||||
diff -Npru ppp/pppd/sys-linux.c ppp-2.4.4b1/pppd/sys-linux.c
|
||||
--- ppp/pppd/sys-linux.c 2005-08-28 07:23:26.000000000 +0200
|
||||
+++ ppp-2.4.4b1/pppd/sys-linux.c 2006-11-28 17:37:16.000000000 +0100
|
||||
@@ -1356,6 +1356,10 @@ get_idle_time(u, ip)
|
||||
*
|
||||
* get_ppp_stats - return statistics for the link.
|
||||
*/
|
||||
+
|
||||
+static struct ifpppstatsreq prev_stat_req;
|
||||
+static struct pppd_stats static_stats;
|
||||
+
|
||||
int
|
||||
get_ppp_stats(u, stats)
|
||||
int u;
|
||||
@@ -1371,10 +1371,21 @@ get_ppp_stats(u, stats)
|
||||
error("Couldn't get PPP statistics: %m");
|
||||
return 0;
|
||||
}
|
||||
- stats->bytes_in = req.stats.p.ppp_ibytes;
|
||||
- stats->bytes_out = req.stats.p.ppp_obytes;
|
||||
- stats->pkts_in = req.stats.p.ppp_ipackets;
|
||||
- stats->pkts_out = req.stats.p.ppp_opackets;
|
||||
+ // Calculate the elapsed bytes since the last query
|
||||
+ static_stats.bytes_in +=
|
||||
+ (req.stats.p.ppp_ibytes - prev_stat_req.stats.p.ppp_ibytes);
|
||||
+ static_stats.bytes_out +=
|
||||
+ (req.stats.p.ppp_obytes - prev_stat_req.stats.p.ppp_obytes);
|
||||
+ static_stats.pkts_in +=
|
||||
+ (req.stats.p.ppp_ipackets - prev_stat_req.stats.p.ppp_ipackets);
|
||||
+ static_stats.pkts_out +=
|
||||
+ (req.stats.p.ppp_opackets - prev_stat_req.stats.p.ppp_opackets);
|
||||
+ // Store the current state
|
||||
+ memcpy(&prev_stat_req,&req,sizeof(prev_stat_req));
|
||||
+
|
||||
+ // Give out the statistics
|
||||
+ memcpy(stats,&static_stats,sizeof(static_stats));
|
||||
+
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2185,6 +2185,10 @@ int sifup(int u)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
|
||||
+ // Initialize the 'previous stats struct'
|
||||
+ memset(&prev_stat_req,0,sizeof(prev_stat_req));
|
||||
+ // And the static statistics puffer
|
||||
+ memset(&static_stats,0,sizeof(static_stats));
|
||||
memset (&ifr, '\0', sizeof (ifr));
|
||||
strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
|
||||
if (ioctl(sock_fd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
|
14
ppp.spec
14
ppp.spec
@ -1,7 +1,7 @@
|
||||
Summary: The PPP (Point-to-Point Protocol) daemon.
|
||||
Name: ppp
|
||||
Version: 2.4.4
|
||||
Release: 11%{?dist}
|
||||
Release: 13%{?dist}
|
||||
License: BSD and LGPLv2+ and GPLv2+ and Public Domain
|
||||
Group: System Environment/Daemons
|
||||
Source0: ftp://ftp.samba.org/pub/ppp/ppp-%{version}.tar.gz
|
||||
@ -28,6 +28,8 @@ Patch24: ppp-2.4.4-closelog.patch
|
||||
Patch25: ppp-2.4.4-response_len.patch
|
||||
Patch26: ppp-2.4.4-new_speeds.patch
|
||||
Patch27: ppp-2.4.4-bogus_dns_addr.patch
|
||||
Patch28: ppp-2.4.4-fd_leak.patch
|
||||
Patch29: ppp-2.4.4-gigaword.patch
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-root
|
||||
BuildPrereq: pam-devel, libpcap-devel
|
||||
@ -72,6 +74,8 @@ This package contains the header files for building plugins for ppp.
|
||||
%patch25 -p1 -b .response_len
|
||||
%patch26 -p1 -b .new_speeds
|
||||
%patch27 -p1 -b .bogus_dns_addr
|
||||
%patch28 -p1 -b .fd_leak
|
||||
%patch29 -p1 -b .gigaword
|
||||
|
||||
rm -f scripts/*.local
|
||||
rm -f scripts/*.change_resolv_conf
|
||||
@ -136,6 +140,14 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%doc PLUGINS
|
||||
|
||||
%changelog
|
||||
* Mon May 10 2010 - Jiri Skala <jskala@redhat.com> 2.4.4-13
|
||||
- removed ppp-2.4.3 from sources
|
||||
- fixes #521167 - RFE: Gigawords support in ppp
|
||||
|
||||
* Wed Jan 06 2010 - Jiri Skala <jskala@redhat.com> 2.4.4-12
|
||||
- fixed #467004 - PPP sometimes gets incorrect DNS servers for mobile connection
|
||||
- added close-on-exec due to #498789
|
||||
|
||||
* Fri Mar 06 2009 - Jiri Skala <jskala@redhat.com> 2.4.4-11
|
||||
- fixed #488764 - package upgrade should not replace configuration files
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user