Re: copy privileges
Posted in 1998
Philippe Juillot wrote:
> I am looking for a simply method to copy the
> access privileges of an old table to a new table.
> It must be possible automatically in an UNIX-script.
>
> I use INFORMIX-Online 7.23
Hmm; it depends on how tricky you want to get and whether
it is a DBA who is going to be doing the permission setting (in
fact, whether the two tables are owned by the same owner, too).
There are two main avenues that spring to mind:
1. Use dbschema to generate the schema for the old table;
discard everything that isn't a grant or revoke statement;
change the old table name into the new table name (worrying
about owner if they are not owned by the same person); and
pipe the transformed statements into dbaccess.
2. Decode systabauth and syscolauth for youself, generating the
new grant and revoke statements on the fly. Depending on the
language used to handle this, you might prepare and execute
the various grant and revoke statements, or you might print
them and pipe the results into dbaccess or whatever. You would
need to add 'AS "grantor"' clauses if your doing this as a DBA.
If you are doing this as a RESOURCE-privileged user, you will have
to modify the permission granting statements a bit more. If you don't
own the old table and aren't a DBA, then you probably can't do all
this sensibly unless you own the new table.
You simplify life if you never give 'WITH GRANT OPTION' privileges.
--
Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net)
Guardian of DBD::Informix v0.59 -- see http://www.perl.com/CPAN
#include <disclaimer.h>