hercules-team / augeas

A configuration editing tool and API
http://augeas.net/
GNU Lesser General Public License v2.1
486 stars 199 forks source link

Lens for /etc/postfix/sasl/smtpd.conf #182

Closed larsen0815 closed 9 years ago

larsen0815 commented 9 years ago

I couldn´t find a lens for "/etc/postfix/sasl/smtpd.conf", so I created it myself. I think this file stems from Parallels Plesk (12.0.18 in use). This is my first try on creating a lens, so don´t expect it to be bugs-free.

It works for the file that I have on my server, but there will probably be more items/keys that are not implemented, yet. Though, this lens will hopefully be useful for others and provide a starting point.

module Postfix_sasl_smtpd =
  autoload xfm

  let eol = Util.eol
  let colon        = del /:[ \t]*/ ": "
  let value_to_eol = store Rx.space_in

  let simple_entry (kw:string) = [ key kw . colon . value_to_eol . eol ]

  let entries = simple_entry "pwcheck_method"
              | simple_entry "auxprop_plugin"
              | simple_entry "saslauthd_path"
              | simple_entry "mech_list"
              | simple_entry "sql_engine"
              | simple_entry "log_level"

  let lns = entries+

  let filter = incl "/etc/postfix/sasl/smtpd.conf"

  let xfm = transform lns filter
lutter commented 9 years ago

Thanks for writing the lens. Could you also add a few tests so we don't break what works right now when the lens gets updated in the future ? Have a look at the files in lenses/tests/ (e.g., test_hosts.aug) for examples of existing tests.

larsen0815 commented 9 years ago

I´m afraid that this is out of my capabilities. I had a hard time understanding the syntax when writing the lens and it was more of a copy-paste-trial-and-error-and-error-and-error-development. And the tests don´t look any less confusing. Sorry.

lutter commented 9 years ago

Ok, fair enough; could you paste the sasl/smtpd.conf file that you used as a model into this issue then ? I'll try and take a stab at writing tests.

larsen0815 commented 9 years ago

Sure:

# cat /etc/postfix/sasl/smtpd.conf
pwcheck_method: auxprop saslauthd
auxprop_plugin: plesk
saslauthd_path: /private/plesk_saslauthd
mech_list: CRAM-MD5 PLAIN LOGIN
sql_engine: intentionally disabled
log_level: 4

In the meantime, this entry was added to the lens:

simple_entry "auto_transition"
lutter commented 9 years ago

Thanks for that ! I just committed the lens and a test as c1b7784e

Please let me know if there's any problems with it.