OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Catalog_Namespace::anonymous_namespace{SysCatalog.cpp} Namespace Reference

Functions

void deleteObjectPrivileges (std::unique_ptr< SqliteConnector > &sqliteConnector, std::string roleName, bool userRole, DBObject &object)
 
void insertOrUpdateObjectPrivileges (std::unique_ptr< SqliteConnector > &sqliteConnector, std::string roleName, bool userRole, const DBObject &object)
 
auto get_users (SysCatalog &syscat, std::unique_ptr< SqliteConnector > &sqliteConnector, const int32_t dbId=-1)
 

Variables

auto append_with_commas
 

Function Documentation

void Catalog_Namespace::anonymous_namespace{SysCatalog.cpp}::deleteObjectPrivileges ( std::unique_ptr< SqliteConnector > &  sqliteConnector,
std::string  roleName,
bool  userRole,
DBObject object 
)

Definition at line 495 of file SysCatalog.cpp.

References DBObjectKey::dbId, DBObjectKey::objectId, DBObjectKey::permissionType, and to_string().

Referenced by Catalog_Namespace::SysCatalog::revokeDBObjectPrivileges_unsafe().

498  {
499  DBObjectKey key = object.getObjectKey();
500 
501  sqliteConnector->query_with_text_params(
502  "DELETE FROM mapd_object_permissions WHERE roleName = ?1 and roleType = ?2 and "
503  "objectPermissionsType = ?3 and "
504  "dbId = "
505  "?4 "
506  "and objectId = ?5",
507  std::vector<std::string>{roleName,
508  std::to_string(userRole),
510  std::to_string(key.dbId),
511  std::to_string(key.objectId)});
512 }
int32_t objectId
Definition: DBObject.h:55
std::string to_string(char const *&&v)
int32_t dbId
Definition: DBObject.h:54
int32_t permissionType
Definition: DBObject.h:53

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

auto Catalog_Namespace::anonymous_namespace{SysCatalog.cpp}::get_users ( SysCatalog &  syscat,
std::unique_ptr< SqliteConnector > &  sqliteConnector,
const int32_t  dbId = -1 
)

Definition at line 1746 of file SysCatalog.cpp.

References Catalog_Namespace::SysCatalog::getUserGrantee(), Grantee::hasAnyPrivilegesOnDb(), Catalog_Namespace::SysCatalog::name(), Catalog_Namespace::parseUserMetadataFromSQLite(), Catalog_Namespace::SysCatalog::temporary_users_by_id_, and Catalog_Namespace::UserMetadata::userName.

Referenced by Catalog_Namespace::SysCatalog::getAllUserMetadata().

1748  {
1749  // Normal users.
1750  sqliteConnector->query(
1751  "SELECT userid, name, passwd_hash, issuper, default_db, can_login FROM mapd_users");
1752  int numRows = sqliteConnector->getNumRows();
1753  list<UserMetadata> user_list;
1754  const bool return_all_users = dbId == -1;
1755  auto has_any_privilege = [&return_all_users, &dbId, &syscat](const std::string& name) {
1756  if (!return_all_users) {
1757  const auto grantee = syscat.getUserGrantee(name);
1758  return grantee ? grantee->hasAnyPrivilegesOnDb(dbId, false) : false;
1759  }
1760  return true;
1761  };
1762  for (int r = 0; r < numRows; ++r) {
1764  parseUserMetadataFromSQLite(sqliteConnector, user, r);
1765  if (has_any_privilege(user.userName)) {
1766  user_list.emplace_back(std::move(user));
1767  }
1768  }
1769 
1770  // Temporary users.
1771  for (const auto& [id, userptr] : syscat.temporary_users_by_id_) {
1772  if (has_any_privilege(userptr->userName)) {
1773  user_list.emplace_back(*userptr);
1774  }
1775  }
1776 
1777  return user_list;
1778 }
static bool parseUserMetadataFromSQLite(const std::unique_ptr< SqliteConnector > &conn, UserMetadata &user, int row)
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::anonymous_namespace{SysCatalog.cpp}::insertOrUpdateObjectPrivileges ( std::unique_ptr< SqliteConnector > &  sqliteConnector,
std::string  roleName,
bool  userRole,
const DBObject object 
)

Definition at line 514 of file SysCatalog.cpp.

References CHECK, DBObjectKey::dbId, DBObjectKey::objectId, DBObjectKey::permissionType, and to_string().

Referenced by Catalog_Namespace::SysCatalog::createRole_unsafe(), Catalog_Namespace::SysCatalog::grantDBObjectPrivileges_unsafe(), Catalog_Namespace::SysCatalog::migrateDBAccessPrivileges(), Catalog_Namespace::SysCatalog::migratePrivileges(), Catalog_Namespace::SysCatalog::populateRoleDbObjects(), and Catalog_Namespace::SysCatalog::revokeDBObjectPrivileges_unsafe().

517  {
518  CHECK(object.valid());
519  DBObjectKey key = object.getObjectKey();
520 
521  sqliteConnector->query_with_text_params(
522  "INSERT OR REPLACE INTO mapd_object_permissions("
523  "roleName, "
524  "roleType, "
525  "objectPermissionsType, "
526  "dbId, "
527  "objectId, "
528  "objectPermissions, "
529  "objectOwnerId,"
530  "objectName) "
531  "VALUES (?1, ?2, ?3, "
532  "?4, ?5, ?6, ?7, ?8)",
533  std::vector<std::string>{
534  roleName, // roleName
535  userRole ? "1" : "0", // roleType
536  std::to_string(key.permissionType), // permissionType
537  std::to_string(key.dbId), // dbId
538  std::to_string(key.objectId), // objectId
539  std::to_string(object.getPrivileges().privileges), // objectPrivileges
540  std::to_string(object.getOwner()), // objectOwnerId
541  object.getName() // name
542  });
543 }
int32_t objectId
Definition: DBObject.h:55
std::string to_string(char const *&&v)
int32_t dbId
Definition: DBObject.h:54
#define CHECK(condition)
Definition: Logger.h:291
int32_t permissionType
Definition: DBObject.h:53

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

auto Catalog_Namespace::anonymous_namespace{SysCatalog.cpp}::append_with_commas
Initial value:
= [](string& s, const string& t) {
if (!s.empty()) {
s += ", ";
}
s += t;
}

Definition at line 1159 of file SysCatalog.cpp.

Referenced by Catalog_Namespace::SysCatalog::alterUser().