[augeas-devel] lens for /etc/ssh/ssh_config

Jiri Suchomel jsuchome at suse.cz
Wed Aug 24 10:39:07 UTC 2011


Hi!

I've tried to create simple lens for /etc/ssh/ssh_config

Could  you check if it does not contain some obvious errors, and potentially 
add it to your standard set of lenses?

Jiri

-- 
Jiri Suchomel

SUSE LINUX, s.r.o.                            e-mail: jsuchome at suse.cz
Lihovarská 1060/12                            tel: +420 284 028 960
190 00 Praha 9, Czech Republic                http://www.suse.cz
-------------- next part --------------
(*
Module: Ssh
  Parses /etc/ssh/ssh_config

*)

module Ssh =
    autoload xfm

    let eol = del /[ \t]*\n/ "\n"
    let spc = Util.del_ws_spc

    let key_re = /[A-Za-z0-9]+/
               - /SendEnv|Host/

    let comment = Util.comment
    let empty = Util.empty
    let indent = del /[ \t]*/ ""
    let value_to_eol = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
    let value_to_spc = store /[^ \t\n]+/

    let array_entry (k:string) =
	[ key k . [ spc . seq k . value_to_spc]* . eol ]

    let send_env = array_entry "SendEnv"

    let other_entry =
	[ indent . key key_re . spc . value_to_spc . eol ]

    let entry = (comment | empty | send_env | other_entry)

    let host = [ key "Host" . spc . value_to_eol . eol . entry* ]

    let lns = (comment | empty) * . host*

    let xfm = transform lns (incl "/etc/ssh/ssh_config")
-------------- next part --------------
module Test_ssh_config = 

    let conf =
"# start
Host suse.cz
   ForwardAgent yes
SendEnv LC_LANG

Host *
   ForwardAgent no
ForwardX11Trusted yes

#   IdentityFile ~/.ssh/identity
SendEnv LC_IDENTIFICATION LC_ALL
"

    test Ssh.lns get conf =
    { "#comment" = "start" }
    { "Host"	= "suse.cz"
	{ "ForwardAgent"  = "yes" }
	{ "SendEnv"
	    { "1" = "LC_LANG" } }
	{ }
    }
    { "Host"	= "*"
	{ "ForwardAgent"  = "no" }
	{ "ForwardX11Trusted"  = "yes" }
	{ }
	{ "#comment" = "IdentityFile ~/.ssh/identity" }
	{ "SendEnv"
	    { "2" = "LC_IDENTIFICATION" }
	    { "3" = "LC_ALL" } }
    }


More information about the augeas-devel mailing list