2001-05-23 15:26:42 +02:00
|
|
|
/*
|
|
|
|
* The contents of this file are subject to the Interbase Public
|
|
|
|
* License Version 1.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy
|
|
|
|
* of the License at http://www.Inprise.com/IPL.html
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an
|
|
|
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
|
|
|
|
* or implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code was created by Inprise Corporation
|
|
|
|
* and its predecessors. Portions created by Inprise Corporation are
|
|
|
|
* Copyright (C) Inprise Corporation.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
* Contributor(s): ______________________________________.
|
2004-11-07 15:17:56 +01:00
|
|
|
*
|
|
|
|
* 2004.09.14 Alex Peshkoff - security changes, preventing ordinary users
|
|
|
|
* from access to other users crypted passwords and enabling modification
|
|
|
|
* of there own password. Originally suggested by Ivan Prenosil
|
|
|
|
* (see http://www.volny.cz/iprenosil/interbase/ for details).
|
2001-05-23 15:26:42 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Domain definitions */
|
2005-10-24 14:30:57 +02:00
|
|
|
CREATE DOMAIN RDB$COMMENT AS BLOB SUB_TYPE TEXT SEGMENT SIZE 80 CHARACTER SET UNICODE_FSS;
|
|
|
|
CREATE DOMAIN RDB$NAME_PART AS VARCHAR(32) CHARACTER SET UNICODE_FSS DEFAULT _UNICODE_FSS '';
|
|
|
|
CREATE DOMAIN RDB$GID AS INTEGER;
|
|
|
|
CREATE DOMAIN RDB$PASSWD AS VARCHAR(64) CHARACTER SET BINARY;
|
|
|
|
CREATE DOMAIN RDB$UID AS INTEGER;
|
|
|
|
CREATE DOMAIN RDB$USER_NAME AS VARCHAR(128) CHARACTER SET UNICODE_FSS;
|
|
|
|
CREATE DOMAIN RDB$USER_PRIVILEGE AS INTEGER;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
2005-10-19 11:02:04 +02:00
|
|
|
/* Table: RDB$USERS */
|
2005-10-24 14:30:57 +02:00
|
|
|
CREATE TABLE RDB$USERS (
|
|
|
|
RDB$USER_NAME RDB$USER_NAME NOT NULL PRIMARY KEY,
|
2001-05-23 15:26:42 +02:00
|
|
|
/* local system user name for setuid for file permissions */
|
2005-10-24 14:30:57 +02:00
|
|
|
RDB$SYS_USER_NAME RDB$USER_NAME,
|
|
|
|
RDB$GROUP_NAME RDB$USER_NAME,
|
|
|
|
RDB$UID RDB$UID,
|
|
|
|
RDB$GID RDB$GID,
|
2005-12-30 17:08:44 +01:00
|
|
|
RDB$PASSWD RDB$PASSWD NOT NULL,
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2005-10-24 14:30:57 +02:00
|
|
|
/* Privilege level of user - mark a user as having DBA privilege */
|
|
|
|
RDB$PRIVILEGE RDB$USER_PRIVILEGE,
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2005-10-24 14:30:57 +02:00
|
|
|
RDB$COMMENT RDB$COMMENT,
|
|
|
|
RDB$FIRST_NAME RDB$NAME_PART,
|
|
|
|
RDB$MIDDLE_NAME RDB$NAME_PART,
|
|
|
|
RDB$LAST_NAME RDB$NAME_PART);
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-11-07 15:17:56 +01:00
|
|
|
COMMIT;
|
|
|
|
|
2005-10-17 19:15:26 +02:00
|
|
|
/* View: USERS. Let's user modify his own password. */
|
2004-11-07 15:17:56 +01:00
|
|
|
CREATE VIEW USERS (USER_NAME, SYS_USER_NAME, GROUP_NAME, UID, GID, PASSWD,
|
|
|
|
PRIVILEGE, COMMENT, FIRST_NAME, MIDDLE_NAME, LAST_NAME, FULL_NAME) AS
|
2005-10-24 14:30:57 +02:00
|
|
|
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,
|
2006-07-25 16:08:26 +02:00
|
|
|
COALESCE (RDB$first_name || _UNICODE_FSS ' ', '') ||
|
|
|
|
COALESCE (RDB$middle_name || _UNICODE_FSS ' ', '') ||
|
|
|
|
COALESCE (RDB$last_name, '')
|
2005-10-17 19:15:26 +02:00
|
|
|
FROM RDB$USERS
|
2004-12-19 16:24:59 +01:00
|
|
|
WHERE CURRENT_USER = 'SYSDBA'
|
2008-01-16 07:33:06 +01:00
|
|
|
OR CURRENT_ROLE = 'RDB$ADMIN'
|
2005-10-24 14:30:57 +02:00
|
|
|
OR CURRENT_USER = RDB$USERS.RDB$USER_NAME;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-11-07 15:17:56 +01:00
|
|
|
/* Access rights */
|
2005-10-17 19:15:26 +02:00
|
|
|
GRANT ALL ON RDB$USERS to VIEW USERS;
|
2001-05-23 15:26:42 +02:00
|
|
|
GRANT SELECT ON USERS to PUBLIC;
|
2004-11-07 15:17:56 +01:00
|
|
|
GRANT UPDATE(PASSWD, GROUP_NAME, UID, GID, FIRST_NAME, MIDDLE_NAME, LAST_NAME)
|
|
|
|
ON USERS TO PUBLIC;
|
|
|
|
|
|
|
|
COMMIT;
|
|
|
|
|
|
|
|
/* Needed record - with PASSWD = random + SHA1 (random + 'SYSDBA' + crypt('masterke')) */
|
2005-10-24 14:30:57 +02:00
|
|
|
INSERT INTO RDB$USERS(RDB$USER_NAME, RDB$PASSWD, RDB$FIRST_NAME, RDB$MIDDLE_NAME, RDB$LAST_NAME)
|
2004-11-07 15:17:56 +01:00
|
|
|
VALUES ('SYSDBA', 'NLtwcs9LrxLMOYhG0uGM9i6KS7mf3QAKvFVpmRg=', 'Sql', 'Server', 'Administrator');
|
|
|
|
|
|
|
|
COMMIT;
|