mirror of
				https://cgit.krebsco.de/krops/
				synced 2025-11-04 09:09:58 +00:00 
			
		
		
		
	lib: add isLocalTarget
This commit is contained in:
		
							parent
							
								
									9677846bf5
								
							
						
					
					
						commit
						e8505f71ff
					
				@ -34,6 +34,12 @@ let {
 | 
			
		||||
      if lib.length y != 1 then throw "malformed /etc/hostname" else
 | 
			
		||||
      lib.elemAt y 0;
 | 
			
		||||
 | 
			
		||||
    isLocalTarget = let
 | 
			
		||||
      origin = lib.mkTarget "";
 | 
			
		||||
    in target:
 | 
			
		||||
      target.user == origin.user &&
 | 
			
		||||
      lib.elem target.host [origin.host "localhost"];
 | 
			
		||||
 | 
			
		||||
    mkTarget = s: let
 | 
			
		||||
      default = defVal: val: if val != null then val else defVal;
 | 
			
		||||
      parse = lib.match "(([^@]+)@)?(([^:/]+))?(:([^/]+))?(/.*)?" s;
 | 
			
		||||
 | 
			
		||||
@ -1,11 +1,5 @@
 | 
			
		||||
let
 | 
			
		||||
  lib = import ../../lib // {
 | 
			
		||||
    isLocalTarget = let
 | 
			
		||||
      origin = lib.mkTarget "";
 | 
			
		||||
    in target:
 | 
			
		||||
      target.host == origin.host &&
 | 
			
		||||
      target.user == origin.user;
 | 
			
		||||
  };
 | 
			
		||||
  lib = import ../../lib;
 | 
			
		||||
in
 | 
			
		||||
 | 
			
		||||
{ nix, openssh, populate, writeDash, writeJSON }: let
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user