]> git.ipfire.org Git - thirdparty/dhcpcd.git/log
thirdparty/dhcpcd.git
5 years agoARP: reduce conflicts from errors to warnings
Roy Marples [Wed, 20 May 2020 16:37:21 +0000 (17:37 +0100)] 
ARP: reduce conflicts from errors to warnings

It's only an error on DAD failure and you're warned about this
already.

5 years agoprivsep: inet processes no longer need inet pledge
Roy Marples [Wed, 20 May 2020 16:27:07 +0000 (17:27 +0100)] 
privsep: inet processes no longer need inet pledge

5 years agoOpenBSD: Avoid a pledge segfault when exiting
Roy Marples [Wed, 20 May 2020 16:14:12 +0000 (17:14 +0100)] 
OpenBSD: Avoid a pledge segfault when exiting

No cpath permission anymore, so we can't unlink the pidfile.
If compiled for pledge then don't bother.

5 years agoprivsep: Ensure we don't scribble garbage to BPF
Roy Marples [Wed, 20 May 2020 15:44:19 +0000 (15:44 +0000)] 
privsep: Ensure we don't scribble garbage to BPF

Well, it's not garbage, it's a privsep IPC message telling us to
start BPF which the BPF process should not have recieved!
Add code to ensure this cannot happen.

5 years agoARP: A few minor fixes for prior
Roy Marples [Wed, 20 May 2020 15:43:44 +0000 (15:43 +0000)] 
ARP: A few minor fixes for prior

5 years agoprivsep: Add comment about BPF returing EPERM on OpenBSD.
Roy Marples [Wed, 20 May 2020 13:15:30 +0000 (14:15 +0100)] 
privsep: Add comment about BPF returing EPERM on OpenBSD.

Looks like an OpenBSD bug.

5 years agoIPv4LL: Fix for non NetBSD
Roy Marples [Wed, 20 May 2020 13:07:36 +0000 (14:07 +0100)] 
IPv4LL: Fix for non NetBSD

5 years agoOpenBSD: Fix non privsep builds.
Roy Marples [Wed, 20 May 2020 11:23:25 +0000 (12:23 +0100)] 
OpenBSD: Fix non privsep builds.

5 years agoIPv4LL: Fix for prior on NetBSD at least.
Roy Marples [Wed, 20 May 2020 11:17:00 +0000 (12:17 +0100)] 
IPv4LL: Fix for prior on NetBSD at least.

5 years agoLinux: workaround a kernel bug when sending DHCPv6 over SOCK_RAW
Roy Marples [Tue, 19 May 2020 16:44:49 +0000 (16:44 +0000)] 
Linux: workaround a kernel bug when sending DHCPv6 over SOCK_RAW

The equivalent works fine for DHCP messages, so hum ho.

5 years agoprivsep: No need for ipv4state
Roy Marples [Tue, 19 May 2020 16:13:06 +0000 (16:13 +0000)] 
privsep: No need for ipv4state

5 years agoFix compile on Linux
Roy Marples [Tue, 19 May 2020 16:09:35 +0000 (16:09 +0000)] 
Fix compile on Linux

5 years agoRemove some debug
Roy Marples [Tue, 19 May 2020 15:43:50 +0000 (16:43 +0100)] 
Remove some debug

5 years agoFix compile for prior on NetBSD
Roy Marples [Tue, 19 May 2020 15:37:10 +0000 (16:37 +0100)] 
Fix compile for prior on NetBSD

5 years agoprivsep: Enable Capsicum for all processes.
Roy Marples [Tue, 19 May 2020 15:19:05 +0000 (16:19 +0100)] 
privsep: Enable Capsicum for all processes.

Except for the priviledged process.
This is quite an in-depth change:
 * ARP is now one process per address
 * BPF flags are now returned via privsep
 * BPF write filters are locked when supported
 * The root process sends to the network

The last step is done by opening RAW sockets and then sending a UDP
header (where applicable) to avoid binding to an address
which is already in use by the reader sockets.

This is slightly wasteful for OS's without sandboxing but does
have the very nice side effect of not needing a source address
to unicast DHCPs replies from which makes the code smaller.

5 years agoLinux: Lock the BPF filter from future changes
Roy Marples [Sat, 16 May 2020 11:28:56 +0000 (12:28 +0100)] 
Linux: Lock the BPF filter from future changes

