pub enum Platform {
Debian,
Rhel,
MacOs,
Other,
}Expand description
Where a command is being suggested to run.
Variants§
Debian
Debian, Ubuntu and derivatives: apt, ssh.service, ufw.
Rhel
RHEL, Rocky, Alma, CentOS, Fedora: dnf, sshd.service,
firewalld, and SELinux in the way of a non-standard port.
MacOs
macOS: no systemd, Remote Login instead of a package, and the ssh port is not an ordinary config edit.
Other
Something else Unix-like. Guidance degrades to naming the goal rather than inventing a command.
Implementations§
Source§impl Platform
impl Platform
Sourcepub fn from_os_release(body: &str) -> Self
pub fn from_os_release(body: &str) -> Self
Pure parse of an os-release body: ID or any ID_LIKE token
decides the family. Debian is the fallback on Linux because it
is what the shipped images and cloud hosts are, so an unknown
derivative gets the more likely of two wrong answers.
Sourcepub fn install(&self, packages: &[&str]) -> Option<String>
pub fn install(&self, packages: &[&str]) -> Option<String>
Install one or more packages, named in this family’s spelling.
None where there is no package manager to name.
Sourcepub fn sshd_package(&self) -> Option<&'static str>
pub fn sshd_package(&self) -> Option<&'static str>
The package providing an ssh server.
Sourcepub fn ssh_service(&self) -> Option<&'static str>
pub fn ssh_service(&self) -> Option<&'static str>
The systemd unit serving ssh. macOS has none.
Sourcepub fn enable_sshd(&self) -> Vec<String>
pub fn enable_sshd(&self) -> Vec<String>
Bring the ssh daemon up on boot and now.
On Debian the socket unit must be disabled first, and this is the
step whose absence is most confusing: while ssh.socket owns the
listener, the Port directive in sshd_config is IGNORED, so a
carefully written drop-in appears to do nothing at all.
Sourcepub fn open_port(&self, port: u16) -> Option<String>
pub fn open_port(&self, port: u16) -> Option<String>
Open a TCP port on the host firewall, when this family has one that is on by default.
Sourcepub fn allow_ssh_port(&self, port: u16) -> Option<String>
pub fn allow_ssh_port(&self, port: u16) -> Option<String>
Let sshd bind a non-standard port. Only SELinux systems need this, and without it the daemon fails to start with a permission error that says nothing about SELinux.
Sourcepub fn has_sshd_config_d(&self) -> bool
pub fn has_sshd_config_d(&self) -> bool
Whether a drop-in under /etc/ssh/sshd_config.d/ is read by
default. macOS ships no Include line on older releases, and
its ssh port is owned by launchd rather than the config anyway.
Sourcepub fn rrsync_fix(&self) -> Option<String>
pub fn rrsync_fix(&self) -> Option<String>
How to get a RUNNABLE rrsync here — the forced command door
b puts on its key.
Debian ships it executable in the rsync package
(/usr/bin/rrsync), so installing rsync is the whole answer.
RHEL ships the same script as DOCUMENTATION:
/usr/share/doc/rsync/support/rrsync, mode 0644 and a python3
script, so it is neither on PATH nor executable. Installing rsync
there is necessary and not sufficient, and a door composed with a
bare rrsync fails with the least helpful error sshd has.
Sourcepub fn in_container() -> bool
pub fn in_container() -> bool
Whether this process is inside a container.
It changes what a fix MEANS, not just where it runs: a package
installed into a running container lives in a writable layer that
the next docker compose run --rm throws away, so the durable
answer is the image, and advice that omits that sends the
operator round the same loop tomorrow.
Trait Implementations§
impl Copy for Platform
impl Eq for Platform
impl StructuralPartialEq for Platform
Auto Trait Implementations§
impl Freeze for Platform
impl RefUnwindSafe for Platform
impl Send for Platform
impl Sync for Platform
impl Unpin for Platform
impl UnsafeUnpin for Platform
impl UnwindSafe for Platform
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.