Some small fixes

This commit is contained in:
Adrian Heine 2020-09-03 11:31:09 +02:00
parent d173198729
commit 42690f1d50
7 changed files with 46 additions and 24 deletions

View file

@ -1,7 +1,12 @@
use crate::command_runner::CommandRunner;
use crate::symbols::Symbol;
use async_trait::async_trait;
use once_cell::sync::Lazy;
use std::error::Error;
use tokio::sync::Semaphore;
pub type Wait = Lazy<Semaphore>;
static WAIT: Wait = Lazy::new(|| Semaphore::new(1));
#[derive(Debug)]
pub struct User<U, C> {
@ -33,6 +38,9 @@ impl<U: AsRef<str>, C: CommandRunner> Symbol for User<U, C> {
}
async fn execute(&self) -> Result<(), Box<dyn Error>> {
// adduser is not reentrant because finding the next uid
// and creating the account is not an atomic operation
let wait = WAIT.acquire().await;
self
.command_runner
.run_successfully(