| 
					
					
					
				 | 
				@ -1,3 +1,4 @@ | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				use std::borrow::{ Borrow, Cow };
 | 
			
		
		
	
		
			
				 | 
				 | 
				use std::error::Error;
 | 
				 | 
				 | 
				use std::error::Error;
 | 
			
		
		
	
		
			
				 | 
				 | 
				use std::fmt;
 | 
				 | 
				 | 
				use std::fmt;
 | 
			
		
		
	
		
			
				 | 
				 | 
				use std::io::Error as IoError;
 | 
				 | 
				 | 
				use std::io::Error as IoError;
 | 
			
		
		
	
	
		
			
				| 
					
						
							
						
					
					
						
							
						
					
					
				 | 
				@ -35,12 +36,12 @@ impl<E: Error> fmt::Display for SystemdUserSessionError<E> { | 
			
		
		
	
		
			
				 | 
				 | 
				}
 | 
				 | 
				 | 
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				pub struct SystemdUserSession<'a> {
 | 
				 | 
				 | 
				pub struct SystemdUserSession<'a> {
 | 
			
		
		
	
		
			
				 | 
				 | 
				  user_name: &'a str,
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				  user_name: Cow<'a, str>,
 | 
			
		
		
	
		
			
				 | 
				 | 
				  command_runner: &'a CommandRunner
 | 
				 | 
				 | 
				  command_runner: &'a CommandRunner
 | 
			
		
		
	
		
			
				 | 
				 | 
				}
 | 
				 | 
				 | 
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				impl<'a> SystemdUserSession<'a> {
 | 
				 | 
				 | 
				impl<'a> SystemdUserSession<'a> {
 | 
			
		
		
	
		
			
				 | 
				 | 
				  pub fn new(user_name: &'a str, command_runner: &'a CommandRunner) -> Self {
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				  pub fn new(user_name: Cow<'a, str>, command_runner: &'a CommandRunner) -> Self {
 | 
			
		
		
	
		
			
				 | 
				 | 
				    SystemdUserSession {
 | 
				 | 
				 | 
				    SystemdUserSession {
 | 
			
		
		
	
		
			
				 | 
				 | 
				      user_name: user_name,
 | 
				 | 
				 | 
				      user_name: user_name,
 | 
			
		
		
	
		
			
				 | 
				 | 
				      command_runner: command_runner
 | 
				 | 
				 | 
				      command_runner: command_runner
 | 
			
		
		
	
	
		
			
				| 
					
					
					
						
							
						
					
				 | 
				@ -51,13 +52,13 @@ impl<'a> SystemdUserSession<'a> { | 
			
		
		
	
		
			
				 | 
				 | 
				impl<'a> Symbol for SystemdUserSession<'a> {
 | 
				 | 
				 | 
				impl<'a> Symbol for SystemdUserSession<'a> {
 | 
			
		
		
	
		
			
				 | 
				 | 
				  fn target_reached(&self) -> Result<bool, Box<Error>> {
 | 
				 | 
				 | 
				  fn target_reached(&self) -> Result<bool, Box<Error>> {
 | 
			
		
		
	
		
			
				 | 
				 | 
				    let mut path = PathBuf::from("/var/lib/systemd/linger");
 | 
				 | 
				 | 
				    let mut path = PathBuf::from("/var/lib/systemd/linger");
 | 
			
		
		
	
		
			
				 | 
				 | 
				    path.push(self.user_name);
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				    path.push(self.user_name.borrow() as &str);
 | 
			
		
		
	
		
			
				 | 
				 | 
				    Ok(path.exists())
 | 
				 | 
				 | 
				    Ok(path.exists())
 | 
			
		
		
	
		
			
				 | 
				 | 
				    // Could also do `loginctl show-user ${self.user_name} | grep -F 'Linger=yes`
 | 
				 | 
				 | 
				    // Could also do `loginctl show-user ${self.user_name} | grep -F 'Linger=yes`
 | 
			
		
		
	
		
			
				 | 
				 | 
				  }
 | 
				 | 
				 | 
				  }
 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				  fn execute(&self) -> Result<(), Box<Error>> {
 | 
				 | 
				 | 
				  fn execute(&self) -> Result<(), Box<Error>> {
 | 
			
		
		
	
		
			
				 | 
				 | 
				    match self.command_runner.run_with_args("loginctl", &["enable-linger", self.user_name]) {
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				    match self.command_runner.run_with_args("loginctl", &["enable-linger", self.user_name.borrow()]) {
 | 
			
		
		
	
		
			
				 | 
				 | 
				      Ok(output) => { println!("{:?} {:?}", from_utf8(&output.stdout).unwrap(), from_utf8(&output.stderr).unwrap() ); match output.status.code() {
 | 
				 | 
				 | 
				      Ok(output) => { println!("{:?} {:?}", from_utf8(&output.stdout).unwrap(), from_utf8(&output.stderr).unwrap() ); match output.status.code() {
 | 
			
		
		
	
		
			
				 | 
				 | 
				        Some(0) => Ok(()),
 | 
				 | 
				 | 
				        Some(0) => Ok(()),
 | 
			
		
		
	
		
			
				 | 
				 | 
				        _ => Err(Box::new(SystemdUserSessionError::GenericError as SystemdUserSessionError<IoError>))
 | 
				 | 
				 | 
				        _ => Err(Box::new(SystemdUserSessionError::GenericError as SystemdUserSessionError<IoError>))
 | 
			
		
		
	
	
		
			
				| 
					
						
							
						
					
					
					
				 | 
				
  |