| 
					
				 | 
			
			
				@@ -178,9 +178,10 @@ class RepositoryServer:  # pragma: no cover 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         'inject_exception', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    def __init__(self, restrict_to_paths, append_only, storage_quota): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    def __init__(self, restrict_to_paths, restrict_to_repositories, append_only, storage_quota): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         self.repository = None 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         self.restrict_to_paths = restrict_to_paths 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        self.restrict_to_repositories = restrict_to_repositories 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # This flag is parsed from the serve command line via Archiver.do_serve, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # i.e. it reflects local system policy and generally ranks higher than 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # whatever the client wants, except when initializing a new repository 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -348,17 +349,24 @@ class RepositoryServer:  # pragma: no cover 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         logging.debug('Resolving repository path %r', path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         path = self._resolve_path(path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         logging.debug('Resolved repository path to %r', path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        path_with_sep = os.path.join(path, '')  # make sure there is a trailing slash (os.sep) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if self.restrict_to_paths: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             # if --restrict-to-path P is given, we make sure that we only operate in/below path P. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             # for the prefix check, it is important that the compared pathes both have trailing slashes, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             # so that a path /foobar will NOT be accepted with --restrict-to-path /foo option. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            path_with_sep = os.path.join(path, '')  # make sure there is a trailing slash (os.sep) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             for restrict_to_path in self.restrict_to_paths: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 restrict_to_path_with_sep = os.path.join(os.path.realpath(restrict_to_path), '')  # trailing slash 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if path_with_sep.startswith(restrict_to_path_with_sep): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     break 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 raise PathNotAllowed(path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if self.restrict_to_repositories: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for restrict_to_repository in self.restrict_to_repositories: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                restrict_to_repository_with_sep = os.path.join(os.path.realpath(restrict_to_repository), '') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if restrict_to_repository_with_sep == path_with_sep: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    break 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                raise PathNotAllowed(path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # "borg init" on "borg serve --append-only" (=self.append_only) does not create an append only repo, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # while "borg init --append-only" (=append_only) does, regardless of the --append-only (self.append_only) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # flag for serve. 
			 |