fixes #682381 - hardcodes eth0

fixes #708260 - SELinux is preventing access on the file LCK..ttyUSB3
This commit is contained in:
Jiri Skala 2011-06-02 08:05:40 +02:00
parent 0875fb0478
commit e7c7404005
4 changed files with 150 additions and 1 deletions

124
ppp-2.4.5-eth.patch Normal file
View File

@ -0,0 +1,124 @@
diff -up ppp-2.4.5/pppd/ether.c.inc.eth ppp-2.4.5/pppd/ether.c.inc
--- ppp-2.4.5/pppd/ether.c.inc.eth 2011-06-01 10:28:35.356139063 +0200
+++ ppp-2.4.5/pppd/ether.c.inc 2011-06-01 11:20:37.876897352 +0200
@@ -0,0 +1,46 @@
+#define PREF_ETH "eth"
+#define PREF_EM "em"
+
+static char *dev_file = "/proc/self/net/dev";
+
+/*
+ * get_first_ethernet - return the name of the first ethernet-style
+ * interface on this system.
+ */
+char *
+get_first_ethernet()
+{
+ FILE *f;
+ char buf[255], *dv, *smc;
+ char pci[16];
+
+ memset(pci, 0, sizeof(pci));
+ if ((f = fopen(dev_file, "r")) != NULL)
+ {
+ // go through network dev file
+ while (fgets (buf, sizeof(buf), f) != NULL)
+ {
+ // the line describes interface
+ if ((smc = strchr(buf, ':')) != NULL)
+ {
+ // trim white characters
+ for (dv=buf, *smc=0; *dv <= ' '; dv++) ;
+ // is "eth" (originial ethernet name) or "em" (ethernet on board)
+ if (!strncmp(dv, PREF_ETH, strlen(PREF_ETH)) ||
+ !strncmp(dv, PREF_EM, strlen(PREF_EM)))
+ {
+ return strdup(dv);
+ }
+ // remember the first pci NIC-card
+ if (strlen(pci) == 0 && dv[0] == 'p' && isdigit(dv[1]))
+ {
+ strcpy(pci, dv);
+ }
+ }
+ }
+ fclose(f);
+ }
+ // return pci NIC-card or nil if no if name
+ return strlen(pci) > 0 ? strdup(pci) : 0L;
+}
+
diff -up ppp-2.4.5/pppd/plugins/rp-pppoe/pppoe-discovery.c.eth ppp-2.4.5/pppd/plugins/rp-pppoe/pppoe-discovery.c
--- ppp-2.4.5/pppd/plugins/rp-pppoe/pppoe-discovery.c.eth 2011-06-01 09:39:13.099343548 +0200
+++ ppp-2.4.5/pppd/plugins/rp-pppoe/pppoe-discovery.c 2011-06-01 11:41:02.188252304 +0200
@@ -47,6 +47,8 @@
#include <net/if_arp.h>
#endif
+#include "../../ether.c.inc"
+
char *xstrdup(const char *s);
void usage(void);
@@ -686,7 +688,7 @@ int main(int argc, char *argv[])
/* default interface name */
if (!conn->ifName)
- conn->ifName = strdup("eth0");
+ conn->ifName = get_first_ethernet();
conn->discoverySocket = -1;
conn->sessionSocket = -1;
diff -up ppp-2.4.5/pppd/sys-linux.c.eth ppp-2.4.5/pppd/sys-linux.c
--- ppp-2.4.5/pppd/sys-linux.c.eth 2011-06-01 09:39:13.074343397 +0200
+++ ppp-2.4.5/pppd/sys-linux.c 2011-06-01 11:50:13.736565685 +0200
@@ -144,6 +144,8 @@
#include <sys/locks.h>
#endif
+#include "ether.c.inc"
+
#ifdef INET6
#ifndef _LINUX_IN6_H
/*
@@ -1869,16 +1871,6 @@ get_if_hwaddr(u_char *addr, char *name)
return ret;
}
-/*
- * get_first_ethernet - return the name of the first ethernet-style
- * interface on this system.
- */
-char *
-get_first_ethernet()
-{
- return "eth0";
-}
-
/********************************************************************
*
* Return user specified netmask, modified by any mask we might determine
@@ -2783,6 +2775,7 @@ ether_to_eui64(eui64_t *p_eui64)
struct ifreq ifr;
int skfd;
const unsigned char *ptr;
+ char warn_msg[80];
skfd = socket_fd(PF_INET6, SOCK_DGRAM, 0);
if(skfd == -1)
@@ -2791,11 +2784,13 @@ ether_to_eui64(eui64_t *p_eui64)
return 0;
}
- strcpy(ifr.ifr_name, "eth0");
+ strcpy(ifr.ifr_name, get_first_ethernet());
if(ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0)
{
close(skfd);
- warn("could not obtain hardware address for eth0");
+ snprintf(warn_msg, sizeof(warn_msg),
+ "could not obtain hardware address for %s", ifr.ifr_name);
+ warn(warn_msg);
return 0;
}
close(skfd);

12
ppp-2.4.5-lock.patch Normal file
View File

@ -0,0 +1,12 @@
diff -up ppp-2.4.5/pppd/utils.c.lock ppp-2.4.5/pppd/utils.c
--- ppp-2.4.5/pppd/utils.c.lock 2011-05-30 15:30:36.432371849 +0200
+++ ppp-2.4.5/pppd/utils.c 2011-05-30 15:30:48.575495854 +0200
@@ -859,7 +859,7 @@ complete_read(int fd, void *buf, size_t
/* Procedures for locking the serial device using a lock file. */
#ifndef LOCK_DIR
#ifdef __linux__
-#define LOCK_DIR "/var/lock"
+#define LOCK_DIR "/var/lock/ppp"
#else
#ifdef SVR4
#define LOCK_DIR "/var/spool/locks"

