get_scheduled_jobs reads /etc/crontab and the user crontabs in
/var/cron/tabs, on FreeBSD also both cron.d directories and every
periodic script, in one round trip as root; manage_scheduled_job
enables, disables or runs one now; put_ and delete_scheduled_job write
and remove an application's own job (/etc/cron.d on FreeBSD, marked
lines in the user's crontab on OpenBSD).
A periodic script is what FreeBSD runs daily, weekly, monthly and for
the security run; it does its work only when its periodic.conf knob
says YES, so that knob is its enabled state, written with sysrc to
/etc/periodic.conf. A later periodic.conf that still overrides it is
reported instead of claimed as done. A script whose knob is not known
only runs; one whose knob is off does nothing when run and offers no run.
BSD su takes no shell (FreeBSD's -s is a MAC label) and -m starts
root's own shell, csh on many FreeBSD hosts, so another user's job goes
to /bin/sh on stdin. OpenBSD cron's -n/-q/-s flags are left off when a
line runs now. What the base system ships is platform: FreeBSD's
/etc/crontab and /etc/periodic, OpenBSD's newsyslog and
/etc/daily|weekly|monthly lines, which stay one job each.
get_cron_jobs goes: it read without root and missed cron.d, every other
user and periodic.
Requires napalm-device-types 4.26.0.
Closes#27
get_arp_table reported the time until the entry expires (FreeBSD's
"expires in N seconds", OpenBSD's Expire column): an entry refreshed a
second ago looked 20 minutes old. It now reports ARP_AGE_UNKNOWN (-1.0).
NetOrk/netork#1327
The write side NetOrk/netork#799 needs, on both drivers.
- Packages: get_packages (FreeBSD `pkg query` with the repository as
source, nothing on a classic system without pkg; OpenBSD `pkg_info`),
install_package / uninstall_package as root (`pkg install`/`pkg
delete`, `pkg_add -I`/`pkg_delete`), names checked before anything is
sent, a failure raised with what the tool printed.
- Updates: get_available_updates. FreeBSD `pkg upgrade -n`, with
`security` from VuXML (`pkg audit`: True for a listed package, False for
any other, None when the audit could not run); OpenBSD `pkg_add -u -n
-v` (no security verdict). Base-system patches are one `base-system`
entry, as decided in #799: OpenBSD's `syspatch -c`, and on a classic
FreeBSD what `freebsd-update` has fetched; on pkgbase the base system is
packages from FreeBSD-base.
- Services: get_services lists the enabled ones (FreeBSD `service ...
status` as root, as root-only pidfiles hide daemons otherwise, without
root when sudo refuses; OpenBSD `rcctl check`), manage_service runs
start/stop/restart/enable/disable as root and returns success and
output.
Fixtures recorded on the FreeBSD 15.1 and OpenBSD 7.9 VMs with genuinely
outdated packages (FreeBSD pointed at the latest branch, an OpenBSD
package taken back to its release build). Checked live on both, including
a service restart and installing and removing a package.
get_listening_sockets() in the shape of napalm-device-types'
ListeningSocketsMixin, whose ss/cgroup reading is Linux's, and with its
rule: read as root first, and without root when that brings nothing back,
which the reading reports as `attributed: False`.
- FreeBSD: `sockstat -46lq -P tcp,udp`, which sees every socket either way.
- OpenBSD: `fstat -n` as root (the sockets nothing is connected to; port 0
is unbound), `netstat -an` without root, as fstat shows a user only
their own processes; those sockets come without a process.
- Addresses as ss prints them: `*` becomes 0.0.0.0 or :: by family, IPv6
without brackets, a zone (`fe80::1%lo0`) becomes the interface. One entry
per socket, the first process holding it.
No get_kernel_facts on purpose: KernelFactsMixin reports a Linux kernel's
modules and CONFIG_ options, which a BSD kernel does not have.
Fixtures recorded on the FreeBSD 15.1 and OpenBSD 7.9 VMs with test
listeners on 127.0.0.1 and ::1 (NetOrk/netork#798).
FreeBSDDriver (`freebsd`) and OpenBSDDriver (`openbsd`) on a shared
BsdDriver, for the BSD VMs netOrk provisions and BSD hosts added by hand
(NetOrk/netork#798).
- SSH over exec channels (napalm-device-types' run_on_transport): no PTY,
stdout and stderr apart, real exit codes; run_command()/open_stream()
are public. Root through `sudo -S` with the password on stdin, or
`sudo -n` without one.
- Facts: hostname, release and running kernel (freebsd-version / uname),
hardware from SMBIOS (kenv) or hw.* sysctls, uptime from kern.boottime.
- Interfaces and addresses (ifconfig -a: ether/lladdr, hex netmasks,
scoped IPv6), routes (netstat -rn, OpenBSD's abbreviated networks
written out, host/broadcast/loopback entries left out), ARP (FreeBSD's
sentences, OpenBSD's table), users and groups, processes (lstart read as
one five-word field), cron jobs (system crontab and the login user's).
- Parsers are pure functions, tested on output recorded from FreeBSD 15.1
(hand-installed and cloud image) and OpenBSD 7.9 (NetOrk/netork#793),
with internal addresses replaced by documentation ranges.