A process that holds a log open only to read it -- CrowdSec's
acquisition, Promtail, rsyslog imfile, a tail -F -- was named as the
file's writer whenever it had the lower pid. The command now reads each
descriptor's flags from /proc/<pid>/fdinfo in the same round trip, and
only an O_WRONLY or O_RDWR holder is the producer. A file only readers
hold stays listed without one; a file only a reader inside a container
holds is its view of a mount and is left out.
Refs: NetOrk/netork#2092
get_log_sources() reads, in the same command, whether rsyslog runs, its
forwarding rules (legacy @/@@/:omrelp: and RainerScript omfwd/omrelp,
with selector, ruleset and whether they take every message), its imfile
inputs, and whether the journal reaches it (imjournal, or imuxsock with
journald's ForwardToSyslog; failing a setting, the default the
distribution ships commented out). Returned as `forwarding`;
parse_log_forwarding and parse_rsyslog are public (NetOrk/netork#2053).
LogSourcesMixin.get_log_sources() reads, in one sh -c call as root, the
units journald holds entries for, the log files running processes hold
open (/proc/<pid>/fd: *.log, *.log.N, anything under /var/log) with size
and last write from stat -L on the descriptor, and the engine's own file
of each container's output as that container's stream. Each file names
the service or container of its first writer from /proc/<pid>/cgroup; a
file a container writes keeps the container's own path.
journald's store, deleted files and a database's write-ahead log
(LevelDB's 000004.log) are left out. Without root it reads again and says
so (attributed: false); a host whose find cannot list open files (busybox)
raises LogSourcesUnavailable rather than reading as no files.
Refs NetOrk/netork#2049
A person who deletes their key loses the password that went with it in netOrk, but the devices kept it, and sudo with it. remove_local_account_keys(name, keys, clear_password=True) takes the keys, the password and sudo in one call; the account stays open. Each step runs when another failed.
See NetOrk/netork#2033.
A person who replaces a key, deletes one or removes their password had
no way to see that reach the device: add_local_account only ever added
a key and kept the password.
add_local_account takes replaces=[...] (the old keys go, matched by
their base64, the person's own keys stay) and clear_password=True (the
account logs in with a key only and cannot have sudo).
remove_local_account_keys takes keys off an account and leaves it open.
Drivers supply _account_clear_password and may override
_account_drop_keys for a key store of their own.
See NetOrk/netork#2013
systemctl show names a timer's monotonic settings by their properties,
OnUnitActiveUSec=3h; the schedule now reads as the unit file writes it.
Found on a live Ubuntu host.
Refs #86
A platform that writes sshd_config from its own database (OpenMediaVault)
had to opt out of harden_ssh_server altogether. Where that generated file
includes /etc/ssh/sshd_config.d, the drop-in is safe; only the fallback
that rewrites sshd_config itself would be undone on the next apply. With
SSHD_CONFIG_GENERATED set, a sshd_config without the include is left alone
and the result says why.
GNU sed keeps a missing final newline, so the next section's header ran
on into the file's last line and its jobs were lost. The report ends
every such file with a newline of its own.
Refs #86
stat without -L gave the link's own mode, 777, and install replaced the
link with a plain file of that mode: cron ignores a file anyone may write,
so every job in it stopped (/etc/cron.d/vzdump on older PVE links to
/etc/pve/vzdump.cron). The file the link names is written instead.
Refs #86
A BSD install takes -D as a destdir, OpenWrt keeps its time zone in uci
and its package database in opkg, and a platform's generated files are its
own; each is a class attribute a driver sets.
Refs #86
BusyBox crond reads no /etc/cron.d, so an Alpine host without systemd
takes the job in the user's crontab instead of a file it would never run.
Refs #86
What a host runs on its own schedule as one shape: cron lines, run-parts
scripts, anacron, systemd timers, periodic, a platform's own jobs, Windows
tasks. Every job says who owns its definition and what the driver can do
to it; every write names the digest the caller saw and is refused when the
host's definition changed since.
PosixScheduledJobsMixin reads everything in one framed report as root,
switches a cron line behind #napalm-disabled:, a timer by systemctl and a
run-parts script by its execute bit, runs a job now bounded by timeout, and
writes an application's job as a timer where systemd runs, else in
/etc/cron.d or the user's crontab. napalm_device_types.cron parses cron
expressions, gives their next runs and writes them as OnCalendar lines.
get_cron_jobs and CronJobDict go: nothing called them.
Version 4.26.0, so drivers can require it before the release is tagged.
Closes#86
A backup server keeps datastores, one backup group per source with its
snapshots, and the jobs that keep them healthy: garbage collection,
verify, prune, sync and tape. None of that is a pool, a volume or a
replication job, so it is a role of its own instead of being bent into
StorageDriver. A server that manages its own disks lists StorageDriver
second.
The role declares the reads (datastores, groups with their newest
snapshot, a group's snapshots, jobs, remotes) and the actions (garbage
collection, running a job, verifying, protecting and deleting a
snapshot), which start a task and return its id for get_backup_task.
The shapes live in napalm_device_types.backups.
ClusterStorageDict gains an optional backup_server: which server,
datastore and namespace a hypervisor's backup storage writes to, with
the fingerprint it pins. Matching that to a server is the application's.
An application matches an LLDP neighbour by its chassis MAC first, and
napalm-linux and napalm-netgear report it as mac; the projection did
not, so every driver built on it would have reported neighbours by name
only (NAPALM/napalm-openwrt#31). lldp_neighbors now carries mac, lower
case, when the chassis id is a MAC address (LldpNeighborDict).
napalm-linux, napalm-openwrt and napalm-proxmox each parsed lldpd's
neighbours on their own, and the copies grouped lines by interface (two
neighbours on one port merged), cut the interface name at its first dot
and looked for chassis.id.value, a key lldpd never prints. The parse
lives here once now: neighbours are split at their via line, the
interface name runs up to the neighbour's first field, ids are read
under the type lldpd prints them with, and a failed lldpctl raises.
The rows project into NAPALM's two LLDP shapes with lldp_neighbors and
lldp_neighbors_detail, the projection part of #10.
Refs #10
DNF_SECURITY_COMMAND ran `dnf updateinfo list --security`, which downloads
the repositories' metadata first whenever the cached copy has expired. On an
Oracle Linux host on OCI that took longer than netOrk's whole 120 s poll.
It now runs with --cacheonly, as APT_UPGRADABLE_COMMAND reads apt's local
index; refreshing stays `dnf makecache`. Without a cache dnf fails at once,
and the __DNF_RC marker already turns that into "security unknown".
Closes#76
models.py is over the file size limit and may not grow; the unknown
key pushed it past its recorded length. SnmpHealthProfile,
SnmpValueSpec, SnmpMemorySpec and SnmpInterfacesSpec move to
napalm_device_types/snmp_health_profile.py. The package exports them
as before and models re-exports them, so existing imports keep working.
The baseline records the smaller models.py.
get_clusters() may also report the cluster's HA resources, backup jobs, the
newest backup per guest and storage, and each node's quorum votes (all
NotRequired; None means not read). HypervisorDriver declares
get_vm_migration_preflight(), migrate_vm() and set_node_maintenance(); the
preflight shape lives in vm_migration.py.
Part of NetOrk/netork#1820 (stage 7: #759, #760, #761).
Devices ship self-signed certificates, so a driver either fails the CA
check on every one of them or turns verification off and sends the
login to whatever answers on the address. tls_certificates pins the
certificate by its SHA-256 fingerprint instead, shaped like
ssh_host_keys: the caller passes the fingerprint to expect by port
(optional_args["tls_fingerprints"]), the driver refuses any other
certificate before a request carries credentials, and every certificate
seen goes to optional_args["tls_certificate_observer"]. Without a
fingerprint the first certificate is accepted.
CertificateCheck checks the certificate in a handshake of its own, then
pins a requests session to it (urllib3's assert_fingerprint, direct and
through a proxy), so no other host can step in between the check and
the login.
Refs NAPALM/napalm-hpe-aruba-procurve#17
LLDP getters used to install, start and reconfigure lldpd on their own,
on every poll. Getters only read now, so starting the agent needs an
action the application calls. The template installs the agent through
ensure_package, has the driver write the interfaces it runs on, then
enables and restarts it through manage_service. The caller names the
interfaces: an agent on every interface also advertises on a WAN port.
Refs NAPALM/napalm-openwrt#8
SnmpValueSpec gains `unknown`. A driver whose device's agent answers a
value wrongly says so in its SNMP_HEALTH_PROFILE, and the application
reports no value for it instead of the standard reading or a default.
OpenBSD's net-snmp reports the CPU as never idle, so a reading of
ssCpuIdle shows every OpenBSD host at 100 % (NAPALM/napalm-bsd#7).
create_vm_from_cloud_init raised a plain error once the VM existed, so the
caller had no id to remove it by. The new RuntimeError carries vmid and
node, with the failure as its cause; a failure before the VM exists raises
as before.
Refs NAPALM/napalm-proxmox#28
A hypervisor reports every cluster its connection can see: the cluster's
name and quorum, its nodes (offline ones too, the local one marked) with
CPU and memory, and the storages and networks with the nodes that see
each. A standalone host is a cluster of one without a name; a manager
reports each cluster and standalone host it runs. Declared only, so a
capability check stays truthful.
create_vm_from_cloud_init() takes the node to create the VM on; a driver
that can only create on its own node refuses another.
Refs NetOrk/netork#484, NetOrk/netork#1822
On bw-01, netork is the satellite's own user (nologin, in docker).
add_service_account opened it, gave it the passwordless sudo rule and netOrk's
key, and only the login as it failed. An account that is there and cannot log
in (nologin, false) is now refused before anything changes.
add_service_account(uid=) makes a new account with that uid once no other
account has it, through the driver's _account_create_with_uid; an account that
is there keeps its own, as a uid is never changed under files that carry it.
The infrastructure's build standard wants the same uid on every host.
add_service_account(name, public_key) creates or reopens the account through
the login the driver uses today: a key and no password, and a rule of its own
in 85-service-<name> that lets it run everything as root without a password,
checked with visudo and sudo -l. Root is refused; run again with the account
the driver already logs in with, it only adds what is missing.
harden_ssh_server (70), _apply_or_restore (51) and exempt_from_ssh_penalties
(81) had grown past the 50-line limit with #63, and `driver / standard` was
red on main. The reading and planning, the putting back, the session's
address, the reasons to leave the exemption and its write move into methods
of their own. Same behaviour, same tests; harden_ssh_server leaves the
baseline.
apt's https method asks Acquire::https::Proxy and then Acquire::http::Proxy,
for the host and then for all. An 00proxy with the http line alone therefore
sent download.docker.com and every other https source to apt-cacher-ng, which
answers 403 CONNECT denied without a PassThroughPattern, and the whole upgrade
failed.
- The report carries https_proxy, https_per_host and https_settings;
https_proxy_for(report, host) is the proxy apt takes for one https host.
- check_https_source() fetches one https source the way apt does.
- configure_package_proxy gains an https step: one https source through the
new proxy. Where the proxy refuses it, 00proxy also says
Acquire::https::Proxy "DIRECT", later https lines to the same proxy are
commented out, and the source is fetched direct. An HTTP error from the
mirror counts as let through.
- apt_fetch_command takes https URLs; comment_out_command takes a scheme.
OpenSSH 9.8+ penalises a source whose connections do not authenticate --
a scanner's probes -- and then drops every connection from it, the
managing client's included.
- OpenSshServerMixin.exempt_from_ssh_penalties puts the address the host
sees the client at ($SSH_CONNECTION) into PerSourcePenaltyExemptList,
next to the host's own exemptions, in its own drop-in. Only where sshd
has the penalties (an older one refuses the directive) and includes the
drop-in directory; checked with sshd -t, sshd -T and a new session, and
taken back on any failure. The check-and-restore step of
harden_ssh_server is shared for it.
- retry_refused tries a connection again after 1, 3, 7 and 15 s while
sshd closes it before its banner; HostKeyCheck.connect uses it.
_account_key_files says which files hold an account's keys; the default is
~/.ssh/authorized_keys and authorized_keys2. OpenMediaVault adds the file it
deploys under /var/lib/openmediavault/ssh/authorized_keys, so reading an
account back sees every key sshd would take.
OpenMediaVault keeps a user's keys in its own database and deploys them
to /var/lib/openmediavault/ssh/authorized_keys, and creates a home only
when its home directory setting is on. The key store becomes three hooks
with the ~/.ssh default: _account_read_keys, _account_add_key and
_account_remove_keys, each given the account's home.
get_local_accounts(names) reads a person's account back: groups, lock,
sudo, key files. add_local_account() creates or reopens one with the
person's key, optional password hash and optional sudo rule;
lock_local_account() takes the keys and sudo away and refuses every
login, keeping the home.
Every command root runs is one fixed command, so a sudoers allowlist can
name it. The key files are read and written as the person (sudo -n -u),
never as root, since a link in a home the person owns may point anywhere.
The sudo rule is a drop-in of its own, checked with visudo before and
sudo -l after; a rule elsewhere (cloud-init's) is reported, not edited.
The login user's own account and system accounts are refused.
A driver supplies creating, opening, locking, reading the lock and
leaving a group.
A driver that typed `echo '<password>' | sudo -S -p "" <command>` into an
interactive shell left that line, password and all, in the login user's
shell history once per command, and where only the part before the first
`&&` ran as root, files root should own were left to the login user.
get_history_sudo_lines() counts the lines per history file with grep -c,
as the login user, without reading any back. remove_history_sudo_lines()
deletes exactly those lines with sed -i, overwrites the backup with
shred -u, and as root gives the driver's SUDO_ROOT_FILES back to root:root
where each is a regular file, not a link, owned by the login user. It
reports each file's lines before and after. Nothing goes to stdin.
The driver names the marker and the files and supplies run_command.
A VM on a VLAN-aware bridge without a VLAN tag only gets an address when
the switch port behind the bridge carries an untagged network. To find
that port, the caller needs the bridge's physical NICs: their LLDP
neighbours name the switch and the port.
uplinks lists them in groups, one per way out of the bridge: a bond's
slaves together, a single NIC alone. A bond is one link, so a caller can
let one slave's neighbour speak for the others when lldpd sees only one.
Internal, VLAN and virtual ports are no uplinks. A missing key means the
driver cannot tell; an empty list is a bridge without uplink.
NAPALM requires an age on every entry of get_arp_table and
get_ipv6_neighbors_table. Many devices do not report one, and drivers
filled in 0.0, which means "confirmed just now". ARP_AGE_UNKNOWN (-1.0, as
NAPALM's IOS driver reports) is the value for "not reported"; the README
states the contract.
NetOrk/netork#1327
netOrk runs every driver in its own containers on Python 3.12, so 3.10
and 3.11 are no longer supported or tested. requires-python, mypy and
ruff move to 3.12, along with what ruff's pyupgrade rules then rewrite.
HostShutdownMixin.shutdown_host(), on DeviceTypeDriver: a device shuts
itself down cleanly through its own means; declared, so hasattr says
whether a driver can. There is no forced variant.
VmStopRequestMixin.begin_stop_vm(name): ask for a VM's clean shutdown
and return at once, for a caller that waits on a timer and reads
get_vm_status instead of blocking in stop_vm. No role demands it.
For netOrk's graph workflows, which switch a hypervisor off when CI has
nothing for it (NetOrk/netork#1636).
The NAPALM driver standard landed on main (#52, 4.21.1). apt_proxy follows
it: builtin generics, strict mypy, complexity 10 at most (parse_apt_proxy,
same_proxy_url and the comment-out step split into helpers), 100 % covered.
Its TypedDicts live in apt_proxy.py, since models.py is over 1000 lines and
may not grow. Version 4.22.0 with its CHANGELOG section.