View File

@ -1 +1,2 @@
d /var/run/ppp 0755 root root
d /var/lock/ppp 0755 root root

View File

@ -1,7 +1,7 @@
Summary: The Point-to-Point Protocol daemon
Name: ppp
Version: 2.4.5
Release: 17%{?dist}
Release: 18%{?dist}
License: BSD and LGPLv2+ and GPLv2+ and Public Domain
Group: System Environment/Daemons
URL: http://www.samba.org/ppp
@ -30,6 +30,8 @@ Patch26: ppp-2.4.5-manpg.patch
Patch27: ppp-2.4.5-eaptls-mppe-0.99.patch
Patch28: ppp-2.4.5-ppp_resolv.patch
Patch29: ppp-2.4.5-man.patch
Patch30: ppp-2.4.5-eth.patch
Patch31: ppp-2.4.5-lock.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: pam-devel, libpcap-devel, openssl-devel
@ -75,6 +77,10 @@ This package contains the header files for building plugins for ppp.
%patch27 -p1 -b .eaptls
%patch28 -p1 -b .ppp_resolv
%patch29 -p1 -b .man
# fixes bz#682381 - hardcodes eth0
%patch30 -p1 -b .eth
# fixes bz#708260 - SELinux is preventing access on the file LCK..ttyUSB3
%patch31 -p1 -b .lock
rm -f scripts/*.local
rm -f scripts/*.change_resolv_conf
@ -104,6 +110,7 @@ install -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/pam.d/ppp
# Provide pointers for people who expect stuff in old places
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/log/ppp
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/run/ppp
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/lock/ppp
install -d -m 755 $RPM_BUILD_ROOT%{_sysconfdir}/tmpfiles.d
install -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/tmpfiles.d/ppp.conf
@ -132,6 +139,7 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/pppd
%dir %{_sysconfdir}/ppp
%dir %{_localstatedir}/run/ppp
%dir %{_localstatedir}/lock/ppp
%attr(700, root, root) %dir %{_localstatedir}/log/ppp
%config %{_sysconfdir}/tmpfiles.d/ppp.conf
%config(noreplace) %{_sysconfdir}/ppp/eaptls-client
@ -149,6 +157,10 @@ rm -rf $RPM_BUILD_ROOT
%doc PLUGINS
%changelog
* Mon May 30 2011 Jiri Skala <jskala@redhat.com> - 2.4.5-18
- fixes #682381 - hardcodes eth0
- fixes #708260 - SELinux is preventing access on the file LCK..ttyUSB3
* Mon Apr 04 2011 Jiri Skala <jskala@redhat.com> - 2.4.5-17
- fixes #664282 and #664868 - man page fixes