net-dialup/ppp: drop dhcp plugin again

It's unclear if anyone is actually using this. We can restore it if
someone asks for it.

Signed-off-by: Mike Gilbert <floppym@gentoo.org>
This commit is contained in:
Mike Gilbert
2023-04-22 14:45:43 -04:00
parent 0030397c19
commit e91bc0db2a
5 changed files with 4 additions and 366 deletions
@@ -1,36 +0,0 @@
From de05f72948317b40c19b1c113e18713816010dd9 Mon Sep 17 00:00:00 2001
From: Mike Gilbert <floppym@gentoo.org>
Date: Thu, 13 Apr 2023 16:26:56 -0400
Subject: [PATCH] Add dhcp plugin
---
configure.ac | 1 +
pppd/plugins/Makefile.am | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 1180f64..5db4197 100644
--- a/configure.ac
+++ b/configure.ac
@@ -329,6 +329,7 @@ AC_CONFIG_FILES([
pppd/Makefile
pppd/pppd.pc
pppd/plugins/Makefile
+ pppd/plugins/dhcp/Makefile
pppd/plugins/pppoe/Makefile
pppd/plugins/pppoatm/Makefile
pppd/plugins/pppol2tp/Makefile
diff --git a/pppd/plugins/Makefile.am b/pppd/plugins/Makefile.am
index 2826148..9708ab1 100644
--- a/pppd/plugins/Makefile.am
+++ b/pppd/plugins/Makefile.am
@@ -21,5 +21,5 @@ winbind_la_LDFLAGS = $(PLUGIN_LDFLAGS)
winbind_la_SOURCES = winbind.c
if !SUNOS
-SUBDIRS = pppoe pppoatm pppol2tp radius
+SUBDIRS = dhcp pppoe pppoatm pppol2tp radius
endif
--
2.40.0
@@ -1,148 +0,0 @@
From e21d256cded13a625bc28d3fe812141a202be696 Mon Sep 17 00:00:00 2001
From: Mike Gilbert <floppym@gentoo.org>
Date: Thu, 13 Apr 2023 14:59:35 -0400
Subject: [PATCH 1/3] Convert sys_errlist to strerror
---
dhcpc.c | 8 ++++----
packet.c | 6 +++---
socket.c | 14 +++++++-------
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/dhcpc.c b/dhcpc.c
index fcff8b9..ff83b53 100644
--- a/dhcpc.c
+++ b/dhcpc.c
@@ -144,7 +144,7 @@ void change_mode(int new_mode)
fd = raw_socket(client_config.ifindex);
if (listen_mode != LISTEN_NONE && fd < 0) {
- fatal("DHCPC: couldn't listen on socket, %s", sys_errlist[errno]);
+ fatal("DHCPC: couldn't listen on socket, %s", strerror(errno));
}
}
@@ -208,7 +208,7 @@ void dhcp_rx(void *dummy) {
len = get_packet(&packet, fd);
if (len == -1 && errno != EINTR) {
- dbglog("DHCPC: error on read, %s, reopening socket", sys_errlist[errno]);
+ dbglog("DHCPC: error on read, %s, reopening socket", strerror(errno));
change_mode(LISTEN_KERNEL);
}
if (len < 0) continue;
@@ -380,7 +380,7 @@ void dhcp_request_new() {
else len = get_raw_packet(&packet, fd);
if (len == -1 && errno != EINTR) {
- dbglog("DHCPC: error on read, %s, reopening socket", sys_errlist[errno]);
+ dbglog("DHCPC: error on read, %s, reopening socket", strerror(errno));
change_mode(listen_mode); /* just close and reopen */
}
if (len < 0) continue;
@@ -445,7 +445,7 @@ void dhcp_request_new() {
} else {
/* An error occured */
- dbglog("DHCPC: error on select, %s, reopening socket", sys_errlist[errno]);
+ dbglog("DHCPC: error on select, %s, reopening socket", strerror(errno));
change_mode(listen_mode); /* just close and reopen */
}
diff --git a/packet.c b/packet.c
index 00b5202..07a1aac 100644
--- a/packet.c
+++ b/packet.c
@@ -125,7 +125,7 @@ int raw_packet(struct dhcpMessage *payload, u_int32_t source_ip, int source_port
return kernel_packet(payload,payload->giaddr,CLIENT_PORT,dest_ip,dest_port);
if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) {
- DEBUG(LOG_ERR, "socket call failed: %s", sys_errlist[errno]);
+ DEBUG(LOG_ERR, "socket call failed: %s", strerror(errno));
return -1;
}
@@ -138,7 +138,7 @@ int raw_packet(struct dhcpMessage *payload, u_int32_t source_ip, int source_port
dest.sll_halen = 6;
memcpy(dest.sll_addr, dest_arp, 6);
if (bind(fd, (struct sockaddr *)&dest, sizeof(struct sockaddr_ll)) < 0) {
- DEBUG(LOG_ERR, "bind call failed: %s", sys_errlist[errno]);
+ DEBUG(LOG_ERR, "bind call failed: %s", strerror(errno));
close(fd);
return -1;
}
@@ -161,7 +161,7 @@ int raw_packet(struct dhcpMessage *payload, u_int32_t source_ip, int source_port
result = sendto(fd, &packet, sizeof(struct udp_dhcp_packet), 0, (struct sockaddr *) &dest, sizeof(dest));
if (result <= 0) {
- DEBUG(LOG_ERR, "write on socket failed: %s", sys_errlist[errno]);
+ DEBUG(LOG_ERR, "write on socket failed: %s", strerror(errno));
}
close(fd);
return result;
diff --git a/socket.c b/socket.c
index 0234350..a6799d5 100644
--- a/socket.c
+++ b/socket.c
@@ -60,7 +60,7 @@ int read_interface(char *interface, int *ifindex, u_int32_t *addr, unsigned char
*addr = sin->sin_addr.s_addr;
DEBUG(LOG_INFO, "%s (our ip) = %s", ifr.ifr_name, inet_ntoa(sin->sin_addr));
} else {
- LOG(LOG_ERR, "SIOCGIFADDR failed!: %s", sys_errlist[errno]);
+ LOG(LOG_ERR, "SIOCGIFADDR failed!: %s", strerror(errno));
return -1;
}
}
@@ -69,7 +69,7 @@ int read_interface(char *interface, int *ifindex, u_int32_t *addr, unsigned char
DEBUG(LOG_INFO, "adapter index %d", ifr.ifr_ifindex);
*ifindex = ifr.ifr_ifindex;
} else {
- LOG(LOG_ERR, "SIOCGIFINDEX failed!: %s", sys_errlist[errno]);
+ LOG(LOG_ERR, "SIOCGIFINDEX failed!: %s", strerror(errno));
return -1;
}
if (ioctl(fd, SIOCGIFHWADDR, &ifr) == 0) {
@@ -77,11 +77,11 @@ int read_interface(char *interface, int *ifindex, u_int32_t *addr, unsigned char
DEBUG(LOG_INFO, "adapter hardware address %02x:%02x:%02x:%02x:%02x:%02x",
arp[0], arp[1], arp[2], arp[3], arp[4], arp[5]);
} else {
- LOG(LOG_ERR, "SIOCGIFHWADDR failed!: %s", sys_errlist[errno]);
+ LOG(LOG_ERR, "SIOCGIFHWADDR failed!: %s", strerror(errno));
return -1;
}
} else {
- LOG(LOG_ERR, "socket failed!: %s", sys_errlist[errno]);
+ LOG(LOG_ERR, "socket failed!: %s", strerror(errno));
return -1;
}
close(fd);
@@ -98,7 +98,7 @@ int listen_socket(unsigned int ip, int port, char *inf)
DEBUG(LOG_INFO, "Opening listen socket on 0x%08x:%d %s\n", ip, port, inf ? inf : "*");
if ((fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
- DEBUG(LOG_ERR, "socket call failed: %s", sys_errlist[errno]);
+ DEBUG(LOG_ERR, "socket call failed: %s", strerror(errno));
return -1;
}
@@ -144,7 +144,7 @@ int raw_socket(int ifindex)
DEBUG(LOG_INFO, "Opening raw socket on ifindex %d\n", ifindex);
if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) {
- DEBUG(LOG_ERR, "socket call failed: %s", sys_errlist[errno]);
+ DEBUG(LOG_ERR, "socket call failed: %s", strerror(errno));
return -1;
}
@@ -152,7 +152,7 @@ int raw_socket(int ifindex)
sock.sll_protocol = htons(ETH_P_IP);
sock.sll_ifindex = ifindex;
if (bind(fd, (struct sockaddr *) &sock, sizeof(sock)) < 0) {
- DEBUG(LOG_ERR, "bind call failed: %s", sys_errlist[errno]);
+ DEBUG(LOG_ERR, "bind call failed: %s", strerror(errno));
close(fd);
return -1;
}
--
2.40.0
@@ -1,35 +0,0 @@
From 9fa2696fa7348e647289e08ce299bb27ab97356d Mon Sep 17 00:00:00 2001
From: Mike Gilbert <floppym@gentoo.org>
Date: Thu, 13 Apr 2023 15:20:30 -0400
Subject: [PATCH 2/3] Add Makefile.am
---
Makefile | 1 -
Makefile.am | 6 ++++++
2 files changed, 6 insertions(+), 1 deletion(-)
delete mode 120000 Makefile
create mode 100644 Makefile.am
diff --git a/Makefile b/Makefile
deleted file mode 120000
index 8bad27d..0000000
--- a/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-Makefile.linux
\ No newline at end of file
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..195435a
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,6 @@
+pppd_plugin_LTLIBRARIES = dhcpc.la
+pppd_plugindir = $(PPPD_PLUGIN_DIR)
+
+dhcpc_la_CPPFLAGS = -I${top_srcdir}
+dhcpc_la_LDFLAGS = -module -avoid-version
+dhcpc_la_SOURCES = dhcpc.c clientpacket.c options.c packet.c socket.c
--
2.40.0
@@ -1,126 +0,0 @@
From f3707ff09fb17e6d6b851f6cda66e2bdfa4b9108 Mon Sep 17 00:00:00 2001
From: Mike Gilbert <floppym@gentoo.org>
Date: Thu, 13 Apr 2023 16:09:45 -0400
Subject: [PATCH 3/3] Fix build with ppp-2.5.0
---
debug.h | 1 +
dhcpc.c | 26 +++++++++++++++-----------
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/debug.h b/debug.h
index e01bd0b..674dffb 100644
--- a/debug.h
+++ b/debug.h
@@ -2,6 +2,7 @@
#define _DEBUG_H
#include <stdio.h>
+#include <pppd/pppd.h>
#define DEBUG
#ifdef DEBUG
diff --git a/dhcpc.c b/dhcpc.c
index ff83b53..d383793 100644
--- a/dhcpc.c
+++ b/dhcpc.c
@@ -33,7 +33,6 @@
#include <sys/types.h>
#include <sys/file.h>
#include <unistd.h>
-#include <getopt.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -44,9 +43,12 @@
#include <net/if.h>
#include <errno.h>
-#include "pppd.h"
+#include <pppd/pppd.h>
+#include <pppd/options.h>
+#include <pppd/fsm.h>
+#include <pppd/ipcp.h>
-char pppd_version[] = VERSION;
+char pppd_version[] = PPPD_VERSION;
#include "dhcpd.h"
#include "dhcpc.h"
@@ -237,8 +239,8 @@ void dhcp_rx(void *dummy) {
if (requested_ip != assigned_ip) {
fatal("DHCPC: Terminating because address has changed!");
}
- untimeout(&dhcp_renew,NULL);
- timeout(&dhcp_renew, NULL, lease / 2,0);
+ ppp_untimeout(&dhcp_renew,NULL);
+ ppp_timeout(&dhcp_renew, NULL, lease / 2,0);
return;
} else if (*message == DHCPNAK) {
/* return to init state */
@@ -248,7 +250,7 @@ void dhcp_rx(void *dummy) {
}
}
}
- timeout(&dhcp_rx,NULL,DHCP_RX_POLL_INTERVAL,0);
+ ppp_timeout(&dhcp_rx,NULL,DHCP_RX_POLL_INTERVAL,0);
}
@@ -272,7 +274,7 @@ void dhcp_renew(void *dummy) {
if (dhcp_state == BOUND) {
dhcp_state = RENEWING;
change_mode(LISTEN_KERNEL);
- timeout(&dhcp_rx,NULL,3,0);
+ ppp_timeout(&dhcp_rx,NULL,3,0);
dbglog("DHCPC: Entering renew state");
/* 1/2 of lease used on entry, timeout renew after another 3/8 of lease */
dhcp_renew_timeout = (lease * 0x3) >> 3;
@@ -299,7 +301,7 @@ void dhcp_renew(void *dummy) {
send_renew(xid, dhcp_state==REBINDING ? client_config.siaddr : server_addr, requested_ip);
dhcp_renew_timeout-=dhcp_packet_interval;
- timeout(&dhcp_renew, NULL, dhcp_packet_interval,0);
+ ppp_timeout(&dhcp_renew, NULL, dhcp_packet_interval,0);
}
void dhcp_request_new() {
@@ -312,6 +314,7 @@ void dhcp_request_new() {
int c, len;
struct dhcpMessage packet;
time_t now;
+ const char *peer_authname = ppp_peer_authname(NULL, 0);
if (dhcp_state == BOUND || dhcp_state == RENEWING || dhcp_state == REBINDING)
return;
@@ -426,7 +429,7 @@ void dhcp_request_new() {
dhcp_process_ack(&packet);
assigned_ip = requested_ip;
dbglog("DHCPC: Setting renewal timer for %d seconds", lease /2);
- timeout(&dhcp_renew, NULL, lease / 2,0);
+ ppp_timeout(&dhcp_renew, NULL, lease / 2,0);
return;
} else if (*message == DHCPNAK) {
/* return to init state */
@@ -455,6 +458,7 @@ void dhcp_request_new() {
void dhcp_ip_choose(u_int32_t *addrp) {
u_int32_t entryvalue;
+ const char *peer_authname = ppp_peer_authname(NULL, 0);
dbglog("DHCPC: ip_choose_hook entered with peer name %s",peer_authname);
@@ -489,8 +493,8 @@ void plugin_init(void)
/* we save pointer to ip_choose_hook so we can defer to other modules
that may specify an IP, e.g. radius */
ip_choose_hook= dhcp_ip_choose;
- add_options(dhcpc_options);
- add_notifier(&exitnotify, dhcp_release, NULL);
+ ppp_add_options(dhcpc_options);
+ ppp_add_notify(NF_EXIT, dhcp_release, NULL);
info("DHCPC: plugin initialized");
}
--
2.40.0
+4 -21
View File
@@ -2,21 +2,19 @@
# Distributed under the terms of the GNU General Public License v2
EAPI=8
AUTOTOOLS_AUTO_DEPEND=no
inherit autotools linux-info pam
inherit linux-info pam
PATCH_TARBALL_NAME="${PN}-2.4.9-patches-03"
DESCRIPTION="Point-to-Point Protocol (PPP)"
HOMEPAGE="https://ppp.samba.org/"
SRC_URI="https://download.samba.org/pub/ppp/${P}.tar.gz
https://github.com/ppp-project/ppp/blob/${P}/contrib/pppgetpass/pppgetpass.8
dhcp? ( http://www.netservers.net.uk/gpl/ppp-dhcpc.tgz )"
https://github.com/ppp-project/ppp/blob/${P}/contrib/pppgetpass/pppgetpass.8"
LICENSE="BSD GPL-2"
SLOT="0/${PV}"
#KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
IUSE="activefilter atm dhcp gtk pam systemd"
IUSE="activefilter atm gtk pam systemd"
DEPEND="
dev-libs/openssl:0=
@@ -29,24 +27,9 @@ DEPEND="
"
RDEPEND="${DEPEND}
!<net-misc/netifrc-0.7.1-r2"
BDEPEND="virtual/pkgconfig
dhcp? ( ${AUTOTOOLS_DEPEND} )"
BDEPEND="virtual/pkgconfig"
PDEPEND="net-dialup/ppp-scripts"
src_prepare() {
if use dhcp; then
eapply "${FILESDIR}/ppp-2.5.0-add-dhcp-plugin.patch"
cd "${WORKDIR}/dhcp" || die
eapply "${FILESDIR}/ppp-2.5.0-dhcp"
cd "${S}" || die
mv "${WORKDIR}/dhcp" "${S}/pppd/plugins/dhcp" || die
fi
default
if use dhcp; then
eautoreconf
fi
}
src_configure() {
local args=(
--localstatedir="${EPREFIX}"/var