Skip to main content

Platform

Enum Platform 

Source
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

Source

pub fn detect() -> Self

This host’s family, from /etc/os-release on Linux.

Source

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.

Source

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.

Source

pub fn sshd_package(&self) -> Option<&'static str>

The package providing an ssh server.

Source

pub fn ssh_service(&self) -> Option<&'static str>

The systemd unit serving ssh. macOS has none.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn name(&self) -> &'static str

A short human name for reports.

Trait Implementations§

Source§

impl Clone for Platform

Source§

fn clone(&self) -> Platform

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Platform

Source§

impl Debug for Platform

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Platform

Source§

impl PartialEq for Platform

Source§

fn eq(&self, other: &Platform) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Platform

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.