Skip to content

Commit

Permalink
Merge pull request #1000 from jlebon/pr/move-away-from-users
Browse files Browse the repository at this point in the history
Move away from deprecated `users` to `uzers`
  • Loading branch information
HuijingHei authored Sep 20, 2023
2 parents 424711e + 2194253 commit fda1e1a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
20 changes: 10 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 @@ -56,7 +56,7 @@ slog-async = ">= 2.5, < 3"
slog-scope = "4.3"
slog-term = ">= 2.6, < 3"
tempfile = ">= 3.2, < 4"
users = "0.11"
uzers = "0.11"
vmw_backdoor = "0.2"
zbus = ">= 2.3, < 4"

Expand Down
5 changes: 3 additions & 2 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ Minor changes:

Packaging changes:

Require Rust ≥ 1.71.0
Specify features depended on from Nix
- Require Rust ≥ 1.71.0
- Specify features depended on from Nix
- Replace deprecated dependency `users` by `uzers`


## Afterburn 5.4.3 (2023-06-05)
Expand Down
8 changes: 4 additions & 4 deletions src/providers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use std::collections::HashMap;
use std::fs::{self, File};
use std::io::prelude::*;
use std::path::Path;
use users::{self, User};
use uzers::{self, User};

/// Message ID markers for authorized-keys entries in journal.
const AFTERBURN_SSH_AUTHORIZED_KEYS_ADDED_MESSAGEID: &str = "0f7d7a502f2d433caa1323440a6b4190";
Expand Down Expand Up @@ -90,10 +90,10 @@ fn write_ssh_key_journal_entry(log: logging::Priority, name: &str, path: &str, a

fn write_ssh_keys(user: User, ssh_keys: Vec<PublicKey>) -> Result<()> {
use std::io::ErrorKind::NotFound;
use users::os::unix::UserExt;
use uzers::os::unix::UserExt;

// switch users
let _guard = users::switch::switch_user_group(user.uid(), user.primary_group_id())
let _guard = uzers::switch::switch_user_group(user.uid(), user.primary_group_id())
.context("failed to switch user/group")?;

// get paths
Expand Down Expand Up @@ -230,7 +230,7 @@ pub trait MetadataProvider {

fn write_ssh_keys(&self, ssh_keys_user: String) -> Result<()> {
let ssh_keys = self.ssh_keys()?;
let user = users::get_user_by_name(&ssh_keys_user)
let user = uzers::get_user_by_name(&ssh_keys_user)
.ok_or_else(|| anyhow!("could not find user with username {:?}", ssh_keys_user))?;

write_ssh_keys(user, ssh_keys)?;
Expand Down

0 comments on commit fda1e1a

Please sign in to comment.