Commit Graph

5458 Commits

Author SHA1 Message Date
Roy Marples
f4c9bb424e privsep: Minor correction to prior logic 2020-10-11 08:47:31 +01:00
Roy Marples
3fb0b5dc43 privsep: We need to ensure stderr is valid before testing if tty 2020-10-10 17:54:03 +01:00
Roy Marples
ef6ee8b83f privsep: Fix stderr redirection again 2020-10-10 15:07:38 +01:00
Roy Marples
9d0603cb46 privsep: allow gettimeofday for SECCOMP
We need it for logging.
2020-10-10 15:06:59 +01:00
Roy Marples
adb065189b BSD doesn't use envp 2020-10-10 14:46:25 +01:00
Roy Marples
05e9264a61 setproctitle compat requires envp, not environ
The two could be different!
envp is NOT C or POSIX standard, but does appear to be a UNIX standard.
2020-10-10 14:44:00 +01:00
Roy Marples
8366c54b42 Just give up with setproctitle on Illumos
Their ps tools go out of their way to only show how it was launched :/
2020-10-10 13:32:23 +03:00
Roy Marples
2e4aeaf7d8 Change copyright on setproctitle.h 2020-10-09 20:38:48 +01:00
Roy Marples
86df6737c2 compat: Use libbsd's setproctitle(3)
Linux PRCTL variant, although more light weight, doesn't work on
some kernels.
This weighs in around 1k more, but always works.
It does play around with environ and args but unlike other
similar variants doesn't appear to stamp on what you actually
use in the program.
2020-10-09 20:21:52 +01:00
Roy Marples
908b028ca6 privsep: Always try and open syslog
Even if we don't print as otherwise we can't in a chroot.
2020-10-09 15:06:57 +01:00
Roy Marples
cf81b6b942 privsep: Ensure command is for BPF first and interface valid second
Otherwise we won't call inet_dispatch on a message meant for it.
2020-10-09 14:45:57 +01:00
Roy Marples
6a5456df22 Linux: fix compile 2020-10-07 16:21:26 +01:00
Roy Marples
f1f3372c47 privsep: Improve rights on launcher fork and stderr fds 2020-10-07 15:31:35 +01:00
Roy Marples
5699c07d53 privsep: Only start network proxy if we need to
Do this before starting it rather than it shutting down.
2020-10-07 15:28:33 +01:00
Roy Marples
d047f2dd0d privsep: Only log chrooting from the launcher process
And the sandbox tech as well.
Rework stop_interface so we can reuse an option for marking
a process as the launcher.
2020-10-07 14:37:35 +01:00
Roy Marples
e2caea6896 if: always log about unsupported interface types in debug 2020-10-07 14:23:23 +01:00
Roy Marples
76b513c6eb dhcpcd: Simplify the link handling even more
Move the IS_LINK_UP macro to if_is_link_up function to reduce
binary size.
Rather than DHCPCD_LINK option controlling the carrier state,
use it in if_is_link_up to determine the outcome.
2020-10-07 14:11:47 +01:00
Roy Marples
f2b2cdfb73 Wireless must be down if unknown. 2020-10-06 07:36:22 +01:00
Roy Marples
053976a565 dhcpcd: Simplify carrier handling more by using IS_LINK_UP macro
Removes the need for the LINK_DOWN_IFFUP state.
While here, remove the check for IFF_RUNNING when LINK_UNKNOWN
because that is OS specific.
2020-10-06 07:10:41 +01:00
Roy Marples
e2b4e65aa0 Release dhcpcd-9.3.0 2020-10-05 16:33:51 +01:00
Roy Marples
a916d82faf privsep: Remove capsicum specific hooks from BPF
We no longer change the filter as it's locked if the OS supports.
2020-10-04 22:04:49 +01:00
Roy Marples
3f8b1832bf Don't log backticks. 2020-10-03 17:17:45 +01:00
Roy Marples
984496259f privsep: We need getsockopt as well as setsockopt on the link socket
So we can report receive buffer size.
Important for route(4) overflow so we can try and set a bigger buffer.
2020-10-03 17:00:56 +01:00
Roy Marples
d13d954be2 privsep: allow CAP_SETSOCKOPT for route(4) fd.
If FreeBSD ever implements RO_MISSFILTER it will need special
rights to work over Capsium.
2020-10-02 15:57:01 +01:00
Roy Marples
c4c15d9a64 privsep: We now need to carry ifa_data for BSD 2020-09-30 17:25:32 +01:00
Roy Marples
3ef993986b BSD: Fix compile for non NetBSD 2020-09-30 16:14:39 +01:00
Roy Marples
6b5a6be3a2 Add a comment to prior incase I do something dumb like removing it
in the future if I forgot why it was there.
2020-09-29 08:00:24 +01:00
SAITOH Masanobu
26123706b5 Fix a typo in a comment 2020-09-29 07:30:27 +01:00
Roy Marples
c35a09f0df privsep: fix crash when interface departs before bpf returns for it 2020-09-28 21:10:21 +01:00
Roy Marples
96702451ae BSD: struct if_data->ifi_link_state is the single source of truth
Vastly improve and simplify link detection on BSD.
dhcpcd either examines the whole system via getifaddrs(3) or
reacts to events via route(4).
In both cases we have struct if_data which has ifi_link_state.

