OmniSciDB  c0231cc57d
 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 458 of file SysCatalog.cpp.

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

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

461  {
462  DBObjectKey key = object.getObjectKey();
463 
464  sqliteConnector->query_with_text_params(
465  "DELETE FROM mapd_object_permissions WHERE roleName = ?1 and roleType = ?2 and "
466  "objectPermissionsType = ?3 and "
467  "dbId = "
468  "?4 "
469  "and objectId = ?5",
470  std::vector<std::string>{roleName,
471  std::to_string(userRole),
473  std::to_string(key.dbId),
474  std::to_string(key.objectId)});
475 }
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 1677 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().

1679  {
1680  // Normal users.
1681  sqliteConnector->query(
1682  "SELECT userid, name, passwd_hash, issuper, default_db, can_login FROM mapd_users");
1683  int numRows = sqliteConnector->getNumRows();
1684  list<UserMetadata> user_list;
1685  const bool return_all_users = dbId == -1;
1686  auto has_any_privilege = [&return_all_users, &dbId, &syscat](const std::string& name) {
1687  if (!return_all_users) {
1688  const auto grantee = syscat.getUserGrantee(name);
1689  return grantee ? grantee->hasAnyPrivilegesOnDb(dbId, false) : false;
1690  }
1691  return true;
1692  };
1693  for (int r = 0; r < numRows; ++r) {
1695  parseUserMetadataFromSQLite(sqliteConnector, user, r);
1696  if (has_any_privilege(user.userName)) {
1697  user_list.emplace_back(std::move(user));
1698  }
1699  }
1700 
1701  // Temporary users.
1702  for (const auto& [id, userptr] : syscat.temporary_users_by_id_) {
1703  if (has_any_privilege(userptr->userName)) {
1704  user_list.emplace_back(*userptr);
1705  }
1706  }
1707 
1708  return user_list;
1709 }
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 477 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().

480  {
481  CHECK(object.valid());
482  DBObjectKey key = object.getObjectKey();
483 
484  sqliteConnector->query_with_text_params(
485  "INSERT OR REPLACE INTO mapd_object_permissions("
486  "roleName, "
487  "roleType, "
488  "objectPermissionsType, "
489  "dbId, "
490  "objectId, "
491  "objectPermissions, "
492  "objectOwnerId,"
493  "objectName) "
494  "VALUES (?1, ?2, ?3, "
495  "?4, ?5, ?6, ?7, ?8)",
496  std::vector<std::string>{
497  roleName, // roleName
498  userRole ? "1" : "0", // roleType
499  std::to_string(key.permissionType), // permissionType
500  std::to_string(key.dbId), // dbId
501  std::to_string(key.objectId), // objectId
502  std::to_string(object.getPrivileges().privileges), // objectPrivileges
503  std::to_string(object.getOwner()), // objectOwnerId
504  object.getName() // name
505  });
506 }
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:222
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 1091 of file SysCatalog.cpp.

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