2001-05-23 15:26:42 +02:00
|
|
|
/*
|
|
|
|
* PROGRAM: JRD Access Method
|
|
|
|
* MODULE: scl.h
|
|
|
|
* DESCRIPTION: Security class definitions
|
|
|
|
*
|
|
|
|
* 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): ______________________________________.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef JRD_SCL_H
|
|
|
|
#define JRD_SCL_H
|
|
|
|
|
2008-03-06 14:13:31 +01:00
|
|
|
#include "../common/classes/MetaName.h"
|
|
|
|
#include "../common/classes/tree.h"
|
2011-10-04 14:51:57 +02:00
|
|
|
#include "../common/security.h"
|
2014-07-08 09:35:27 +02:00
|
|
|
#include "../jrd/obj.h"
|
2008-03-06 14:13:31 +01:00
|
|
|
|
2014-04-04 17:57:18 +02:00
|
|
|
namespace Firebird {
|
|
|
|
class ClumpletWriter;
|
|
|
|
}
|
|
|
|
|
2004-03-20 15:57:40 +01:00
|
|
|
namespace Jrd {
|
|
|
|
|
2009-11-27 09:34:34 +01:00
|
|
|
const size_t ACL_BLOB_BUFFER_SIZE = MAX_USHORT; // used to read/write acl blob
|
2008-07-11 15:50:59 +02:00
|
|
|
|
2008-03-08 12:37:15 +01:00
|
|
|
// Security class definition
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2008-03-06 14:13:31 +01:00
|
|
|
class SecurityClass
|
2001-12-24 03:51:06 +01:00
|
|
|
{
|
2008-03-06 14:13:31 +01:00
|
|
|
public:
|
2014-07-08 09:35:27 +02:00
|
|
|
typedef ULONG flags_t;
|
2008-03-06 14:13:31 +01:00
|
|
|
|
2009-04-04 18:39:31 +02:00
|
|
|
SecurityClass(Firebird::MemoryPool &pool, const Firebird::MetaName& name)
|
|
|
|
: scl_flags(0), scl_name(pool, name)
|
2008-12-23 09:41:23 +01:00
|
|
|
{}
|
2008-03-06 14:13:31 +01:00
|
|
|
|
2008-03-08 12:37:15 +01:00
|
|
|
flags_t scl_flags; // Access permissions
|
|
|
|
const Firebird::MetaName scl_name;
|
2008-03-06 14:13:31 +01:00
|
|
|
|
2008-05-10 05:44:57 +02:00
|
|
|
static const Firebird::MetaName& generate(const void*, const SecurityClass* item)
|
2008-12-05 01:56:15 +01:00
|
|
|
{
|
2008-03-08 22:20:26 +01:00
|
|
|
return item->scl_name;
|
2008-03-06 14:13:31 +01:00
|
|
|
}
|
2001-12-24 03:51:06 +01:00
|
|
|
};
|
|
|
|
|
2008-03-06 14:13:31 +01:00
|
|
|
typedef Firebird::BePlusTree<
|
2008-12-05 01:56:15 +01:00
|
|
|
SecurityClass*,
|
|
|
|
Firebird::MetaName,
|
|
|
|
Firebird::MemoryPool,
|
2008-03-06 14:13:31 +01:00
|
|
|
SecurityClass
|
|
|
|
> SecurityClassList;
|
|
|
|
|
|
|
|
|
2013-03-07 14:59:03 +01:00
|
|
|
const SecurityClass::flags_t SCL_select = 1; // SELECT access
|
|
|
|
const SecurityClass::flags_t SCL_drop = 2; // DROP access
|
|
|
|
const SecurityClass::flags_t SCL_control = 4; // Control access
|
|
|
|
const SecurityClass::flags_t SCL_exists = 8; // At least ACL exists
|
|
|
|
const SecurityClass::flags_t SCL_alter = 16; // ALTER access
|
|
|
|
const SecurityClass::flags_t SCL_corrupt = 32; // ACL does look too good
|
|
|
|
const SecurityClass::flags_t SCL_insert = 64; // INSERT access
|
|
|
|
const SecurityClass::flags_t SCL_delete = 128; // DELETE access
|
|
|
|
const SecurityClass::flags_t SCL_update = 256; // UPDATE access
|
|
|
|
const SecurityClass::flags_t SCL_references = 512; // REFERENCES access
|
|
|
|
const SecurityClass::flags_t SCL_execute = 1024; // EXECUTE access
|
|
|
|
const SecurityClass::flags_t SCL_usage = 2048; // USAGE access
|
2014-07-08 09:35:27 +02:00
|
|
|
const SecurityClass::flags_t SCL_create = 4096;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
2009-11-27 09:34:34 +01:00
|
|
|
// information about the user
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2009-11-27 09:34:34 +01:00
|
|
|
const USHORT USR_locksmith = 1; // User has great karma
|
|
|
|
const USHORT USR_dba = 2; // User has DBA privileges
|
|
|
|
const USHORT USR_owner = 4; // User owns database
|
2015-08-18 17:04:04 +02:00
|
|
|
const USHORT USR_mapdown = 8; // Mapping failed when getting context
|
2006-08-16 17:15:58 +02:00
|
|
|
|
2007-06-08 12:24:57 +02:00
|
|
|
class UserId
|
2001-12-24 03:51:06 +01:00
|
|
|
{
|
2007-06-08 12:24:57 +02:00
|
|
|
public:
|
2016-05-12 16:03:54 +02:00
|
|
|
Firebird::MetaName usr_user_name; // User name
|
|
|
|
Firebird::MetaName usr_sql_role_name; // Role name
|
|
|
|
Firebird::SortedArray<Firebird::MetaName> usr_granted_roles; // Granted roles list
|
|
|
|
Firebird::MetaName usr_trusted_role; // Trusted role if set
|
2009-11-27 09:34:34 +01:00
|
|
|
Firebird::string usr_project_name; // Project name
|
|
|
|
Firebird::string usr_org_name; // Organization name
|
2013-09-18 11:37:13 +02:00
|
|
|
Firebird::string usr_auth_method; // Authentication method
|
2014-09-29 13:03:47 +02:00
|
|
|
Auth::AuthenticationBlock usr_auth_block; // Authentication block after mapping
|
2009-11-27 09:34:34 +01:00
|
|
|
USHORT usr_user_id; // User id
|
|
|
|
USHORT usr_group_id; // Group id
|
|
|
|
USHORT usr_flags; // Misc. crud
|
2007-06-08 12:24:57 +02:00
|
|
|
|
2006-08-16 17:15:58 +02:00
|
|
|
bool locksmith() const
|
|
|
|
{
|
2008-01-16 10:48:41 +01:00
|
|
|
return usr_flags & (USR_locksmith | USR_owner | USR_dba);
|
2006-08-16 17:15:58 +02:00
|
|
|
}
|
2007-06-08 12:24:57 +02:00
|
|
|
|
2008-12-23 09:41:23 +01:00
|
|
|
UserId()
|
2010-01-22 15:55:11 +01:00
|
|
|
: usr_user_id(0), usr_group_id(0), usr_flags(0)
|
2016-05-12 16:03:54 +02:00
|
|
|
{}
|
2007-06-08 12:24:57 +02:00
|
|
|
|
|
|
|
UserId(Firebird::MemoryPool& p, const UserId& ui)
|
2008-12-05 01:56:15 +01:00
|
|
|
: usr_user_name(p, ui.usr_user_name),
|
2007-06-08 12:24:57 +02:00
|
|
|
usr_sql_role_name(p, ui.usr_sql_role_name),
|
2016-05-12 16:03:54 +02:00
|
|
|
usr_granted_roles(p),
|
2014-04-30 17:12:12 +02:00
|
|
|
usr_trusted_role(p, ui.usr_trusted_role),
|
2008-12-05 01:56:15 +01:00
|
|
|
usr_project_name(p, ui.usr_project_name),
|
2007-06-08 12:24:57 +02:00
|
|
|
usr_org_name(p, ui.usr_org_name),
|
2013-09-18 11:37:13 +02:00
|
|
|
usr_auth_method(p, ui.usr_auth_method),
|
2011-10-04 14:51:57 +02:00
|
|
|
usr_auth_block(p),
|
2008-12-05 01:56:15 +01:00
|
|
|
usr_user_id(ui.usr_user_id),
|
|
|
|
usr_group_id(ui.usr_group_id),
|
2009-04-04 18:39:31 +02:00
|
|
|
usr_flags(ui.usr_flags)
|
2011-10-04 14:51:57 +02:00
|
|
|
{
|
|
|
|
usr_auth_block.assign(ui.usr_auth_block);
|
2016-05-12 16:03:54 +02:00
|
|
|
usr_granted_roles = ui.usr_granted_roles;
|
2011-10-04 14:51:57 +02:00
|
|
|
}
|
2007-06-08 12:24:57 +02:00
|
|
|
|
2008-12-23 09:41:23 +01:00
|
|
|
UserId(const UserId& ui)
|
|
|
|
: usr_user_name(ui.usr_user_name),
|
|
|
|
usr_sql_role_name(ui.usr_sql_role_name),
|
2016-05-12 16:03:54 +02:00
|
|
|
usr_granted_roles(ui.usr_granted_roles),
|
2014-04-30 17:12:12 +02:00
|
|
|
usr_trusted_role(ui.usr_trusted_role),
|
2008-12-23 09:41:23 +01:00
|
|
|
usr_project_name(ui.usr_project_name),
|
|
|
|
usr_org_name(ui.usr_org_name),
|
2013-09-18 11:37:13 +02:00
|
|
|
usr_auth_method(ui.usr_auth_method),
|
2008-12-23 09:41:23 +01:00
|
|
|
usr_user_id(ui.usr_user_id),
|
|
|
|
usr_group_id(ui.usr_group_id),
|
2009-04-04 18:39:31 +02:00
|
|
|
usr_flags(ui.usr_flags)
|
2011-10-04 14:51:57 +02:00
|
|
|
{
|
|
|
|
usr_auth_block.assign(ui.usr_auth_block);
|
|
|
|
}
|
2009-04-04 18:39:31 +02:00
|
|
|
|
2007-06-08 12:24:57 +02:00
|
|
|
UserId& operator=(const UserId& ui)
|
|
|
|
{
|
|
|
|
usr_user_name = ui.usr_user_name;
|
|
|
|
usr_sql_role_name = ui.usr_sql_role_name;
|
2016-05-12 16:03:54 +02:00
|
|
|
usr_granted_roles = ui.usr_granted_roles;
|
2014-04-30 17:12:12 +02:00
|
|
|
usr_trusted_role = ui.usr_trusted_role;
|
2007-06-08 12:24:57 +02:00
|
|
|
usr_project_name = ui.usr_project_name;
|
|
|
|
usr_org_name = ui.usr_org_name;
|
2013-09-18 11:37:13 +02:00
|
|
|
usr_auth_method = ui.usr_auth_method;
|
2007-06-08 12:24:57 +02:00
|
|
|
usr_user_id = ui.usr_user_id;
|
|
|
|
usr_group_id = ui.usr_group_id;
|
|
|
|
usr_flags = ui.usr_flags;
|
2011-10-04 14:51:57 +02:00
|
|
|
usr_auth_block.assign(ui.usr_auth_block);
|
2007-06-08 12:24:57 +02:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
2014-04-04 17:57:18 +02:00
|
|
|
|
|
|
|
void populateDpb(Firebird::ClumpletWriter& dpb);
|
2001-12-24 03:51:06 +01:00
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2010-02-13 09:31:16 +01:00
|
|
|
// These numbers are arbitrary and only used at run-time. Can be changed if necessary at any moment.
|
|
|
|
// We need to include here the new objects that accept ACLs.
|
2014-07-08 09:35:27 +02:00
|
|
|
const SLONG SCL_object_database = obj_database;
|
|
|
|
const SLONG SCL_object_table = obj_relations;
|
|
|
|
const SLONG SCL_object_package = obj_packages;
|
|
|
|
const SLONG SCL_object_procedure = obj_procedures;
|
|
|
|
const SLONG SCL_object_function = obj_functions;
|
|
|
|
const SLONG SCL_object_collation = obj_collations;
|
|
|
|
const SLONG SCL_object_exception = obj_exceptions;
|
|
|
|
const SLONG SCL_object_generator = obj_generators;
|
|
|
|
const SLONG SCL_object_charset = obj_charsets;
|
|
|
|
const SLONG SCL_object_domain = obj_domains;
|
|
|
|
const SLONG SCL_object_view = obj_views;
|
|
|
|
const SLONG SCL_object_role = obj_roles;
|
|
|
|
const SLONG SCL_object_filter = obj_filters;
|
2015-06-09 15:18:27 +02:00
|
|
|
// Please keep it with code more than other objects
|
|
|
|
// - relations and procedures should be sorted before columns.
|
|
|
|
const SLONG SCL_object_column = obj_type_MAX + 1;
|
2002-06-29 15:03:13 +02:00
|
|
|
|
2004-03-20 15:57:40 +01:00
|
|
|
} //namespace Jrd
|
|
|
|
|
2004-02-20 07:43:27 +01:00
|
|
|
#endif // JRD_SCL_H
|