5 years agoARP: Remove ability to filter specific addresses
Roy Marples [Fri, 15 May 2020 21:29:30 +0000 (22:29 +0100)] 
ARP: Remove ability to filter specific addresses

This is only really needed for long lasting ARP, which is only
used for IPv4 address defence.
Modern NetBSD does not need this and it fails to work with
OpenBSD Pledge. FreeBSD Capsicum is more secure without this
as the BPF fd can then be locked for other changes [1].
That just leaves Linux and Solaris.

If anyone feels dhcpcd is processing to much ARP then please
implement RFC 5227 in the kernel like NetBSD.

[1] Locking the BPF fd is questionable because the inet proxy
using sendmsg can send any packet to any destination.

5 years agoBPF: Set write filters where supported
Roy Marples [Fri, 15 May 2020 19:23:55 +0000 (20:23 +0100)] 
BPF: Set write filters where supported

While here make Capsicum and Pledge more granular so we can
easily Pledge the BPF BOOTP process but not the ARP one.

5 years agodhcpcd: allow sigpipe in scripts.
Roy Marples [Fri, 15 May 2020 14:56:47 +0000 (15:56 +0100)] 
dhcpcd: allow sigpipe in scripts.

5 years agoDHCP: always log inform when not renewing
Roy Marples [Fri, 15 May 2020 14:34:16 +0000 (15:34 +0100)] 
DHCP: always log inform when not renewing

So that we log a new lease on rebind from a renew failure.

5 years agoprivsep: sockaddr len should be socklen_t
Roy Marples [Thu, 14 May 2020 00:15:39 +0000 (01:15 +0100)] 
privsep: sockaddr len should be socklen_t

While ps_root_getifaddrs is only for capsicum, it's highly portable
and thus in the privsep-root rather than privsep-bsd.
As such, store the sockaddr len as socklen_t because that's what
POSIX demands.

It's only a few more bytes and I'd rather make this change now
than it potentially bite me later.

5 years agoRemove debug.
Roy Marples [Wed, 13 May 2020 19:58:58 +0000 (20:58 +0100)] 
Remove debug.

5 years agoprivsep: Add a generic wrapper for getifaddrs(3)
Roy Marples [Wed, 13 May 2020 19:52:24 +0000 (20:52 +0100)] 
privsep: Add a generic wrapper for getifaddrs(3)

Although this is only for Capsicum, the getifaddrs interface is
quite portable although not POSIX.

With this final change, the Master process can now enter Capsicum
Capabilites Mode and this completes the Capsicum integration.

5 years agoprivsep: Move defines around
Roy Marples [Wed, 13 May 2020 19:50:45 +0000 (20:50 +0100)] 
privsep: Move defines around

5 years agoBump date for prior
Roy Marples [Tue, 12 May 2020 21:10:08 +0000 (22:10 +0100)] 
Bump date for prior

