Skip to content

Commit

Permalink
Cargo: replace users with uzers
Browse files Browse the repository at this point in the history
Crate `users` is unmaintained, so it is not possible to resolve
a security issue of the crate.
https://github.com/flatcar/update-ssh-keys/security/dependabot/4.

So it is necessary to use instead an actively maintained fork, `uzers`.
  • Loading branch information
dongsupark committed Oct 24, 2023
1 parent 1742e00 commit a76ad7a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
27 changes: 17 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ fs2 = "0.4"
# Public dependencies, exposed through library API.
error-chain = { version = "0.12", default-features = false }
openssh-keys = { git = "https://github.com/pothos/openssh-keys", branch = "add-sk-keys" }
users = "0.9"
clap = { version = "4.4.6", features = ["cargo"] }
uzers = "0.11.3"

[[bin]]
name = "update-ssh-keys"
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
extern crate error_chain;
extern crate fs2;
extern crate openssh_keys;
extern crate users;
extern crate uzers;

pub mod errors {
error_chain! {
Expand Down Expand Up @@ -64,8 +64,8 @@ use std::collections::HashMap;
use std::fs::{self, File};
use std::io::{BufRead, BufReader, Read, Write};
use std::path::{Path, PathBuf};
use users::os::unix::UserExt;
use users::{switch, User};
use uzers::os::unix::UserExt;
use uzers::{switch, User};

const SSH_DIR: &str = ".ssh";
const AUTHORIZED_KEYS_DIR: &str = "authorized_keys.d";
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern crate clap;
#[macro_use]
extern crate error_chain;
extern crate openssh_keys;
extern crate users;
extern crate uzers;

extern crate update_ssh_keys;

Expand All @@ -29,7 +29,7 @@ use std::fs::File;
use std::path::PathBuf;
use update_ssh_keys::errors::*;
use update_ssh_keys::*;
use users::get_current_username;
use uzers::get_current_username;

#[derive(Clone, Debug)]
struct Config {
Expand Down Expand Up @@ -62,7 +62,7 @@ quick_main!(run);
fn run() -> Result<()> {
let config = config().chain_err(|| "command line configuration")?;

let user = users::get_user_by_name(&config.user)
let user = uzers::get_user_by_name(&config.user)
.ok_or_else(|| format!("failed to find user with name '{}'", config.user))?;

let mut aks = AuthorizedKeys::open(user, true, config.ssh_dir.clone()).chain_err(|| {
Expand Down

0 comments on commit a76ad7a

Please sign in to comment.