Armed with this knowledge, we no longer need SIOCGIFDATA or
SIOCGIFMEDIA.

To solve the issue of newly attached interfaces having
LINK_STATE_UNKNOWN or some interfaces not even changing it,
we only change the local knowledge of interface flags when
reports them by getifaddrs(3) or route(4) when we change them.
For example, if we set IFF_UP and it succeeds we don't set this
internally until reported by the kernel as above.

This keeps flags and link state in sync with each other.
The hope is that the kernel can set the real link state before
it reports IFF_UP.

As such, we no longer require the poll option or need to enter a
tight loop for old interfaces.
2020-09-28 17:09:38 +01:00
Roy Marples
91df57a59d BSD: Ignore vether(4) devices by default. 2020-09-27 11:28:03 +01:00
Sascha Wildner
61b2e192fd Clean up some warnings. 2020-09-24 20:53:56 +01:00
Roy Marples
cce22f81ee FreeBSD: Anticipate SIOCGIFDATA not working in Capsicum 2020-09-24 03:49:30 +01:00
Roy Marples
ec4013c25f BSD: NetBSD is the odd man out with SIOCGIFDATA
So setup the #defines like so.
On OpenBSD, pledge blocks it and there is no escape.
Luckily we already allow indirect ioctls via privsep so it works fine.
2020-09-24 03:31:43 +01:00
Roy Marples
fbae1f3873 if: Always warn about ignored interfaces. 2020-09-23 13:14:06 +01:00
Roy Marples
af6fa9caa7 BSD: Of course DragonFly does SIOCGIFDATA differently.. 2020-09-23 09:59:47 +01:00
Roy Marples
84bfc372fc Add a warning about prior 2020-09-23 09:31:24 +01:00
Roy Marples
a22b39d2b9 Revert double variable define 2020-09-23 09:27:58 +01:00
Roy Marples
2e3a64fdfe FreeBSD lacks SIOCGIFDATA it seems. 2020-09-23 09:26:16 +01:00
Roy Marples
12b2bece4e BSD: Use SIOCGIFDATA if no media support and no ifa_data
Hopefully this nails link state once and for all on BSD.
2020-09-22 21:53:13 +01:00
Roy Marples
0ede9e5419 BSD: Detect initial link state in ifa_data
Not all interfaces report media state to get the link state.
However, link state is available from getifaddrs(3) ifa_data
for AF_LINK addresses.

Testing shows that link state is also sent correctly via
route(4) messages for the same interface.

This makes pppoe(4) interfaces more reliable on FreeBSD and OpenBSD.
2020-09-22 13:09:03 +01:00
Roy Marples
96bf083104 dhcpcd: log carrier lost once more 2020-09-22 13:08:32 +01:00
Roy Marples
47e72381a2 Try and track link state better, regardless of if we're using
the interface or not.
2020-09-21 22:24:18 +01:00
Roy Marples
42e2923e68 privsep: Don't log sandbox type twice 2020-09-21 17:40:28 +01:00
Roy Marples
c6582a8a11 privsep: Allow __NR_mmap for seccomp
Some malloc implementations might use it rather than brk.
2020-09-21 11:20:46 +01:00
Roy Marples
bda80910be privsep: Don't remove pidfile at exit
The privileged actioneer will remove it.
2020-09-20 21:22:49 +01:00
Roy Marples
f6da2ec859 privsep: Add more platforms for seccomp
Really nutty. Why cannot a system header define a default?
2020-09-20 20:22:40 +01:00
Roy Marples
100a3839b0 privsep: Allow more syscalls for seccomp
dumplease now works over the control socket and stdin.
2020-09-20 19:44:23 +01:00
Roy Marples
92e860ed9e privsep: Send signal from launcher to master over the socket
rather than using kill which is not permitted in capsicum.
This also allows us to drop the proc pledge.
2020-09-20 19:24:26 +01:00
Roy Marples
8b204c6183 privsep: sandbox the launcher process 2020-09-20 19:09:08 +01:00