[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: RFC: script to run sqlalchemy migrations on the db



2008/8/9 Toshio Kuratomi <a badger gmail com>:
> FAS started using the python-migrate package to update its db.  This is a
> good thing for third-parties that want to install their own FAS server as it
> lets us ship the database changes in a way that is easy for those users to
> apply to their own production databases.
>
> However, it doesn't work very well in our particular environment because
> we're a bit more strict about our permissions than the migrate authors
> envision.  In order to perform migrations, you need to have a user that can
> modify the schema for the db.  This is either hte owner of the db or the
> superuser.  In our setup, we create the db with the superuser and then run
> our web apps with another user.  This prevents the normal web app from
> modifying the db schema.
>
> To work around this I propose writing a script that does this:
> # 1) Create a db user.
> # 2) grant access to all the values in the specified db
> # 3) run the migrate commands to create the manage.py script and run it with
> the new username and password
> # 4) Reassign any new tables to the postgres user
> # 5) Remove the temporary db user
>
> The command line to invoke it would then look like this:
>
> sudo -u postgres migrate-runner -h DBHOST -d DBNAME MIGRATE_REPO
>
> Does this look:
> 1) Doable -- loupgaroublond I'm looking at you to tell me what the migrate
> commands will be and if there's any caveats to this
>
> 2) Secure -- the point of this would be to keep protecting the db superuser
> with a sudo account on db2 and not being able to use it without a shell on
> db2.  If the security of this solution is less than what giving a password
> to a superuser account would be then we might as well do that instead.
>
> If this looks good, I'll work on coding something up.

I don't see how this is any more secure than just either granting some
user sudo or creating a long term admin DB role just for the FAS DB
that is well protected.

As I see it:

1) the FAS run time itself has not been security audited and vetted,
therefore the least damage it can do to the DB the better.
2) Most of the admins, or rather the people in charge of upgrading FAS
on our servers have been security audited and vetted through a system
of mutual respect in a meritocracy.  Why do we need a temporary
superuser account every time we upgrade?
3) If we store the long term superuser account for FAS somewhere so
upgrade scripts can be done automatically, then all I think we need is
some SELinux / file perm policy that prevents FAS from accessing those
files itself.


As for feasibility, I don't think the migrate scripts themselves can
create new users on the fly, nor do I think that's where we want to do
it.  We probably want to create per project wrappers that get called
instead of manage.py.  Have we spoken to upstream about this yet too?

Or maybe I just need to wake up more, and I'll get it.

-Yaakov


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]