[Freeipa-devel] [PATCH] 256 allow uid/gid starting number to be set
Martin Nagy
mnagy at redhat.com
Wed Aug 26 06:34:02 UTC 2009
On Tue, 2009-08-25 at 16:39 -0400, Rob Crittenden wrote:
> This adds 2 new options to the installer so the user can select the
> numeric starting point for uidnumbers and gidnumbers.
>
> This also adds a new option to the template system, eval(). You can have
> the python interpreter evaluate a statement and include the result in
> the template output.
>
> rob
So, first I see this:
> -uidNumber: 999
> -gidNumber: 1001
> +uidNumber: $UIDSTART
> +gidNumber: $GIDSTART
And then later I see this:
> -dnaNextValue: 1100
> +dnaNextValue: eval($UIDSTART+1)
[snip]
> -dnaNextValue: 1100
> +dnaNextValue: eval($GIDSTART+3)
This seems to be inconsistent, is this intentional? More inconsistencies
I can see are in the command line option parser where you use 1100 as
default for both UIDSTART and GIDSTART. In the man page you state the
default is 1000 for both.
For the evaluation code, I feel it is a tad more complex than it has to
be. Also, the pattern seems to be too greedy. I'd suggest that you use
the sub() function instead, here's an example:
>>> str = "Something, something, something, eval(foo). Something,
something, something, eval(bar)."
>>> foo = "dark side"
>>> bar = "complete"
>>> pattern = re.compile('(eval\s*\(([^)]*)\))')
>>> pattern.sub(lambda x: eval(x.group(2)), str)
'Something, something, something, dark side. Something, something,
something, complete.'
This also allows eval() to work more times on one line (also notice the
[^)]* which makes sure we don't accept something like "eval(foo) bar)".
I'm also of the opinion that we do abort the installation if the eval()
fails, because that would be a clear bug. If we keep it quiet we might
see a more cryptic error instead.
Martin
More information about the Freeipa-devel
mailing list