[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [OSSTEST PATCH 15/16] mg-schema-test-database: Safety catch in JobDB database open
On Mon, 2015-12-07 at 17:27 +0000, Ian Jackson wrote: > When we open the `osstest' database, see whether this is a parent DB > (main DB) from which a test DB has been spawned by this user. > > If it has, bomb out, unless the user has specified a suitable regexp > matching the DB name in the env var > Â OSSTEST_DB_USEREAL_IGNORETEST > > This means that when a test database is in play, the user who created > it cannot accidentally operate on the real DB. > > The safety catch does not affect Tcl programs, which get the DB config > directly, but in general that just means sg-execute-flight and > sg-run-job which already have a fair amount of safety catch because > they demand flight numbers. > > mg-schema-test-database hits this feature over the head.ÂÂWe assume > that the caller of mg-schema-test-database knows what they are doing; > particularly, that if they create nested test DBs (!), they do not > need the assitance of this feature to stop themselves operating > mg-schema-test-database incorrectly.ÂÂAnyone who creates nested test > DBs will hopefully recognise the potential for confusion! > > Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> > --- > ÂOsstest/JobDB/Executive.pm |ÂÂÂ33 ++++++++++++++++++++++++++++++++- > Âmg-schema-test-databaseÂÂÂÂ|ÂÂÂÂ2 ++ > Â2 files changed, 34 insertions(+), 1 deletion(-) > > diff --git a/Osstest/JobDB/Executive.pm b/Osstest/JobDB/Executive.pm > index 2572f5f..29dbc6f 100644 > --- a/Osstest/JobDB/Executive.pm > +++ b/Osstest/JobDB/Executive.pm > @@ -51,8 +51,39 @@ sub current_flight ($) { #method > ÂÂÂÂÂreturn $ENV{'OSSTEST_FLIGHT'}; > Â} > Â > +sub _check_testdbs ($) { > +ÂÂÂÂmy ($dbh) = @_; > + > +ÂÂÂÂmy $re = $ENV{OSSTEST_DB_USEREAL_IGNORETEST} // ''; > +ÂÂÂÂreturn if $re eq '.*'; # needed by mg-schema-test-database during > setup > + > +ÂÂÂÂ# mg-schema-test-database creates a task > +ÂÂÂÂ#ÂÂÂxdbref/DBNAME with username ${Username}@ Was there intended to be a wildcard or pattern of some sort after the @ in this comment? > +ÂÂÂÂmy $sth = $dbh->prepare(<<END); > +ÂÂÂÂÂÂÂÂSELECT refkey AS dbname, > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂusername, comment > +ÂÂÂÂÂÂÂÂÂÂÂÂFROM tasks > + ÂÂÂÂWHERE type = 'xdbref' > + ÂÂÂÂÂÂAND live > + ÂÂÂÂÂÂAND username LIKE (? || '@%') Nice of them to pick "||" as the string concatenation operator. It's almost like they hate us C programmers... Other than the comment thing above: Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |