OmniSciDB  fe05a0c208
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
anonymous_namespace{SysCatalog.cpp} Namespace Reference

Functions

std::string hash_with_bcrypt (const std::string &pwd)
 
std::filesystem::path copy_catalog_if_read_only (std::filesystem::path base_data_path)
 

Function Documentation

std::filesystem::path anonymous_namespace{SysCatalog.cpp}::copy_catalog_if_read_only ( std::filesystem::path  base_data_path)

Definition at line 78 of file SysCatalog.cpp.

References CHECK_NE, gpu_enabled::copy(), g_read_only, logger::INFO, and LOG.

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

78  {
79  std::filesystem::path catalog_base_data_path;
80 
81  // For a read-only server, make a temporary copy of mapd_catalogs.
82  // This catalog copy must take place before any other catalog accesses.
83  if (!g_read_only) {
84  // Catalog directory mapd_catalogs will be in the normal location.
85  catalog_base_data_path = base_data_path;
86  } else {
87  // Catalog directory mapd_catalogs will be in a temporary location.
88  catalog_base_data_path = base_data_path / "temporary";
89 
90  // Delete the temporary directory if it exists.
91  // The name "temporary" is hardcoded so nobody should object to its deletion!
92  CHECK_NE(catalog_base_data_path.string().find("temporary"), std::string::npos);
93  CHECK_NE(catalog_base_data_path, base_data_path);
94  if (std::filesystem::exists(catalog_base_data_path)) {
95  std::filesystem::remove_all(catalog_base_data_path);
96  }
97  std::filesystem::create_directories(catalog_base_data_path);
98 
99  // Make the temporary copy of the catalog.
100  const auto normal_catalog_path = base_data_path / "mapd_catalogs";
101  const auto temporary_catalog_path = catalog_base_data_path / "mapd_catalogs";
102  LOG(INFO) << "copying catalog from " << normal_catalog_path << " to "
103  << temporary_catalog_path << " for read-only server";
104  std::filesystem::copy(normal_catalog_path,
105  temporary_catalog_path,
106  std::filesystem::copy_options::recursive);
107  }
108 
109  return catalog_base_data_path;
110 }
#define LOG(tag)
Definition: Logger.h:194
DEVICE auto copy(ARGS &&...args)
Definition: gpu_enabled.h:51
#define CHECK_NE(x, y)
Definition: Logger.h:212
bool g_read_only
Definition: File.cpp:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string anonymous_namespace{SysCatalog.cpp}::hash_with_bcrypt ( const std::string &  pwd)

Definition at line 70 of file SysCatalog.cpp.

References CHECK.

Referenced by Catalog_Namespace::SysCatalog::alterUser(), Catalog_Namespace::SysCatalog::createUser(), Catalog_Namespace::SysCatalog::initDB(), Catalog_Namespace::SysCatalog::updateBlankPasswordsToRandom(), and Catalog_Namespace::SysCatalog::updatePasswordsToHashes().

70  {
71  char salt[BCRYPT_HASHSIZE], hash[BCRYPT_HASHSIZE];
72  CHECK(bcrypt_gensalt(-1, salt) == 0);
73  CHECK(bcrypt_hashpw(pwd.c_str(), salt, hash) == 0);
74  return std::string(hash, BCRYPT_HASHSIZE);
75 }
#define CHECK(condition)
Definition: Logger.h:203

+ Here is the caller graph for this function: