Subject Re: [firebird-support] Re: Firebird 2.x security and non-SYSDBA users
Author Christian Waldmann
This is my script to add a second user (called 'ADMINISTRATOR') that can
administrate users, applied to the security2.fdb:

The modifications are: add the new user to the where clause and grant
the view to the new user


SET SQL DIALECT 3;
SET NAMES WIN1252;

/*-------------------------------------------------------------------------*/
/* Dropping old views */
/*-------------------------------------------------------------------------*/
DROP VIEW USERS;

/*-------------------------------------------------------------------------*/
/* Creating new views */
/*-------------------------------------------------------------------------*/
CREATE VIEW USERS(
USER_NAME,
SYS_USER_NAME,
GROUP_NAME,
UID,
GID,
PASSWD,
PRIVILEGE,
"COMMENT",
FIRST_NAME,
MIDDLE_NAME,
LAST_NAME,
FULL_NAME)
AS
SELECT RDB$USER_NAME, RDB$SYS_USER_NAME, RDB$GROUP_NAME, RDB$UID,
RDB$GID, RDB$PASSWD,
RDB$PRIVILEGE, RDB$COMMENT, RDB$FIRST_NAME, RDB$MIDDLE_NAME,
RDB$LAST_NAME,
COALESCE (RDB$first_name || _UNICODE_FSS ' ', '') ||
COALESCE (RDB$middle_name || _UNICODE_FSS ' ', '') ||
COALESCE (RDB$last_name, '')
FROM RDB$USERS
WHERE CURRENT_USER = 'SYSDBA'
OR CURRENT_USER = 'ADMINISTRATOR'
OR CURRENT_USER = RDB$USERS.RDB$USER_NAME
;
/*-------------------------------------------------------------------------*/
/* Restoring privileges */
/*-------------------------------------------------------------------------*/
GRANT SELECT, UPDATE, DELETE, INSERT, REFERENCES ON RDB$USERS TO VIEW USERS;
GRANT SELECT ON USERS TO "PUBLIC";


/******************************************************************************/
/**** Privileges
****/
/******************************************************************************/
GRANT ALL ON USERS TO ADMINISTRATOR;