5 years agoFix neighbor discovery option parsing (#16)
Andrew Childs [Tue, 12 May 2020 21:08:33 +0000 (06:08 +0900)] 
Fix neighbor discovery option parsing (#16)

* make_option_mask: use `nd_` prefix for nd options

The prefix for neighbor discovery options was partially changed to
`nd6_` in d5700a48edf7006369f766d225e70bbca3d8055c. However
set_option_space continued to use `nd_`. This prevented either
`nd6_prefix_information` or `nd_prefix_information` from being parsed
since the former was in the wrong option space, and the latter did not
have the prefix removed.

* manual: fix nd_ and dhcp6_ option prefixes

5 years agoNote that capsicum does allow gethostname
Roy Marples [Tue, 12 May 2020 18:00:36 +0000 (19:00 +0100)] 
Note that capsicum does allow gethostname

5 years agoFix an uninitialised memory access
Roy Marples [Tue, 12 May 2020 13:59:48 +0000 (13:59 +0000)] 
Fix an uninitialised memory access

5 years agoFix compile on Linux and Solaris
Roy Marples [Tue, 12 May 2020 13:54:19 +0000 (13:54 +0000)] 
Fix compile on Linux and Solaris

5 years agoUpdate comment for capsicum
Roy Marples [Tue, 12 May 2020 10:46:19 +0000 (11:46 +0100)] 
Update comment for capsicum

5 years agoRemove chroot file location reference
Roy Marples [Tue, 12 May 2020 10:35:28 +0000 (11:35 +0100)] 
Remove chroot file location reference

5 years agoprivsep: Just ensure default user has a home directory
Roy Marples [Tue, 12 May 2020 10:32:22 +0000 (11:32 +0100)] 
privsep: Just ensure default user has a home directory

5 years agoRemove unused variable.
Roy Marples [Tue, 12 May 2020 10:29:13 +0000 (11:29 +0100)] 
Remove unused variable.

5 years agoWe nolonger use getline.
Roy Marples [Tue, 12 May 2020 10:24:42 +0000 (11:24 +0100)] 
We nolonger use getline.

5 years agoprivsep: No longer need the chrootdir configure option.
Roy Marples [Tue, 12 May 2020 10:23:03 +0000 (11:23 +0100)] 
privsep: No longer need the chrootdir configure option.

As we work with an empty chroot directory.

5 years agoFix compile warnings with prior.
Roy Marples [Tue, 12 May 2020 09:58:31 +0000 (10:58 +0100)] 
Fix compile warnings with prior.

5 years agoprivsep: Handle all file IO in the Priviledged Actioneer
Roy Marples [Tue, 12 May 2020 09:26:35 +0000 (10:26 +0100)] 
privsep: Handle all file IO in the Priviledged Actioneer

This allows us to move the database directory back into the
root of the filesystem.
While here, harden the files by denying any user read access to them.

As part of this change, init the DUID from any machine data and
cache the default DHCP vendor field before dropping priviledges as we
may lose access to this later.

5 years agoFix warning for prior
Roy Marples [Sun, 10 May 2020 16:32:15 +0000 (17:32 +0100)] 
Fix warning for prior

5 years agoprivsep: Fix prior for non pledge systems
Roy Marples [Sun, 10 May 2020 15:19:09 +0000 (16:19 +0100)] 
privsep: Fix prior for non pledge systems

5 years agoprivsep: Implement pledge(2) support as found on OpenBSD
Roy Marples [Sun, 10 May 2020 15:09:54 +0000 (16:09 +0100)] 
privsep: Implement pledge(2) support as found on OpenBSD

5 years agoprivsep: Add function for indirect ioctl
Roy Marples [Sun, 10 May 2020 11:19:59 +0000 (12:19 +0100)] 
privsep: Add function for indirect ioctl

5 years agoprivsep: Copy back ioctl data
Roy Marples [Sun, 10 May 2020 10:05:23 +0000 (11:05 +0100)] 
privsep: Copy back ioctl data

5 years agoFix compile error for non capsicum
Roy Marples [Sun, 10 May 2020 09:11:46 +0000 (10:11 +0100)] 
Fix compile error for non capsicum

5 years agoMerge branch 'master' of github.com:rsmarples/dhcpcd
Roy Marples [Sun, 10 May 2020 09:07:34 +0000 (10:07 +0100)] 
Merge branch 'master' of github.com:rsmarples/dhcpcd

5 years agoMerge pull request #15 from mpu/controlgroup
Roy Marples [Sat, 9 May 2020 09:46:25 +0000 (10:46 +0100)] 
Merge pull request #15 from mpu/controlgroup

Do not report an error if control_group is already set

5 years agoMerge pull request #14 from mpu/master
Roy Marples [Fri, 8 May 2020 10:37:50 +0000 (11:37 +0100)] 
Merge pull request #14 from mpu/master

fix buffer size in getgrnam_r

5 years agoprivsep: Enable capsicum for network facing processes
Roy Marples [Thu, 7 May 2020 19:57:22 +0000 (20:57 +0100)] 
privsep: Enable capsicum for network facing processes

All fd's in network facing processes are fully limited.
Capability mode is only enabled for BPF processes because
it's too restrictive otherwise - the reasons are noted
in the commit.

5 years agoif: Be more descriptive on error for getifaddrs
Roy Marples [Thu, 7 May 2020 14:02:26 +0000 (15:02 +0100)] 
if: Be more descriptive on error for getifaddrs

5 years agoinet6: Move BSD get/set scope function to ipv6 for general use
Roy Marples [Thu, 7 May 2020 13:29:44 +0000 (14:29 +0100)] 
inet6: Move BSD get/set scope function to ipv6 for general use

It seems that FreeBSD doesn't allow binding to scoped addresses,
so let's use our functions everwhere rather than directly
setting scope.

5 years agoprivsep: Remove unsued function.
Roy Marples [Wed, 6 May 2020 23:08:41 +0000 (00:08 +0100)] 
privsep: Remove unsued function.

5 years agoFix buffer size in getgrnam_r
Quentin Carbonneaux [Tue, 5 May 2020 15:21:04 +0000 (17:21 +0200)] 
Fix buffer size in getgrnam_r

5 years agoDo not report an error if control_group is already set
Quentin Carbonneaux [Tue, 5 May 2020 15:43:04 +0000 (17:43 +0200)] 
Do not report an error if control_group is already set

5 years agoDHCP: Use correct buffer for receiving UDP
Roy Marples [Tue, 5 May 2020 19:03:49 +0000 (19:03 +0000)] 
DHCP: Use correct buffer for receiving UDP

Big wup!
While here, ensure buffer is aligned to the structure we want
to read.

5 years agoprivsep: Allow a blank string to force privsep users home directory
Roy Marples [Tue, 5 May 2020 16:55:10 +0000 (17:55 +0100)] 
privsep: Allow a blank string to force privsep users home directory

So FreeBSD users can set it like other OS's if they so choose.

5 years agoprivsep: Document any overridden chroot directory.
Roy Marples [Tue, 5 May 2020 16:34:54 +0000 (17:34 +0100)] 
privsep: Document any overridden chroot directory.

5 years agoLog chrootdir set.
Roy Marples [Mon, 4 May 2020 15:32:37 +0000 (16:32 +0100)] 
Log chrootdir set.

5 years agodhcpcd: Discard the freopen result.
Roy Marples [Fri, 1 May 2020 10:19:49 +0000 (11:19 +0100)] 
dhcpcd: Discard the freopen result.

5 years agoprivsep: Discard the freopen result.
Roy Marples [Fri, 1 May 2020 10:18:05 +0000 (11:18 +0100)] 
privsep: Discard the freopen result.

5 years agoAlign whitespace
Roy Marples [Thu, 30 Apr 2020 20:30:01 +0000 (21:30 +0100)] 
Align whitespace

5 years agoprivsep: allow --chrootdir= to configure a default chroot directory
Roy Marples [Thu, 30 Apr 2020 20:26:16 +0000 (21:26 +0100)] 
privsep: allow --chrootdir= to configure a default chroot directory

5 years agoprivsep: Add --chroot configurable
Roy Marples [Thu, 30 Apr 2020 20:13:45 +0000 (21:13 +0100)] 
privsep: Add --chroot configurable

Overrides the directory to chroot to away from the privilege separation
users home directory.

5 years agoinet6: Mark temp addrs for regen
Roy Marples [Wed, 29 Apr 2020 21:41:35 +0000 (22:41 +0100)] 
inet6: Mark temp addrs for regen

This solves an infinite loop where new temp addrs regened are
added at the tail and we loop endlessly.

5 years agoinet6: Set default ND timers before a RA arrives after preservation
Roy Marples [Wed, 29 Apr 2020 15:33:57 +0000 (16:33 +0100)] 
inet6: Set default ND timers before a RA arrives after preservation

Other OS will just remove the RA's on carrier down and thus set
default values, but not so on NetBSD.
As such as need to set default values just before settings any values
from the incoming RA.
This allows us to change networks sensibly.

5 years agoinet6: Expire ND on the second, not after it
Roy Marples [Wed, 29 Apr 2020 15:06:04 +0000 (15:06 +0000)] 
inet6: Expire ND on the second, not after it

Otherwise the timing is slightly confused.

5 years agoinet6: Apply the best RA which is still valid.
Roy Marples [Wed, 29 Apr 2020 14:32:15 +0000 (15:32 +0100)] 
inet6: Apply the best RA which is still valid.

If there is no such RA, then apply some defaults.

5 years agoLinux: Only set positive reachable timers
Roy Marples [Wed, 29 Apr 2020 14:31:49 +0000 (15:31 +0100)] 
Linux: Only set positive reachable timers

5 years agoNetBSD: Gear up for kernel RA removal.
Roy Marples [Wed, 29 Apr 2020 13:55:23 +0000 (14:55 +0100)] 
NetBSD: Gear up for kernel RA removal.

linkmtu will vanish from nd_ifinfo along with other things.
Also, there is not need to pre-fetch ifinfo because flags are no
longer updated when setting ifinfo back again.

5 years agoDHCP: Close sockets on carrier down
Roy Marples [Tue, 28 Apr 2020 16:39:48 +0000 (16:39 +0000)] 
DHCP: Close sockets on carrier down

This allows any BPF filter to reset family on carrier up.

5 years agoBump dates for prior.
Roy Marples [Tue, 28 Apr 2020 16:00:29 +0000 (17:00 +0100)] 
Bump dates for prior.

5 years agoGrammar nits
Sascha Wildner [Tue, 28 Apr 2020 15:56:26 +0000 (16:56 +0100)] 
Grammar nits

5 years agoWhitespace
Roy Marples [Tue, 28 Apr 2020 15:37:44 +0000 (16:37 +0100)] 
Whitespace

5 years agoAlign more CMSG foo.
Roy Marples [Sun, 26 Apr 2020 20:05:06 +0000 (21:05 +0100)] 
Align more CMSG foo.

5 years agoDHCP6: Implement DECLINE support for duplicated addresses
Roy Marples [Sun, 26 Apr 2020 16:22:42 +0000 (17:22 +0100)] 
DHCP6: Implement DECLINE support for duplicated addresses

This is the final piece of DHCP6 to implement!
Part of this change drops the use of the IPV6_AF_DUPLICATED flag
and we just use IN6_IFF_DUPLICATED now.

5 years agoThis should really be sa_family_t.
Roy Marples [Fri, 24 Apr 2020 11:23:05 +0000 (12:23 +0100)] 
This should really be sa_family_t.

5 years agodhcpcd: Fix separation of per interface and per family
Roy Marples [Thu, 23 Apr 2020 22:45:38 +0000 (23:45 +0100)] 
dhcpcd: Fix separation of per interface and per family

While here improve privsep proess titles for this.

5 years agoif: support changing hardware address type on Linux
Roy Marples [Thu, 23 Apr 2020 14:15:41 +0000 (14:15 +0000)] 
if: support changing hardware address type on Linux

5 years agoRemove unsed define.
Roy Marples [Thu, 23 Apr 2020 13:40:03 +0000 (13:40 +0000)] 
Remove unsed define.

5 years agoRename ifp->family -> ifp->hwtype so it's less confusing
Roy Marples [Thu, 23 Apr 2020 13:33:48 +0000 (14:33 +0100)] 
Rename ifp->family -> ifp->hwtype so it's less confusing

5 years agoprivsep: Open the IPV6 ND socket when running IPv6
Roy Marples [Wed, 22 Apr 2020 15:57:40 +0000 (16:57 +0100)] 
privsep: Open the IPV6 ND socket when running IPv6

IPv6 RS could be turned off globally

5 years ago01-test: Avoid use of grep and sort which might be in /usr
Roy Marples [Tue, 21 Apr 2020 13:31:39 +0000 (14:31 +0100)] 
01-test: Avoid use of grep and sort which might be in /usr

This is a touch more long winded, but is fully shell and
the output *should* be identical.

5 years agohostname: Ensure it's not clobbered by SLAAC v9.0.2
Mark Davies [Tue, 21 Apr 2020 09:34:09 +0000 (10:34 +0100)] 
hostname: Ensure it's not clobbered by SLAAC

Because it cannot carry a hostname and user could be forcing it.

5 years agoRelease dhcpcd-9.0.2
Roy Marples [Tue, 21 Apr 2020 09:32:00 +0000 (10:32 +0100)] 
Release dhcpcd-9.0.2

5 years agoalign CMSG buffer
Roy Marples [Tue, 21 Apr 2020 08:55:50 +0000 (09:55 +0100)] 
align CMSG buffer

5 years agoDHCP: Avoid mis-aligned BOOTP structure
Roy Marples [Mon, 20 Apr 2020 21:18:41 +0000 (22:18 +0100)] 
DHCP: Avoid mis-aligned BOOTP structure

This was caused by the recent change to pass back the frame header.

5 years agoOpenBSD: set IN6_IFF_AUTOCONF for addresses generated from a RA
Roy Marples [Mon, 20 Apr 2020 14:31:57 +0000 (15:31 +0100)] 
OpenBSD: set IN6_IFF_AUTOCONF for addresses generated from a RA

NetBSD will follow suit once the code in the kernel to handle RA
has been removed.

5 years agoif: ensure interface flags persist when setting a flag
Roy Marples [Mon, 20 Apr 2020 13:11:00 +0000 (14:11 +0100)] 
if: ensure interface flags persist when setting a flag

Otherwise we stupidly drop IFF_MULTICAST on Linux.

5 years agoinet6: Add 'temporary' directive to the slaac option
Roy Marples [Sun, 19 Apr 2020 06:52:47 +0000 (07:52 +0100)] 
inet6: Add 'temporary' directive to the slaac option

This instructs dhcpcd to create a temporary address for each
address generated from a RA.
As such, dhcpcd no longer looks at the kernel option for it
as the functionality is being removed from some or never existed
in the first place.

5 years agoBSD: Dont warn if the kernel does not support flushing routers
Roy Marples [Sun, 19 Apr 2020 04:33:53 +0000 (05:33 +0100)] 
BSD: Dont warn if the kernel does not support flushing routers

As the implemention might be removed one day.

5 years agoDHCP6: don't log when things consitently fail
Roy Marples [Fri, 17 Apr 2020 12:25:33 +0000 (13:25 +0100)] 
DHCP6: don't log when things consitently fail

For example, the RA says obtain more inforamtion via DHCPv6 but
there is no DHCPv6 server to service the request.

5 years agoinet6: Only log RA's when they are from a new server
Roy Marples [Fri, 17 Apr 2020 12:22:54 +0000 (13:22 +0100)] 
inet6: Only log RA's when they are from a new server

We cannot log them normally as there are implementations which
vary the expiry times based on their own times so each message is
different. As such, we only log from new servers or coming back
from expiration.

5 years agoinet6: Don't regen temporary addresses without an IPv6 state
Roy Marples [Thu, 16 Apr 2020 22:28:34 +0000 (23:28 +0100)] 
inet6: Don't regen temporary addresses without an IPv6 state

As this is not possible.

5 years agodhcpcd: daemomize if no valid interfaces found
Roy Marples [Thu, 16 Apr 2020 22:27:47 +0000 (23:27 +0100)] 
dhcpcd: daemomize if no valid interfaces found

But if we're waitig for an ip address we still wait.

5 years agoconfigure: Set a blank default hostname for non Linux
Roy Marples [Thu, 16 Apr 2020 22:26:49 +0000 (23:26 +0100)] 
configure: Set a blank default hostname for non Linux

Wups, I was debugging.

5 years agoprivsep: Don't abort if we fail to init a protocol.
Roy Marples [Thu, 16 Apr 2020 20:00:58 +0000 (21:00 +0100)] 
privsep: Don't abort if we fail to init a protocol.

It's only an error if we cannot init anything.

5 years agoprivsep: Redirect to /dev/null unless test or quiet and not debug
Roy Marples [Wed, 15 Apr 2020 15:50:32 +0000 (16:50 +0100)] 
privsep: Redirect to /dev/null unless test or quiet and not debug

Keeps the rtsol like behaviour the same.

5 years agoDon't open a control socket in test mode.
Roy Marples [Wed, 15 Apr 2020 15:50:11 +0000 (16:50 +0100)] 
Don't open a control socket in test mode.

5 years agoRelease dhcpcd-9.0.1 v9.0.1
Roy Marples [Mon, 13 Apr 2020 15:09:08 +0000 (16:09 +0100)] 
Release dhcpcd-9.0.1

5 years agoinstall: Dont move old files around to new locations
Roy Marples [Sun, 5 Apr 2020 15:50:59 +0000 (16:50 +0100)] 
install: Dont move old files around to new locations

privsep user dir may not exist and this code wont work for
dhcpcd-9 anyway.

5 years agoNote /dev/log issue on linux
Roy Marples [Sun, 5 Apr 2020 15:47:25 +0000 (16:47 +0100)] 
Note /dev/log issue on linux

5 years agoprivsep: Detect a suitable user for dhcpcd, otherwise use dhcpcd
Roy Marples [Sun, 5 Apr 2020 15:44:32 +0000 (16:44 +0100)] 
privsep: Detect a suitable user for dhcpcd, otherwise use dhcpcd

System users generally have _ preceeding their username.
Only use this user if it exists and their home dir is not /var/empty.
Otherwise default to using dhcpcd.