diff --git a/src/builder.rs b/src/builder.rs index abfc965..aa385bc 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -121,7 +121,7 @@ impl ImplementationBuilder> for DefaultBuilder { fn create( resource: &Cert, target: & as Resource>::Artifact, - (csr, root_cert, account_key, challenges_dir, user_name, _): ::Artifact, + (csr, root_cert, account_key, challenges_dir, (user_name, _), _): ::Artifact, ) -> Self::Implementation { CertSymbol::new( resource.0.clone(), @@ -552,13 +552,13 @@ impl ImplementationBuilder> for DefaultBuilder { type Prerequisites = (); fn prerequisites(_resource: &UserForDomain) -> Self::Prerequisites {} - type Implementation = UserSymbol, StdCommandRunner>; + type Implementation = UserSymbol, Rc, StdCommandRunner>; fn create( _resource: &UserForDomain, - (user_name, _home_path): & as Resource>::Artifact, + (user_name, home_path): & as Resource>::Artifact, (): ::Artifact, ) -> Self::Implementation { - UserSymbol::new(user_name.0.clone(), StdCommandRunner) + UserSymbol::new(user_name.0.clone(), home_path.into(), StdCommandRunner) } } @@ -566,13 +566,13 @@ impl ImplementationBuilder for DefaultBuilder { type Prerequisites = (); fn prerequisites(_resource: &User) -> Self::Prerequisites {} - type Implementation = UserSymbol, StdCommandRunner>; + type Implementation = UserSymbol, Rc, StdCommandRunner>; fn create( resource: &User, - (): &::Artifact, + home_path: &::Artifact, (): ::Artifact, ) -> Self::Implementation { - UserSymbol::new(resource.0.clone(), StdCommandRunner) + UserSymbol::new(resource.0.clone(), home_path.into(), StdCommandRunner) } } @@ -594,13 +594,13 @@ impl ImplementationBuilder for DefaultBuilder { type Prerequisites = (); fn prerequisites(_resource: &AcmeUser) -> Self::Prerequisites {} - type Implementation = UserSymbol, StdCommandRunner>; + type Implementation = UserSymbol, Rc, StdCommandRunner>; fn create( _resource: &AcmeUser, - user_name: &::Artifact, + (user_name, home_path): &::Artifact, (): ::Artifact, ) -> Self::Implementation { - UserSymbol::new(user_name.0.clone(), StdCommandRunner) + UserSymbol::new(user_name.0.clone(), home_path.into(), StdCommandRunner) } } @@ -617,7 +617,7 @@ impl ImplementationBuilder for DefaultBuilder { fn create( _resource: &AcmeChallengesDir, target: &::Artifact, - user_name: ::Artifact, + (user_name, _): ::Artifact, ) -> Self::Implementation { ( DirSymbol::new(target.clone_rc()), @@ -658,7 +658,7 @@ impl ImplementationBuilder for DefaultBuilder { fn create( _resource: &AcmeAccountKey, target: &::Artifact, - user_name: ::Artifact, + (user_name, _): ::Artifact, ) -> Self::Implementation { ( KeySymbol::new(StdCommandRunner, target.clone_rc()), diff --git a/src/locator.rs b/src/locator.rs index 2591253..01a6e41 100644 --- a/src/locator.rs +++ b/src/locator.rs @@ -202,8 +202,9 @@ impl ResourceLocator for DefaultLocator

{ impl ResourceLocator for DefaultLocator

{ type Prerequisites = (); fn locate(_resource: &AcmeUser) -> (::Artifact, Self::Prerequisites) { - let acme_user = P::acme_user(); - (UserNameArtifact(acme_user.into()), ()) + let user_name = P::acme_user(); + let home = P::user_home(&user_name); + ((UserNameArtifact(user_name.into()), PathArtifact::from(home)), ()) } } @@ -264,10 +265,11 @@ impl> ResourceLocator> for DefaultLoca } } -impl

ResourceLocator for DefaultLocator

{ +impl ResourceLocator for DefaultLocator

{ type Prerequisites = (); - fn locate(_resource: &User) -> (::Artifact, Self::Prerequisites) { - ((), ()) + fn locate(resource: &User) -> (::Artifact, Self::Prerequisites) { + let home = P::user_home(&resource.0); + ((PathArtifact::from(home)), ()) } } diff --git a/src/resources/mod.rs b/src/resources/mod.rs index 0d06c78..8c56a67 100644 --- a/src/resources/mod.rs +++ b/src/resources/mod.rs @@ -91,7 +91,7 @@ impl Resource for AcmeAccountKey { #[derive(Debug, Hash, PartialEq, Eq)] pub struct AcmeUser; impl Resource for AcmeUser { - type Artifact = UserNameArtifact; + type Artifact = (UserNameArtifact, PathArtifact); } #[derive(Debug, Hash, PartialEq, Eq)] @@ -138,7 +138,7 @@ pub fn get_saved_directory( #[derive(Debug, Hash, PartialEq, Eq)] pub struct User(pub Rc); impl Resource for User { - type Artifact = (); + type Artifact = PathArtifact; } #[derive(Debug, Hash, PartialEq, Eq)] diff --git a/src/symbols/user.rs b/src/symbols/user.rs index db784a7..c32bec3 100644 --- a/src/symbols/user.rs +++ b/src/symbols/user.rs @@ -4,27 +4,30 @@ use async_trait::async_trait; use once_cell::sync::Lazy; use std::error::Error; use tokio::sync::Semaphore; +use std::path::Path; pub type Wait = Lazy; static WAIT: Wait = Lazy::new(|| Semaphore::new(1)); #[derive(Debug)] -pub struct User { +pub struct User { user_name: U, + home_path: H, command_runner: C, } -impl User { - pub const fn new(user_name: U, command_runner: C) -> Self { +impl User { + pub const fn new(user_name: U, home_path: H, command_runner: C) -> Self { Self { user_name, + home_path, command_runner, } } } #[async_trait(?Send)] -impl, C: CommandRunner> Symbol for User { +impl, H: AsRef, C: CommandRunner> Symbol for User { async fn target_reached(&self) -> Result> { let output = self .command_runner @@ -48,6 +51,8 @@ impl, C: CommandRunner> Symbol for User { args![ // "-m", // Necessary for Fedora, not accepted in Debian "--system", + "--home", + self.home_path.as_ref(), self.user_name.as_ref(), ], )