08/13/08

Permalink 12:01:06 pm, Categories: Programming, Configuration management, Augeas, 105 words  

Parsing inifiles the easy way

Raphael has been doing a lot of work to make processing of INI-style files in Augeas easy and painless. It's now at the point that you can describe /etc/php.ini in a few lines:

module PHP =
  autoload xfm

let entry  = IniFile.entry /[a-z][a-z0-9\._-]+/
let record = IniFile.record "section" entry
let lns    = IniFile.lns record

let filter = (incl "/etc/php*/*/php.ini")
             . Util.stdexcl

let xfm = transform lns filter

That's all you need to have Augeas suck PHP ini files into its tree — turning on safe mode requires exactly two commands in augtool:

  set /files/etc/php.ini/PHP/safe_mode On
  save

07/09/08

Permalink 04:40:08 pm, Categories: Programming, 39 words  

Augeas has Perl bindings

Thanks to the tireless efforts of Dominique Dumont, Augeas now has Perl bindings in addition to the existing Python, Ruby, and OCaml bindings. And the corresponding perl-Config-Augeas package should be coming to a Fedora mirror near you very soon.

Permalink

06/12/08

Permalink 01:03:53 pm, Categories: Configuration management, Augeas, 122 words  

Augeas on linux.com

linux.com has a very nice article on Augeas. It's a very nice overview and introduction.

As embarrassed as I am by the bug the author ran into (blank lines in /etc/hosts threw Augeas' parser off), I am glad to say that it's fixed in the most recent version 0.2.0. The bug and its fix underscores a bigger point though: by basing your config-mangling script on Augeas, rather than parsing files yourself, you will benefit from others finding and fixing bugs in Augeas' parsing logic.

Some of the comments on the article are a little confused about Augeas' purpose: it's not meant for the situations where you'd be perfectly happy to use vi, it's main purpose is to ease scripting configuration changes.

Permalink

05/16/08

Permalink 01:31:49 pm, Categories: Programming, Configuration management, Augeas, 216 words  

Augeas 0.1.1

I just released Augeas 0.1.1; without really planning it, it turned out that the last two weeks were mostly spend on fixing bugs (besides the regular expression enhancement I blogged about previously — even though the real reason for doing that was that the typechecker had a serious bug, and subtraction of regular languages is needed to make the fixed typecheck usable)

The reference counting code in the interpreter had some serious leaks. I had known about them for a while, but never tried to track them down systematically, partly because I thought it would be way too hairy. As it turned out, they weren't that hard to track down; the key ingredient in squashing them was writing little test scripts that only exercised a small number of operations, like

  let l = key /a/

and then running Valgrind a lot, and gdb a little. Of course, the real trick is to figure out what little toy scripts to write ...

Besides memory leaks, I also realized, using Valgrind's massif tool, that compiled regular expressions are huge, and I was hanging on to them for way too long.

With all that, Augeas 0.1.1 has no known memory leaks, and uses a reasonable amount of memory. Most of the honor for that goes to Valgrind, which is an amazingly useful tool.

Permalink

05/13/08

Permalink 06:14:30 pm, Categories: Programming, Augeas, 162 words  

Fun with regular languages

For Augeas, I wanted to support subtraction of regular expresions, so that you can say

  let key_re = /[A-Za-z]+/ - /(Allow|Deny)(Groups|Users)/

which would make key_re match all words made up of lower and upper case letters except for AllowGroups, AllowUsers, DenyGroups and DenyUsers --- the reason being, that those four special cases are handled differently from "generic" keys.

Since the - can't be expressed in regular language notation, it needs to be constructed by compiling its two operands into a finite automaton, subtracting the two automata from each other, and then converting the automaton back into a regular expression. All these operations, except for the conversion from automaton to regular expression, were already supported by libfa.

Implementing the conversion was quite a bit of fun, and the implementation follows almost literally the proof [pdf] that every language recognized by a finite automaton is regular. For some reason, these graph algorithms are always fun to implement, especially when they wind up working ;)

Permalink

:: Next Page >>

Search

Syndicate this blog XML

What is RSS?

Misc

powered by
b2evolution