OmniSciDB  bf83d84833
 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 326 of file SysCatalog.cpp.

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

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

329  {
330  DBObjectKey key = object.getObjectKey();
331 
332  sqliteConnector->query_with_text_params(
333  "DELETE FROM mapd_object_permissions WHERE roleName = ?1 and roleType = ?2 and "
334  "objectPermissionsType = ?3 and "
335  "dbId = "
336  "?4 "
337  "and objectId = ?5",
338  std::vector<std::string>{roleName,
339  std::to_string(userRole),
341  std::to_string(key.dbId),
342  std::to_string(key.objectId)});
343 }
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 1291 of file SysCatalog.cpp.

References setup::name.

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

1292  {
1293  sqliteConnector->query("SELECT userid, name, issuper, can_login FROM mapd_users");
1294  int numRows = sqliteConnector->getNumRows();
1295  list<UserMetadata> user_list;
1296  const bool return_all_users = dbId == -1;
1297  auto has_any_privilege = [&return_all_users, &dbId](const std::string& name) {
1298  if (!return_all_users) {
1299  const auto grantee = SysCatalog::instance().getUserGrantee(name);
1300  return grantee ? grantee->hasAnyPrivilegesOnDb(dbId, false) : false;
1301  }
1302  return true;
1303  };
1304  auto add_user = [&user_list, &has_any_privilege](const int32_t id,
1305  const std::string& name,
1306  const bool super,
1307  const bool can_login) {
1308  if (has_any_privilege(name)) {
1309  user_list.emplace_back(id, name, "", super, -1, can_login);
1310  };
1311  };
1312  for (int r = 0; r < numRows; ++r) {
1313  add_user(sqliteConnector->getData<int>(r, 0),
1314  sqliteConnector->getData<string>(r, 1),
1315  sqliteConnector->getData<bool>(r, 2),
1316  sqliteConnector->getData<bool>(r, 3));
1317  }
1318  return user_list;
1319 }
string name
Definition: setup.py:35

+ 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 345 of file SysCatalog.cpp.

References 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().

348  {
349  DBObjectKey key = object.getObjectKey();
350 
351  sqliteConnector->query_with_text_params(
352  "INSERT OR REPLACE INTO mapd_object_permissions("
353  "roleName, "
354  "roleType, "
355  "objectPermissionsType, "
356  "dbId, "
357  "objectId, "
358  "objectPermissions, "
359  "objectOwnerId,"
360  "objectName) "
361  "VALUES (?1, ?2, ?3, "
362  "?4, ?5, ?6, ?7, ?8)",
363  std::vector<std::string>{
364  roleName, // roleName
365  userRole ? "1" : "0", // roleType
366  std::to_string(key.permissionType), // permissionType
367  std::to_string(key.dbId), // dbId
368  std::to_string(key.objectId), // objectId
369  std::to_string(object.getPrivileges().privileges), // objectPrivileges
370  std::to_string(object.getOwner()), // objectOwnerId
371  object.getName() // name
372  });
373 }
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:

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 888 of file SysCatalog.cpp.

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