Import dhcpcd-10.0.6 with the following changes:

* privsep: Stop proxying stderr to console and fix some detachment issues
 * non-privsep: Fix launcher hangup
 * DHCP6: Allow the invalid interface name - to mean don't assign an address from a delegated prefix
 * DHCP6: Load the configuration for the interface being activated from prefix delegation
This commit is contained in:
roy 2023-12-18 15:49:41 +00:00
parent c397c5680e
commit c9f4661bc0
8 changed files with 45 additions and 30 deletions

View File

@ -106,17 +106,18 @@ control_hangup(struct fd_list *fd)
control_free(fd);
}
static void
static int
control_handle_read(struct fd_list *fd)
{
char buffer[1024];
ssize_t bytes;
bytes = read(fd->fd, buffer, sizeof(buffer) - 1);
if (bytes == -1) {
if (bytes == -1)
logerr(__func__);
if (bytes == -1 || bytes == 0) {
control_hangup(fd);
return;
return -1;
}
#ifdef PRIVSEP
@ -128,21 +129,23 @@ control_handle_read(struct fd_list *fd)
fd->flags &= ~FD_SENDLEN;
if (err == -1) {
logerr(__func__);
return;
return 0;
}
if (err == 1 &&
ps_ctl_sendargs(fd, buffer, (size_t)bytes) == -1) {
logerr(__func__);
control_free(fd);
return -1;
}
return;
return 0;
}
#endif
control_recvdata(fd, buffer, (size_t)bytes);
return 0;
}
static void
static int
control_handle_write(struct fd_list *fd)
{
struct iovec iov[2];
@ -169,7 +172,7 @@ control_handle_write(struct fd_list *fd)
logerr("%s: write", __func__);
}
control_hangup(fd);
return;
return -1;
}
TAILQ_REMOVE(&fd->queue, data, next);
@ -182,7 +185,7 @@ control_handle_write(struct fd_list *fd)
#endif
if (TAILQ_FIRST(&fd->queue) != NULL)
return;
return 0;
#ifdef PRIVSEP
if (IN_PRIVSEP_SE(fd->ctx) && !(fd->flags & FD_LISTEN)) {
@ -195,9 +198,9 @@ control_handle_write(struct fd_list *fd)
if (eloop_event_add(fd->ctx->eloop, fd->fd, ELE_READ,
control_handle_data, fd) == -1)
logerr("%s: eloop_event_add", __func__);
return 0;
}
static void
control_handle_data(void *arg, unsigned short events)
{
@ -206,10 +209,14 @@ control_handle_data(void *arg, unsigned short events)
if (!(events & (ELE_READ | ELE_WRITE | ELE_HANGUP)))
logerrx("%s: unexpected event 0x%04x", __func__, events);
if (events & ELE_WRITE && !(events & ELE_HANGUP))
control_handle_write(fd);
if (events & ELE_READ)
control_handle_read(fd);
if (events & ELE_WRITE && !(events & ELE_HANGUP)) {
if (control_handle_write(fd) == -1)
return;
}
if (events & ELE_READ) {
if (control_handle_read(fd) == -1)
return;
}
if (events & ELE_HANGUP)
control_hangup(fd);
}

View File

@ -25,11 +25,11 @@
* SUCH DAMAGE.
*/
#ifndef CONFIG_H
#define CONFIG_H
#ifndef DEFS_H
#define DEFS_H
#define PACKAGE "dhcpcd"
#define VERSION "10.0.4"
#define VERSION "10.0.6"
#ifndef PRIVSEP_USER
# define PRIVSEP_USER "_" PACKAGE

View File

@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd August 31, 2022
.Dd December 10, 2023
.Dt DHCPCD 8
.Os
.Sh NAME
@ -186,13 +186,16 @@ The
.Fl w , Fl Fl waitip
option is enabled in this instance to maintain compatibility with older
versions.
Using a single interface also affects the
Using a single interface,
optionally further limited to an address protocol,
also affects the
.Fl k ,
.Fl N ,
.Fl n
and
.Fl x
options, where the same interface will need to be specified, as a lack of an
options, where the same interface and any address protocol
will need to be specified, as a lack of an
interface will imply Manager mode which this is not.
To force starting in Manager mode with only one interface, the
.Fl M , Fl Fl manager

View File

@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd October 4, 2023
.Dd December 18, 2023
.Dt DHCPCD.CONF 5
.Os
.Sh NAME
@ -359,6 +359,7 @@ Otherwise addresses are only assigned for each
.Ar interface
and
.Ar sla_id .
To avoid delegating to any interface, use - as the invalid interface name.
Each assigned address will have a
.Ar suffix ,
defaulting to 1.
@ -415,6 +416,7 @@ interface eth0
ia_na 1 # request an IPv6 address
ia_pd 2 eth1/0 # request a PD and assign it to eth1
ia_pd 3 eth2/1 eth3/2 # req a PD and assign it to eth2 and eth3
ia_pd 4 - # request a PD but don't assign it
.Ed
.It Ic ipv4only
Only configure IPv4.

View File

@ -116,10 +116,6 @@ struct passwd;
struct dhcpcd_ctx {
char pidfile[sizeof(PIDFILE) + IF_NAMESIZE + 1];
char vendor[256];
bool stdin_valid; /* It's possible stdin, stdout and stderr */
bool stdout_valid; /* could be closed when dhcpcd starts. */
bool stderr_valid;
int stderr_fd; /* FD for logging to stderr */
int fork_fd; /* FD for the fork init signal pipe */
const char *cffile;
unsigned long long options;

View File

@ -285,7 +285,6 @@ struct if_options {
struct auth auth;
};
struct if_options *default_config(struct dhcpcd_ctx *);
struct if_options *read_config(struct dhcpcd_ctx *,
const char *, const char *, const char *);
int add_options(struct dhcpcd_ctx *, const char *,

View File

@ -335,6 +335,10 @@ ipv4ll_start(void *arg)
}
}
if (state->running)
return;
state->running = true;
/* RFC 3927 Section 2.1 states that the random number generator
* SHOULD be seeded with a value derived from persistent information
* such as the IEEE 802 MAC address so that it usually picks
@ -435,11 +439,14 @@ ipv4ll_drop(struct interface *ifp)
return;
state = IPV4LL_STATE(ifp);
if (state && state->addr != NULL) {
if (ifp->options->options & DHCPCD_CONFIGURE)
ipv4_deladdr(state->addr, 1);
state->addr = NULL;
dropped = true;
if (state) {
state->running = false;
if (state->addr != NULL) {
if (ifp->options->options & DHCPCD_CONFIGURE)
ipv4_deladdr(state->addr, 1);
state->addr = NULL;
dropped = true;
}
}
/* Free any other link local addresses that might exist. */

View File

@ -44,6 +44,7 @@ struct ipv4ll_state {
struct in_addr pickedaddr;
struct ipv4_addr *addr;
char randomstate[128];
bool running;
bool seeded;
bool down;
size_t conflicts;