Skip to content

Commit

Permalink
feat: Add default username and password (#130)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kjughx authored Nov 15, 2024
1 parent 2623a42 commit 40446c2
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions bin/samba.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions crates/acap-ssh-utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Commands:

Options:
--host <HOST> Hostname or IP address of the device [env: AXIS_DEVICE_IP=]
-u, --user <USER> The username to use for the ssh connection [env: AXIS_DEVICE_USER=]
-p, --pass <PASS> The password to use for the ssh connection [env: AXIS_DEVICE_PASS=]
-u, --user <USER> The username to use for the ssh connection [env: AXIS_DEVICE_USER=, default="root"]
-p, --pass <PASS> The password to use for the ssh connection [env: AXIS_DEVICE_PASS=, default="pass"]
-h, --help Print help (see more with '--help')
```
4 changes: 2 additions & 2 deletions crates/acap-ssh-utils/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
4 changes: 2 additions & 2 deletions crates/acap-vapix/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ fn from_dbus() -> anyhow::Result<HttpClient> {
}

fn from_env() -> anyhow::Result<HttpClient> {
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");
Expand Down
4 changes: 2 additions & 2 deletions crates/cargo-acap-sdk/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
4 changes: 2 additions & 2 deletions crates/device-manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Commands:

Options:
--host <HOST> Hostname or IP address of the device [env: AXIS_DEVICE_IP=]
-u, --user <USER> The username to use for the ssh connection [env: AXIS_DEVICE_USER=]
-p, --pass <PASS> The password to use for the ssh connection [env: AXIS_DEVICE_PASS=]
-u, --user <USER> The username to use for the ssh connection [env: AXIS_DEVICE_USER=, default="root"]
-p, --pass <PASS> The password to use for the ssh connection [env: AXIS_DEVICE_PASS=, default="pass"]
-h, --help Print help
```

Expand Down
4 changes: 2 additions & 2 deletions crates/device-manager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down

0 comments on commit 40446c2

Please sign in to comment.