OmniSciDB  6686921089
 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 388 of file SysCatalog.cpp.

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

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

391  {
392  DBObjectKey key = object.getObjectKey();
393 
394  sqliteConnector->query_with_text_params(
395  "DELETE FROM mapd_object_permissions WHERE roleName = ?1 and roleType = ?2 and "
396  "objectPermissionsType = ?3 and "
397  "dbId = "
398  "?4 "
399  "and objectId = ?5",
400  std::vector<std::string>{roleName,
401  std::to_string(userRole),
403  std::to_string(key.dbId),
404  std::to_string(key.objectId)});
405 }
int32_t objectId
Definition: DBObject.h:57
std::string to_string(char const *&&v)
int32_t dbId
Definition: DBObject.h:56
int32_t permissionType
Definition: DBObject.h:55

+ 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 1483 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().

1485  {
1486  // Normal users.
1487  sqliteConnector->query(
1488  "SELECT userid, name, passwd_hash, issuper, default_db, can_login FROM mapd_users");
1489  int numRows = sqliteConnector->getNumRows();
1490  list<UserMetadata> user_list;
1491  const bool return_all_users = dbId == -1;
1492  auto has_any_privilege = [&return_all_users, &dbId, &syscat](const std::string& name) {
1493  if (!return_all_users) {
1494  const auto grantee = syscat.getUserGrantee(name);
1495  return grantee ? grantee->hasAnyPrivilegesOnDb(dbId, false) : false;
1496  }
1497  return true;
1498  };
1499  for (int r = 0; r < numRows; ++r) {
1501  parseUserMetadataFromSQLite(sqliteConnector, user, r);
1502  if (has_any_privilege(user.userName)) {
1503  user_list.emplace_back(std::move(user));
1504  }
1505  }
1506 
1507  // Temporary users.
1508  for (const auto& [id, userptr] : syscat.temporary_users_by_id_) {
1509  if (has_any_privilege(userptr->userName)) {
1510  user_list.emplace_back(*userptr);
1511  }
1512  }
1513 
1514  return user_list;
1515 }
string name
Definition: setup.in.py:72
static bool parseUserMetadataFromSQLite(const std::unique_ptr< SqliteConnector > &conn, UserMetadata &user, int row)

+ 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 407 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().

410  {
411  CHECK(object.valid());
412  DBObjectKey key = object.getObjectKey();
413 
414  sqliteConnector->query_with_text_params(
415  "INSERT OR REPLACE INTO mapd_object_permissions("
416  "roleName, "
417  "roleType, "
418  "objectPermissionsType, "
419  "dbId, "
420  "objectId, "
421  "objectPermissions, "
422  "objectOwnerId,"
423  "objectName) "
424  "VALUES (?1, ?2, ?3, "
425  "?4, ?5, ?6, ?7, ?8)",
426  std::vector<std::string>{
427  roleName, // roleName
428  userRole ? "1" : "0", // roleType
429  std::to_string(key.permissionType), // permissionType
430  std::to_string(key.dbId), // dbId
431  std::to_string(key.objectId), // objectId
432  std::to_string(object.getPrivileges().privileges), // objectPrivileges
433  std::to_string(object.getOwner()), // objectOwnerId
434  object.getName() // name
435  });
436 }
int32_t objectId
Definition: DBObject.h:57
std::string to_string(char const *&&v)
int32_t dbId
Definition: DBObject.h:56
#define CHECK(condition)
Definition: Logger.h:209
int32_t permissionType
Definition: DBObject.h:55

+ 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;
}
char * t

Definition at line 991 of file SysCatalog.cpp.

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