From 40446c29da168afd6210b83d79ae0f2c9c8b8ba0 Mon Sep 17 00:00:00 2001 From: Philip Johansson <43731839+kjughx@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:28:37 +0100 Subject: [PATCH] feat: Add default username and password (#130) The values chosen are the same as was already used in the `Makefile`. If any default values should be set, these are probably the best. But it is possible that some users are better served by having no default values, and if that is the case we should try to make a more thorough analysis of the net benefit of providing these defaults. --- bin/samba.py | 4 ++-- crates/acap-ssh-utils/README.md | 4 ++-- crates/acap-ssh-utils/src/main.rs | 4 ++-- crates/acap-vapix/src/lib.rs | 4 ++-- crates/cargo-acap-sdk/src/main.rs | 4 ++-- crates/device-manager/README.md | 4 ++-- crates/device-manager/src/main.rs | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bin/samba.py b/bin/samba.py index 21c0111..44e0e2a 100755 --- a/bin/samba.py +++ b/bin/samba.py @@ -34,8 +34,8 @@ def main(data: None | str | pathlib.Path = None, tunnel: bool = False) -> None: env["USERID"] = str(os.getuid()) env["GROUPID"] = str(os.getgid()) assert env["AXIS_DEVICE_IP"] - assert env["AXIS_DEVICE_PASS"] - assert env["AXIS_DEVICE_USER"] + env.setdefault("AXIS_DEVICE_PASS", "pass") + env.setdefault("AXIS_DEVICE_USER", "root") cmd = ["docker", "compose"] if tunnel: diff --git a/crates/acap-ssh-utils/README.md b/crates/acap-ssh-utils/README.md index 59da993..ac99f58 100644 --- a/crates/acap-ssh-utils/README.md +++ b/crates/acap-ssh-utils/README.md @@ -12,7 +12,7 @@ Commands: Options: --host Hostname or IP address of the device [env: AXIS_DEVICE_IP=] - -u, --user The username to use for the ssh connection [env: AXIS_DEVICE_USER=] - -p, --pass The password to use for the ssh connection [env: AXIS_DEVICE_PASS=] + -u, --user The username to use for the ssh connection [env: AXIS_DEVICE_USER=, default="root"] + -p, --pass The password to use for the ssh connection [env: AXIS_DEVICE_PASS=, default="pass"] -h, --help Print help (see more with '--help') ``` diff --git a/crates/acap-ssh-utils/src/main.rs b/crates/acap-ssh-utils/src/main.rs index d884f95..b49e8be 100644 --- a/crates/acap-ssh-utils/src/main.rs +++ b/crates/acap-ssh-utils/src/main.rs @@ -46,10 +46,10 @@ struct Netloc { #[arg(long, value_parser = url::Host::parse, env="AXIS_DEVICE_IP")] host: Host, /// The username to use for the ssh connection. - #[clap(short, long, env = "AXIS_DEVICE_USER")] + #[clap(short, long, env = "AXIS_DEVICE_USER", default_value = "root")] user: String, /// The password to use for the ssh connection. - #[clap(short, long, env = "AXIS_DEVICE_PASS")] + #[clap(short, long, env = "AXIS_DEVICE_PASS", default_value = "pass")] pass: String, } diff --git a/crates/acap-vapix/src/lib.rs b/crates/acap-vapix/src/lib.rs index 94f72a4..2187db4 100644 --- a/crates/acap-vapix/src/lib.rs +++ b/crates/acap-vapix/src/lib.rs @@ -67,8 +67,8 @@ fn from_dbus() -> anyhow::Result { } fn from_env() -> anyhow::Result { - let username = env::var("AXIS_DEVICE_USER")?; - let password = env::var("AXIS_DEVICE_PASS")?; + let username = env::var("AXIS_DEVICE_USER").unwrap_or("root".into()); + let password = env::var("AXIS_DEVICE_PASS").unwrap_or("pass".into()); let host = env::var("AXIS_DEVICE_IP")?; let url = Url::parse(&format!("http://{host}"))?; debug!("Creating client using username {username} from env"); diff --git a/crates/cargo-acap-sdk/src/main.rs b/crates/cargo-acap-sdk/src/main.rs index 8f6f641..6c74f56 100644 --- a/crates/cargo-acap-sdk/src/main.rs +++ b/crates/cargo-acap-sdk/src/main.rs @@ -112,13 +112,13 @@ struct DeployOptions { /// Username of SSH- and/or VAPIX-account to authenticate as. /// /// It is up to the user to ensure that these have been created on the device as needed. - #[clap(long, env = "AXIS_DEVICE_USER")] + #[clap(long, env = "AXIS_DEVICE_USER", default_value = "root")] user: String, /// Password of SSH- and/or VAPIX-account to authenticate as. /// /// It is up to the user to ensure that these have been created on the device as needed. // TODO: Consider disallowing passing password as arguments. - #[clap(long, env = "AXIS_DEVICE_PASS")] + #[clap(long, env = "AXIS_DEVICE_PASS", default_value = "pass")] pass: String, } diff --git a/crates/device-manager/README.md b/crates/device-manager/README.md index e64a592..bf0edbd 100644 --- a/crates/device-manager/README.md +++ b/crates/device-manager/README.md @@ -11,8 +11,8 @@ Commands: Options: --host Hostname or IP address of the device [env: AXIS_DEVICE_IP=] - -u, --user The username to use for the ssh connection [env: AXIS_DEVICE_USER=] - -p, --pass The password to use for the ssh connection [env: AXIS_DEVICE_PASS=] + -u, --user The username to use for the ssh connection [env: AXIS_DEVICE_USER=, default="root"] + -p, --pass The password to use for the ssh connection [env: AXIS_DEVICE_PASS=, default="pass"] -h, --help Print help ``` diff --git a/crates/device-manager/src/main.rs b/crates/device-manager/src/main.rs index ed670b6..913b952 100644 --- a/crates/device-manager/src/main.rs +++ b/crates/device-manager/src/main.rs @@ -43,10 +43,10 @@ struct Netloc { #[arg(long, value_parser = url::Host::parse, env = "AXIS_DEVICE_IP")] host: Host, /// The username to use for the ssh connection. - #[clap(short, long, env = "AXIS_DEVICE_USER")] + #[clap(short, long, env = "AXIS_DEVICE_USER", default_value = "root")] user: String, /// The password to use for the ssh connection. - #[clap(short, long, env = "AXIS_DEVICE_PASS")] + #[clap(short, long, env = "AXIS_DEVICE_PASS", default_value = "pass")] pass: String, }