| 
						
						
						
					 | 
				
				 | 
				
					@ -1,3 +1,4 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use std::borrow::{ Borrow, Cow };
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use std::error::Error;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use std::fmt;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use std::fs;
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -11,12 +12,12 @@ use command_runner::CommandRunner; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					pub struct Owner<'a, D> where D: AsRef<str> + fmt::Display {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  path: D,
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  user_name: &'a str,
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  user_name: Cow<'a, str>,
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  command_runner: &'a CommandRunner
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					}
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					impl<'a, D> Owner<'a, D> where D: AsRef<str> + fmt::Display {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  pub fn new(path: D, user_name: &'a str, command_runner: &'a CommandRunner) -> Self {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  pub fn new(path: D, user_name: Cow<'a, str>, command_runner: &'a CommandRunner) -> Self {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    Owner { path: path, user_name: user_name, command_runner: command_runner }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					}
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -24,12 +25,12 @@ impl<'a, D> Owner<'a, D> where D: AsRef<str> + fmt::Display { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					impl<'a, D> Symbol for Owner<'a, D> where D: AsRef<str> + fmt::Display {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  fn target_reached(&self) -> Result<bool, Box<Error>> {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    let actual_uid = fs::metadata(self.path.as_ref()).unwrap().uid();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    let target_uid = get_user_by_name(self.user_name).unwrap().uid();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    let target_uid = get_user_by_name(self.user_name.borrow()).unwrap().uid();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    Ok(actual_uid == target_uid)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  fn execute(&self) -> Result<(), Box<Error>> {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    try!(self.command_runner.run_with_args("chown", &[self.user_name, self.path.as_ref()]));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    try!(self.command_runner.run_with_args("chown", &[self.user_name.borrow(), self.path.as_ref()]));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    Ok(())
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					}
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |