Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ control_start1(struct dhcpcd_ctx *ctx, const char *ifname, sa_family_t family)
goto err;

#ifdef PRIVSEP_RIGHTS
if (IN_PRIVSEP(ctx) && ps_rights_limit_fd_fctnl(fd) == -1)
if (IN_PRIVSEP(ctx) && ps_rights_limit_fd_getsockopt(fd) == -1)
goto err;
#endif

Expand Down
5 changes: 3 additions & 2 deletions src/dhcpcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2487,9 +2487,10 @@ main(int argc, char **argv, char **envp)
ctx.options |= DHCPCD_FORKED; /* avoid socket unlink */
if (!(ctx.options & DHCPCD_MANAGER))
ctx.control_fd = control_open(argv[optind], family);
if (!(ctx.options & DHCPCD_MANAGER) && ctx.control_fd == -1)
if (!(ctx.options & DHCPCD_MANAGER) && ctx.control_fd == -1 &&
errno != EACCES)
ctx.control_fd = control_open(argv[optind], AF_UNSPEC);
if (ctx.control_fd == -1)
if (ctx.control_fd == -1 && errno != EACCES)
ctx.control_fd = control_open(NULL, AF_UNSPEC);
if (ctx.control_fd != -1) {
if (!(ctx.options & DHCPCD_DUMPLEASE))
Expand Down
12 changes: 12 additions & 0 deletions src/privsep.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,18 @@ ps_rights_limit_ioctl(int fd)
return 0;
}

int
ps_rights_limit_fd_getsockopt(int fd)
{
cap_rights_t rights;

cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_EVENT, CAP_ACCEPT,
CAP_GETSOCKOPT | CAP_FCNTL);
if (cap_rights_limit(fd, &rights) == -1 && errno != ENOSYS)
return -1;
return 0;
}

int
ps_rights_limit_fd_fctnl(int fd)
{
Expand Down
1 change: 1 addition & 0 deletions src/privsep.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ ssize_t ps_recvpsmsg(struct dhcpcd_ctx *, int, unsigned short,

#ifdef PRIVSEP_RIGHTS
int ps_rights_limit_ioctl(int);
int ps_rights_limit_fd_getsockopt(int);
int ps_rights_limit_fd_fctnl(int);
int ps_rights_limit_fd_rdonly(int);
int ps_rights_limit_fd_sockopt(int);
Expand Down