pub struct EnvList(_);
Expand description

A PAM environment list

The PAM environment represents the contents of the regular environment variables of the authenticated user when service is granted and can be used to prepare the environment of child processes run as the authenticated user.

See Context::envlist().

Examples

// Print the PAM environment
for item in &context.envlist() {
    println!("VAR: {}", item);
}

The environment can be passed to std::process::Command by using EnvList::iter_tuples():

use std::process::Command;

// Spawn a process in the PAM environment
let command = Command::new("/usr/bin/some_program")
                      .env_clear()
                      .envs(context.envlist().iter_tuples());

The environment can be passed to NIX’s execve by using EnvList::as_ref():

use nix::unistd::execve;

// Replace this process with another program in the PAM environment
execve(
    &CString::new("/usr/bin/some_program").unwrap(),
    &[CString::new("some_program").unwrap()],
    context.envlist().as_ref()
).expect("replacing the current process failed");

Implementations

Returns a reference to the value of the named environment variable.

Returns None if the variable doesn’t exist in this list.

Returns an iterator over all contained variables as EnvItems.

The iteration happens in deterministic, but unspecified order.

Returns the count of environment variables in the list.

Returns true if the environment list is empty.

Returns an iterator over all contained variables as (key: &OsStr, value: &OsStr) tuples.

The iteration happens in deterministic, but unspecified order.

Provides compatibility with std::process::Command::envs().

Trait Implementations

Provide compatibility with the 3rd parameter of nix::unistd::execve.

Converts this type into a shared reference of the (usually inferred) input type.

Formats the value using the given formatter. Read more

Display and string conversion of the environment list.

Also causes .to_string() to be implemented.

Formats the environment list as a multi-line string

Reference conversion to a referencing hash map

Converts to this type from the input type.

Reference conversion to a vector of “key=value” &CStrs.

Converts to this type from the input type.

Reference conversion to a vector of (&key, &value) tuples.

Converts to this type from the input type.

Conversion to a hash map

Converts to this type from the input type.

Conversion to a vector of (key, value) tuples.

Converts to this type from the input type.

Conversion to a vector of “key=value” CStrings.

Converts to this type from the input type.

Indexing with list[key]

Returns a reference to the value of the named environment variable.

Panics

Panics if the environment variable is not present in the EnvList.

The returned type after indexing.

Provide direct for-loop support.

See EnvList::iter().

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.