OmniSciDB  8fa3bf436f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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, DBObject &object)
 
auto get_users (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 372 of file SysCatalog.cpp.

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

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

375  {
376  DBObjectKey key = object.getObjectKey();
377 
378  sqliteConnector->query_with_text_params(
379  "DELETE FROM mapd_object_permissions WHERE roleName = ?1 and roleType = ?2 and "
380  "objectPermissionsType = ?3 and "
381  "dbId = "
382  "?4 "
383  "and objectId = ?5",
384  std::vector<std::string>{roleName,
385  std::to_string(userRole),
387  std::to_string(key.dbId),
388  std::to_string(key.objectId)});
389 }
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 ( std::unique_ptr< SqliteConnector > &  sqliteConnector,
const int32_t  dbId = -1 
)

Definition at line 1347 of file SysCatalog.cpp.

References setup::name, and test_fsi::r.

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

1348  {
1349  sqliteConnector->query("SELECT userid, name, issuper, can_login FROM mapd_users");
1350  int numRows = sqliteConnector->getNumRows();
1351  list<UserMetadata> user_list;
1352  const bool return_all_users = dbId == -1;
1353  auto has_any_privilege = [&return_all_users, &dbId](const std::string& name) {
1354  if (!return_all_users) {
1355  const auto grantee = SysCatalog::instance().getUserGrantee(name);
1356  return grantee ? grantee->hasAnyPrivilegesOnDb(dbId, false) : false;
1357  }
1358  return true;
1359  };
1360  auto add_user = [&user_list, &has_any_privilege](const int32_t id,
1361  const std::string& name,
1362  const bool super,
1363  const bool can_login) {
1364  if (has_any_privilege(name)) {
1365  user_list.emplace_back(id, name, "", super, -1, can_login);
1366  };
1367  };
1368  for (int r = 0; r < numRows; ++r) {
1369  add_user(sqliteConnector->getData<int>(r, 0),
1370  sqliteConnector->getData<string>(r, 1),
1371  sqliteConnector->getData<bool>(r, 2),
1372  sqliteConnector->getData<bool>(r, 3));
1373  }
1374  return user_list;
1375 }
string name
Definition: setup.in.py:72
tuple r
Definition: test_fsi.py:16

+ 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,
DBObject object 
)

Definition at line 391 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().

394  {
395  CHECK(object.valid());
396  DBObjectKey key = object.getObjectKey();
397 
398  sqliteConnector->query_with_text_params(
399  "INSERT OR REPLACE INTO mapd_object_permissions("
400  "roleName, "
401  "roleType, "
402  "objectPermissionsType, "
403  "dbId, "
404  "objectId, "
405  "objectPermissions, "
406  "objectOwnerId,"
407  "objectName) "
408  "VALUES (?1, ?2, ?3, "
409  "?4, ?5, ?6, ?7, ?8)",
410  std::vector<std::string>{
411  roleName, // roleName
412  userRole ? "1" : "0", // roleType
413  std::to_string(key.permissionType), // permissionType
414  std::to_string(key.dbId), // dbId
415  std::to_string(key.objectId), // objectId
416  std::to_string(object.getPrivileges().privileges), // objectPrivileges
417  std::to_string(object.getOwner()), // objectOwnerId
418  object.getName() // name
419  });
420 }
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:203
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 934 of file SysCatalog.cpp.

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