signstar_configure_build/
cli.rs1use clap::{Parser, crate_name};
4use signstar_common::{
5 config::{
6 get_default_config_file_path,
7 get_etc_override_config_file_path,
8 get_run_override_config_file_path,
9 get_usr_local_override_config_file_path,
10 },
11 ssh::{get_ssh_authorized_key_base_dir, get_sshd_config_dropin_dir},
12 system_user::get_home_base_dir_path,
13};
14use strum::VariantNames;
15
16use crate::{ConfigPath, SshForceCommand};
17
18const BIN_NAME: &str = crate_name!();
20const SSH_FORCE_COMMAND_VARIANTS: &[&str] = SshForceCommand::VARIANTS;
22
23#[derive(Debug, Parser)]
25#[command(
26 about = "A command-line interface for Signstar image build configuration",
27 name = BIN_NAME,
28 long_about = format!("A command-line interface for Signstar image build configuration
29
30NOTE: This command must be run as root!
31
32This executable is meant to be used to configure relevant system users of a Signstar system during build.
33
34It creates system users and their integration based on a central configuration file.
35
36By default, one of the following configuration files is used if it exists, in the following order:
37
38- {:?}
39
40- {:?}
41
42- {:?}
43
44If none of the above are found, the default location {:?} is used.
45Alternatively a custom configuration file location can be specified using the \"--config\"/ \"-c\" option.
46
47System users, if they don't exist already, are created with the help of `useradd`.
48The users are created without a passphrase and setup with a home below {:?}.
49However, their home directory is not created automatically.
50The system user accounts are then unlocked with the help of `usermod`.
51For each system user a tmpfiles.d integration is provided below \"/usr/lib/tmpfiles.d\", to allow automatic creation of their home directory.
52
53If the used configuration file associates the system user with SSH public keys, a dedicated \"authorized_keys\" file containing the SSH public keys for the user is created below {:?}.
54Additionally, an \"sshd_config\" drop-in configuration is created below {:?}.
55This \"sshd_config\" drop-in configuration enforces the use of the user's \"authorized_keys\" and the use of a specific command (i.e. one of {SSH_FORCE_COMMAND_VARIANTS:?}) depending on the user's role.",
56 get_usr_local_override_config_file_path(),
57 get_run_override_config_file_path(),
58 get_etc_override_config_file_path(),
59 get_default_config_file_path(),
60 get_home_base_dir_path(),
61 get_ssh_authorized_key_base_dir(),
62 get_sshd_config_dropin_dir(),
63 ),
64 version
65)]
66pub struct Cli {
67 #[arg(
69 env = "SIGNSTAR_CONFIG",
70 global = true,
71 help = "The path to a custom configuration file",
72 long_help = format!("The path to a custom configuration file
73
74If specified, the custom configuration file is used instead of the default configuration file location.
75
76If unspecified, one of the following configuration files is used if it exists, in the following order:
77
78- {:?}
79
80- {:?}
81
82- {:?}
83
84If none of the above are found, the default location {:?} is used.",
85 get_usr_local_override_config_file_path(),
86 get_run_override_config_file_path(),
87 get_etc_override_config_file_path(),
88 get_default_config_file_path(),
89),
90 long,
91 short
92 )]
93 pub config: Option<ConfigPath>,
94}