Dne St 24. srpna 2011 16:24:00 Francis Giraldeau napsal(a):
> On Wed, 2011-08-24 at 12:39 +0200, Jiri Suchomel wrote:
> > 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?
>
> The Ciphers directive doesn't split all elements from the list ...
> ...
> Also, ProxyCommand and RemoteForward directives makes the lens fail:
> ...
> With those additions, I think it would be complete.

OK, what about this one?
Now I've added handling for Ciphers, ProxyCommand, RemoteForward, LocalForward 
and MACs. And included your hint for reseting the counter.

Jiri


-- 
Jiri Suchomel

SUSE LINUX, s.r.o.                            e-mail: [email protected]
Lihovarská 1060/12                            tel: +420 284 028 960
190 00 Praha 9, Czech Republic                http://www.suse.cz
(*
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|ProxyCommand|RemoteForward|LocalForward|MACs|Ciphers/

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

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

    let commas_entry (k:string) =
        [ key k . counter k . spc . 
            [ seq k . value_to_comma] . ([ seq k . comma . value_to_comma])* . 
eol ]

    let send_env = array_entry "SendEnv"

    let proxy_command = [ indent . key "ProxyCommand" . spc . value_to_eol . 
eol ]

    let fw_entry (k:string) = [ indent . key k . spc . 
        [ key /[^ \t\n\/]+/ . spc . value_to_eol . eol ]]

    let remote_fw = fw_entry "RemoteForward"
    let local_fw = fw_entry "LocalForward"

    let ciphers = commas_entry "Ciphers"
    let macs    = commas_entry "MACs"

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

    let entry = (comment | empty
        | send_env
        | proxy_command
        | remote_fw
        | local_fw
        | macs
        | ciphers
        | 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")

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
ProxyCommand ssh -q -W %h:%p gateway.example.com
RemoteForward [1.2.3.4]:20023 localhost:22
RemoteForward 2221 lhost1:22
LocalForward 3001 remotehost:3000
Ciphers aes128-ctr,aes192-ctr
MACs hmac-md5,hmac-sha1,[email protected]
"

    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"
            { "1" = "LC_IDENTIFICATION" }
            { "2" = "LC_ALL" } }
        { "ProxyCommand" = "ssh -q -W %h:%p gateway.example.com" }
        { "RemoteForward"
            { "[1.2.3.4]:20023" = "localhost:22" }
        }
        { "RemoteForward"
            { "2221" = "lhost1:22" }
        }
        { "LocalForward"
            { "3001" = "remotehost:3000" }
        }
        { "Ciphers"
            { "1" = "aes128-ctr" }
            { "2" = "aes192-ctr" }
        }
        { "MACs"
            { "1" = "hmac-md5" }
            { "2" = "hmac-sha1" }
            { "3" = "[email protected]" }
        }
    }
_______________________________________________
augeas-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/augeas-devel

Reply via email to